X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=http_filter_api.c;h=8d138b9c748e214807cd15dd13abeeb5716cd641;hb=31092c29dba06404d2f0d856d5a89f0b28be6f0b;hp=f7e99ec3a12c13bd488bc13468a62e55c37c1f5a;hpb=32e91737086db53bb1fd9ed9f79d693c43ec459f;p=m6w6%2Fext-http diff --git a/http_filter_api.c b/http_filter_api.c index f7e99ec..8d138b9 100644 --- a/http_filter_api.c +++ b/http_filter_api.c @@ -12,10 +12,6 @@ /* $Id$ */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #define HTTP_WANT_ZLIB #include "php_http.h" @@ -78,7 +74,7 @@ PHP_MINIT_FUNCTION(http_filter) php_stream_bucket_append(buckets_out, __buck TSRMLS_CC); \ } -typedef struct { +typedef struct _http_chunked_decode_filter_buffer_t { phpstr buffer; ulong hexlen; } HTTP_FILTER_BUFFER(chunked_decode); @@ -169,8 +165,8 @@ static HTTP_FILTER_FUNCTION(chunked_decode) /* ignore preceeding CRLFs (too loose?) */ while (off < PHPSTR_LEN(buffer) && ( - PHPSTR_VAL(buffer)[off] == 0xa || - PHPSTR_VAL(buffer)[off] == 0xd)) { + PHPSTR_VAL(buffer)[off] == '\n' || + PHPSTR_VAL(buffer)[off] == '\r')) { ++off; } if (off) { @@ -317,8 +313,10 @@ static HTTP_FILTER_FUNCTION(deflate) if (ptr->buflen) { http_encoding_deflate_stream_update(buffer, ptr->buf, ptr->buflen, &encoded, &encoded_len); if (encoded) { - out_avail = 1; - NEW_BUCKET(encoded, encoded_len); + if (encoded_len) { + out_avail = 1; + NEW_BUCKET(encoded, encoded_len); + } efree(encoded); } } @@ -335,8 +333,10 @@ static HTTP_FILTER_FUNCTION(deflate) http_encoding_deflate_stream_flush(buffer, &encoded, &encoded_len); if (encoded) { - out_avail = 1; - NEW_BUCKET(encoded, encoded_len); + if (encoded_len) { + out_avail = 1; + NEW_BUCKET(encoded, encoded_len); + } efree(encoded); } } @@ -347,8 +347,10 @@ static HTTP_FILTER_FUNCTION(deflate) http_encoding_deflate_stream_finish(buffer, &encoded, &encoded_len); if (encoded) { - out_avail = 1; - NEW_BUCKET(encoded, encoded_len); + if (encoded_len) { + out_avail = 1; + NEW_BUCKET(encoded, encoded_len); + } efree(encoded); } } @@ -382,8 +384,10 @@ static HTTP_FILTER_FUNCTION(inflate) if (ptr->buflen) { http_encoding_inflate_stream_update(buffer, ptr->buf, ptr->buflen, &decoded, &decoded_len); if (decoded) { - out_avail = 1; - NEW_BUCKET(decoded, decoded_len); + if (decoded_len) { + out_avail = 1; + NEW_BUCKET(decoded, decoded_len); + } efree(decoded); } } @@ -400,8 +404,10 @@ static HTTP_FILTER_FUNCTION(inflate) http_encoding_inflate_stream_flush(buffer, &decoded, &decoded_len); if (decoded) { - out_avail = 1; - NEW_BUCKET(decoded, decoded_len); + if (decoded_len) { + out_avail = 1; + NEW_BUCKET(decoded, decoded_len); + } efree(decoded); } } @@ -412,8 +418,10 @@ static HTTP_FILTER_FUNCTION(inflate) http_encoding_inflate_stream_finish(buffer, &decoded, &decoded_len); if (decoded) { - out_avail = 1; - NEW_BUCKET(decoded, decoded_len); + if (decoded_len) { + out_avail = 1; + NEW_BUCKET(decoded, decoded_len); + } efree(decoded); } } @@ -469,7 +477,7 @@ static php_stream_filter *http_filter_create(const char *name, zval *params, int } else if (!strcasecmp(name, "http.inflate")) { - int flags = p ? HTTP_ENCODING_STREAM_PERSISTENT : 0; + int flags = HTTP_ENCODING_STREAM_FLUSH_SYNC | (p ? HTTP_ENCODING_STREAM_PERSISTENT : 0); HTTP_FILTER_BUFFER(inflate) *b = NULL; if ((b = http_encoding_inflate_stream_init(NULL, flags))) { @@ -480,7 +488,7 @@ static php_stream_filter *http_filter_create(const char *name, zval *params, int } else if (!strcasecmp(name, "http.deflate")) { - int flags = p ? HTTP_ENCODING_STREAM_PERSISTENT : 0; + int flags = HTTP_ENCODING_STREAM_FLUSH_SYNC | (p ? HTTP_ENCODING_STREAM_PERSISTENT : 0); HTTP_FILTER_BUFFER(deflate) *b = NULL; if (params) { @@ -488,7 +496,7 @@ static php_stream_filter *http_filter_create(const char *name, zval *params, int { case IS_ARRAY: case IS_OBJECT: - if (SUCCESS != zend_hash_find(HASH_OF(params), "flags", sizeof("flags"), (void **) &tmp)) { + if (SUCCESS != zend_hash_find(HASH_OF(params), "flags", sizeof("flags"), (void *) &tmp)) { break; } default: @@ -496,7 +504,7 @@ static php_stream_filter *http_filter_create(const char *name, zval *params, int zval *orig = *tmp; convert_to_long_ex(tmp); - flags |= (Z_LVAL_PP(tmp) & 0x0fffffff); + flags |= (Z_LVAL_PP(tmp) & 0x00ffffff); if (orig != *tmp) zval_ptr_dtor(tmp); } }