From: Michael Wallner Date: Mon, 23 Jan 2012 09:05:46 +0000 (+0000) Subject: filter tests & fixes X-Git-Tag: DEV_2-before-client~59 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=02b671786e119a62ebe1a8183d682a39b4958a7b;p=m6w6%2Fext-http filter tests & fixes --- diff --git a/php_http_filter.c b/php_http_filter.c index 121966b..2c53358 100644 --- a/php_http_filter.c +++ b/php_http_filter.c @@ -363,7 +363,28 @@ static php_stream_filter *http_filter_create(const char *name, zval *params, int { zval **tmp = ¶ms; php_stream_filter *f = NULL; + int flags = p ? PHP_HTTP_ENCODING_STREAM_PERSISTENT : 0; + if (params) { + switch (Z_TYPE_P(params)) { + case IS_ARRAY: + case IS_OBJECT: + if (SUCCESS != zend_hash_find(HASH_OF(params), "flags", sizeof("flags"), (void *) &tmp)) { + break; + } + /* no break */ + default: + { + zval *num = php_http_ztyp(IS_LONG, *tmp); + + flags |= (Z_LVAL_P(num) & 0x0fffffff); + zval_ptr_dtor(&num); + + } + break; + } + } + if (!strcasecmp(name, "http.chunked_decode")) { PHP_HTTP_FILTER_BUFFER(chunked_decode) *b = NULL; @@ -380,7 +401,6 @@ static php_stream_filter *http_filter_create(const char *name, zval *params, int } else if (!strcasecmp(name, "http.inflate")) { - int flags = p ? PHP_HTTP_ENCODING_STREAM_PERSISTENT : 0; PHP_HTTP_FILTER_BUFFER(zlib) *b = NULL; if ((b = php_http_encoding_stream_init(NULL, php_http_encoding_stream_get_inflate_ops(), flags TSRMLS_CC))) { @@ -391,28 +411,8 @@ static php_stream_filter *http_filter_create(const char *name, zval *params, int } else if (!strcasecmp(name, "http.deflate")) { - int flags = p ? PHP_HTTP_ENCODING_STREAM_PERSISTENT : 0; PHP_HTTP_FILTER_BUFFER(zlib) *b = NULL; - if (params) { - switch (Z_TYPE_P(params)) { - case IS_ARRAY: - case IS_OBJECT: - if (SUCCESS != zend_hash_find(HASH_OF(params), "flags", sizeof("flags"), (void *) &tmp)) { - break; - } - /* no break */ - default: - { - zval *num = php_http_ztyp(IS_LONG, *tmp); - - flags |= (Z_LVAL_P(num) & 0x0fffffff); - zval_ptr_dtor(&num); - - } - break; - } - } if ((b = php_http_encoding_stream_init(NULL, php_http_encoding_stream_get_deflate_ops(), flags TSRMLS_CC))) { if (!(f = php_stream_filter_alloc(&PHP_HTTP_FILTER_OP(deflate), b, p))) { php_http_encoding_stream_free(&b); diff --git a/tests/filterchunked.phpt b/tests/filterchunked.phpt new file mode 100644 index 0000000..f2d2850 --- /dev/null +++ b/tests/filterchunked.phpt @@ -0,0 +1,29 @@ +--TEST-- +chunked filter +--SKIPIF-- + +--FILE-- + +DONE +--EXPECT-- +DONE diff --git a/tests/filterzlib.phpt b/tests/filterzlib.phpt new file mode 100644 index 0000000..bbfac86 --- /dev/null +++ b/tests/filterzlib.phpt @@ -0,0 +1,29 @@ +--TEST-- +zlib filter +--SKIPIF-- + +--FILE-- + +DONE +--EXPECT-- +DONE