{
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;
} 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))) {
} 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);
--- /dev/null
+--TEST--
+chunked filter
+--SKIPIF--
+<?php include "skipif.inc"; ?>
+--FILE--
+<?php
+list($in, $out) = stream_socket_pair(
+ STREAM_PF_UNIX,
+ STREAM_SOCK_STREAM,
+ STREAM_IPPROTO_IP
+);
+stream_filter_append($in, "http.chunked_decode", STREAM_FILTER_READ);
+stream_filter_append($out, "http.chunked_encode", STREAM_FILTER_WRITE,
+ array());
+
+$file = file(__FILE__);
+foreach($file as $line) {
+ fwrite($out, $line);
+ fflush($out);
+}
+fclose($out);
+if (implode("",$file) !== ($read = fread($in, filesize(__FILE__)))) {
+ echo "got: $read\n";
+}
+fclose($in);
+?>
+DONE
+--EXPECT--
+DONE
--- /dev/null
+--TEST--
+zlib filter
+--SKIPIF--
+<?php include "skipif.inc"; ?>
+--FILE--
+<?php
+list($in, $out) = stream_socket_pair(
+ STREAM_PF_UNIX,
+ STREAM_SOCK_STREAM,
+ STREAM_IPPROTO_IP
+);
+stream_filter_append($in, "http.inflate", STREAM_FILTER_READ);
+stream_filter_append($out, "http.deflate", STREAM_FILTER_WRITE,
+ http\Encoding\Stream\Deflate::LEVEL_MAX);
+
+$file = file(__FILE__);
+foreach ($file as $line) {
+ fwrite($out, $line);
+ fflush($out);
+}
+fclose($out);
+if (implode("",$file) !== ($read = fread($in, filesize(__FILE__)))) {
+ echo "got: $read\n";
+}
+fclose($in);
+?>
+DONE
+--EXPECT--
+DONE