X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=http_filter_api.c;h=8d138b9c748e214807cd15dd13abeeb5716cd641;hb=31092c29dba06404d2f0d856d5a89f0b28be6f0b;hp=dcc71867ed444648c0d09f53e34ff35507882474;hpb=ccd556e32e7264830790ec13b72a9b0e3760684b;p=m6w6%2Fext-http diff --git a/http_filter_api.c b/http_filter_api.c index dcc7186..8d138b9 100644 --- a/http_filter_api.c +++ b/http_filter_api.c @@ -165,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) { @@ -313,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); } } @@ -331,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); } } @@ -343,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); } } @@ -378,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); } } @@ -396,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); } } @@ -408,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); } } @@ -465,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))) { @@ -476,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) { @@ -484,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: @@ -492,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); } }