- } else {
- php_http_error(HE_WARNING, PHP_HTTP_E_ENCODING, "HttpEncodingStream cannot be initialized twice");
- }
- } end_error_handling();
- }
- } end_error_handling();
+ obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+
+ if (obj->stream) {
+ php_http_throw(bad_method_call, "http\\Encoding\\Stream cannot be initialized twice", NULL);
+ return;
+ }
+
+ if (instanceof_function(obj->zo.ce, php_http_deflate_stream_class_entry TSRMLS_CC)) {
+ ops = &php_http_encoding_deflate_ops;
+ } else if (instanceof_function(obj->zo.ce, php_http_inflate_stream_class_entry TSRMLS_CC)) {
+ ops = &php_http_encoding_inflate_ops;
+ } else if (instanceof_function(obj->zo.ce, php_http_dechunk_stream_class_entry TSRMLS_CC)) {
+ ops = &php_http_encoding_dechunk_ops;
+ } else {
+ php_http_throw(runtime, "Unknown http\\Encoding\\Stream class '%s'", obj->zo.ce->name);
+ return;
+ }
+
+ php_http_expect(obj->stream = php_http_encoding_stream_init(obj->stream, ops, flags TSRMLS_CC), runtime, return);