- HashTable *selected;
- zval zsupported;
-
- INIT_PZVAL(&zsupported);
- array_init(&zsupported);
- add_next_index_stringl(&zsupported, "gzip", lenof("gzip"), 1);
- add_next_index_stringl(&zsupported, "x-gzip", lenof("x-gzip"), 1);
- add_next_index_stringl(&zsupported, "deflate", lenof("deflate"), 1);
-
- HTTP_G->send.deflate.encoding = 0;
+ int ohandler = php_ob_handler_used("ob_gzhandler" TSRMLS_CC) || php_ob_handler_used("zlib output compression" TSRMLS_CC);
+#endif
+
+ if (!ohandler && !ignore_http_ohandler) {
+#ifdef PHP_OUTPUT_NEWAPI
+ ohandler = php_output_handler_started(ZEND_STRL("ob_defaltehandler") TSRMLS_CC) || php_output_handler_started(ZEND_STRL("http deflate") TSRMLS_CC);
+#else
+ ohandler = php_ob_handler_used("ob_deflatehandler" TSRMLS_CC) || php_ob_handler_used("http deflate" TSRMLS_CC);
+#endif
+ }
+
+ if (response && !ohandler) {
+#ifdef HTTP_HAVE_ZLIB
+ HashTable *selected;
+ zval zsupported;
+
+ HTTP_G->send.deflate.encoding = 0;
+
+ INIT_PZVAL(&zsupported);
+ array_init(&zsupported);
+ add_next_index_stringl(&zsupported, "gzip", lenof("gzip"), 1);
+ add_next_index_stringl(&zsupported, "x-gzip", lenof("x-gzip"), 1);
+ add_next_index_stringl(&zsupported, "deflate", lenof("deflate"), 1);
+
+ if ((selected = http_negotiate_encoding(&zsupported))) {
+ STATUS hs = FAILURE;
+ char *encoding = NULL;
+ ulong idx;