X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=http_encoding_api.c;h=c0d1140d4d452f5e0d304caea652959836709c1d;hb=d4f8313f211bdc3e62a4788690cad8edef85f7f2;hp=f57add91cff00ce9c5a1ae6895db82961078e5d9;hpb=b20688d08c28e9733ba6c021f5eee460ee6bf07a;p=m6w6%2Fext-http diff --git a/http_encoding_api.c b/http_encoding_api.c index f57add9..c0d1140 100644 --- a/http_encoding_api.c +++ b/http_encoding_api.c @@ -392,7 +392,7 @@ PHP_HTTP_API STATUS _http_encoding_deflate_stream_update(http_encoding_stream *s case Z_OK: case Z_STREAM_END: /* cut processed chunk off the buffer */ - phpstr_cut(PHPSTR(s->stream.opaque), 0, data_len - s->stream.avail_in); + phpstr_cut(PHPSTR(s->stream.opaque), 0, PHPSTR_LEN(s->stream.opaque) - s->stream.avail_in); /* size buffer down to actual size */ *encoded_len -= s->stream.avail_out; @@ -436,7 +436,7 @@ retry_raw_inflate: case Z_OK: case Z_STREAM_END: /* cut off */ - phpstr_cut(PHPSTR(s->stream.opaque), 0, data_len - s->stream.avail_in); + phpstr_cut(PHPSTR(s->stream.opaque), 0, PHPSTR_LEN(s->stream.opaque) - s->stream.avail_in); /* size down */ *decoded_len -= s->stream.avail_out; @@ -467,7 +467,7 @@ PHP_HTTP_API STATUS _http_encoding_deflate_stream_flush(http_encoding_stream *s, { int status; - *encoded_len = 0x800; + *encoded_len = 0x8000; *encoded = emalloc_rel(*encoded_len); s->stream.avail_in = 0; @@ -479,7 +479,7 @@ PHP_HTTP_API STATUS _http_encoding_deflate_stream_flush(http_encoding_stream *s, { case Z_OK: case Z_STREAM_END: - *encoded_len = 0x800 - s->stream.avail_out; + *encoded_len = 0x8000 - s->stream.avail_out; *encoded = erealloc_rel(*encoded, *encoded_len + 1); (*encoded)[*encoded_len] = '\0'; return SUCCESS; @@ -494,38 +494,16 @@ PHP_HTTP_API STATUS _http_encoding_deflate_stream_flush(http_encoding_stream *s, PHP_HTTP_API STATUS _http_encoding_inflate_stream_flush(http_encoding_stream *s, char **decoded, size_t *decoded_len ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC TSRMLS_DC) { - int status; - - *decoded_len = 0x800; - *decoded = emalloc_rel(*decoded_len); - - s->stream.avail_in = 0; - s->stream.next_in = NULL; - s->stream.avail_out = *decoded_len; - s->stream.next_out = (Bytef *) *decoded; - - switch (status = inflate(&s->stream, Z_SYNC_FLUSH)) - { - case Z_OK: - case Z_STREAM_END: - *decoded_len = 0x800 - s->stream.avail_out; - *decoded = erealloc_rel(*decoded, *decoded_len + 1); - (*decoded)[*decoded_len] = '\0'; - return SUCCESS; - break; - } - - STR_SET(*decoded, NULL); - *decoded_len = 0; - http_error_ex(HE_WARNING, HTTP_E_ENCODING, "Failed to flush inflate stream: %s", zError(status)); - return FAILURE; + /* noop */ + *decoded = estrndup("", *decoded_len = 0); + return SUCCESS; } PHP_HTTP_API STATUS _http_encoding_deflate_stream_finish(http_encoding_stream *s, char **encoded, size_t *encoded_len ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC TSRMLS_DC) { int status; - *encoded_len = 0x800; + *encoded_len = 0x8000; *encoded = emalloc_rel(*encoded_len); /* deflate remaining input */ @@ -560,7 +538,7 @@ PHP_HTTP_API STATUS _http_encoding_inflate_stream_finish(http_encoding_stream *s { int status; - *decoded_len = s->stream.avail_in << 2; + *decoded_len = PHPSTR_LEN(s->stream.opaque) << 2; *decoded = emalloc_rel(*decoded_len); /* inflate remaining input */