- attempt to fix bug #8872 (build fails --without-http-zlib-compression)
authorMichael Wallner <mike@php.net>
Sat, 7 Oct 2006 12:46:22 +0000 (12:46 +0000)
committerMichael Wallner <mike@php.net>
Sat, 7 Oct 2006 12:46:22 +0000 (12:46 +0000)
- finally fix invalid detection wheter a deflated response should be started

http_encoding_api.c
http_response_object.c
http_send_api.c
package2.xml
php_http.h
php_http_encoding_api.h

index 0de420a81a89fbf41fdfd744e937dc598afc916b..2d20908951ce01c37e1b13d9e3b6ba2a4d4a1aeb 100644 (file)
@@ -158,18 +158,22 @@ PHP_HTTP_API const char *_http_encoding_dechunk(const char *encoded, size_t enco
 /* }}} */
 
 /* {{{ int http_encoding_response_start(size_t) */
-PHP_HTTP_API int _http_encoding_response_start(size_t content_length TSRMLS_DC)
+PHP_HTTP_API int _http_encoding_response_start(size_t content_length, zend_bool ignore_http_ohandler TSRMLS_DC)
 {
-       int is_http = HTTP_G->send.deflate.encoding;
-       int is_zlib = php_ob_handler_used("ob_gzhandler" TSRMLS_CC) || php_ob_handler_used("zlib output compression" TSRMLS_CC);
+       int response = HTTP_G->send.deflate.response;
+       int ohandler = php_ob_handler_used("ob_gzhandler" TSRMLS_CC) || php_ob_handler_used("zlib output compression" TSRMLS_CC);
        
-       HTTP_G->send.deflate.encoding = 0;
+       if (!ohandler && !ignore_http_ohandler) {
+               ohandler = php_ob_handler_used("ob_deflatehandler" TSRMLS_CC) || php_ob_handler_used("http deflate" TSRMLS_CC);
+       }
        
-       if (is_http && !is_zlib) {
+       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);
@@ -202,14 +206,17 @@ PHP_HTTP_API int _http_encoding_response_start(size_t content_length TSRMLS_DC)
                
                zval_dtor(&zsupported);
 #else
+               HTTP_G->send.deflate.encoding = 0;
                php_start_ob_buffer_named("ob_gzhandler", 0, 0 TSRMLS_CC);
 #endif /* HTTP_HAVE_ZLIB */
-       } else if (content_length && !is_zlib) {
+       } else if (content_length && !ohandler) {
                /* emit a content-length header */
                char cl_header_str[128];
                size_t cl_header_len;
                cl_header_len = snprintf(cl_header_str, lenof(cl_header_str), "Content-Length: %zu", content_length);
                http_send_header_string_ex(cl_header_str, cl_header_len, 1);
+       } else {
+               HTTP_G->send.deflate.encoding = 0;
        }
        
        return HTTP_G->send.deflate.encoding;
@@ -651,6 +658,8 @@ PHP_HTTP_API void _http_encoding_inflate_stream_free(http_encoding_stream **s TS
 /* {{{ void http_ob_deflatehandler(char *, uint, char **, uint *, int) */
 void _http_ob_deflatehandler(char *output, uint output_len, char **handled_output, uint *handled_output_len, int mode TSRMLS_DC)
 {
+       int encoding;
+       
        *handled_output = NULL;
        *handled_output_len = 0;
        
@@ -662,9 +671,11 @@ void _http_ob_deflatehandler(char *output, uint output_len, char **handled_outpu
                        return;
                }
                
-               HTTP_G->send.deflate.encoding = !0;
+               HTTP_G->send.deflate.response = 1;
+               encoding = http_encoding_response_start(0, 1);
+               HTTP_G->send.deflate.response = 0;
                
-               switch (http_encoding_response_start(0)) {
+               switch (encoding) {
                        case HTTP_ENCODING_GZIP:
                                flags = HTTP_DEFLATE_TYPE_GZIP;
                                break;
index d7be4032c15f40fc347616600085857c0eff9a09..8b00412771d531ee6c6e051e6c9fadc119354ebb 100644 (file)
@@ -1154,7 +1154,7 @@ PHP_METHOD(HttpResponse, send)
        }
 
        /* gzip */
-       HTTP_G->send.deflate.encoding = zval_is_true(GET_STATIC_PROP(gzip));
+       HTTP_G->send.deflate.response = zval_is_true(GET_STATIC_PROP(gzip));
        
        /* send */
        switch (Z_LVAL_P(GET_STATIC_PROP(mode))) {
index 2be92b62dec675c02fd141aaeb65dc3c30ac0391..d1a2ebeb08d3234c4dce327210b3c26cabbcb954 100644 (file)
@@ -51,7 +51,7 @@ static inline void _http_send_response_start(void **buffer, size_t content_lengt
 {
        int encoding;
        
-       if ((encoding = http_encoding_response_start(content_length))) {
+       if ((encoding = http_encoding_response_start(content_length, 0))) {
 #ifdef HTTP_HAVE_ZLIB
                *buffer = http_encoding_deflate_stream_init(NULL, 
                        (encoding == HTTP_ENCODING_GZIP) ? 
@@ -65,7 +65,7 @@ static inline void _http_send_response_start(void **buffer, size_t content_lengt
 #define http_send_response_data_plain(b, d, dl) _http_send_response_data_plain((b), (d), (dl) TSRMLS_CC)
 static inline void _http_send_response_data_plain(void **buffer, const char *data, size_t data_len TSRMLS_DC)
 {
-       if (HTTP_G->send.deflate.encoding && *(http_encoding_stream **) buffer) {
+       if (HTTP_G->send.deflate.response && HTTP_G->send.deflate.encoding) {
 #ifdef HTTP_HAVE_ZLIB
                char *encoded;
                size_t encoded_len;
@@ -137,7 +137,7 @@ static inline void _http_send_response_data_fetch(void **buffer, const void *dat
 #define http_send_response_finish(b) _http_send_response_finish((b) TSRMLS_CC)
 static inline void _http_send_response_finish(void **buffer TSRMLS_DC)
 {
-       if (HTTP_G->send.deflate.encoding && *(http_encoding_stream **) buffer) {
+       if (HTTP_G->send.deflate.response && HTTP_G->send.deflate.encoding) {
 #ifdef HTTP_HAVE_ZLIB
                char *encoded = NULL;
                size_t encoded_len = 0;
index 83fece314e0c10368926c3ff0681cbdb6721c644..17b6404ed8411980f6a67ebd63aba6bb2a7a01ee 100644 (file)
@@ -28,9 +28,9 @@ support. Parallel requests are available for PHP 5 and greater.
   <email>mike@php.net</email>
   <active>yes</active>
  </lead>
- <date>2006-10-02</date>
+ <date>2006-10-07</date>
  <version>
-  <release>1.3.1</release>
+  <release>1.3.2</release>
   <api>1.3.0</api>
  </version>
  <stability>
@@ -39,8 +39,8 @@ support. Parallel requests are available for PHP 5 and greater.
  </stability>
  <license>BSD, revised</license>
  <notes><![CDATA[
-* Fixed build with gcc-2.95 (bug #8737)
-* Fixed bug in HttpRequestPool where a negative timeout was passed to select()
+* Fixed invalid detection whether a deflated response should be started
+* Fixed build --without-http-zlib-compression (bug #8872)
 ]]></notes>
  <contents>
   <dir name="/">
index c93067ec2824afdb03e5e2c2995a13c072558a33..a23ac69f942d74260580ae67aa8afeb89a71a8f0 100644 (file)
@@ -15,7 +15,7 @@
 #ifndef PHP_EXT_HTTP_H
 #define PHP_EXT_HTTP_H
 
-#define PHP_EXT_HTTP_VERSION "1.3.1"
+#define PHP_EXT_HTTP_VERSION "1.3.2"
 
 #ifdef HAVE_CONFIG_H
 #      include "config.h"
@@ -102,6 +102,7 @@ ZEND_BEGIN_MODULE_GLOBALS(http)
                char *unquoted_etag;
                time_t last_modified;
                struct _http_globals_send_deflate {
+                       zend_bool response;
                        zend_bool start_auto;
                        long start_flags;
                        int encoding;
index 8ebddbaa3b42ce5baca688c4cbf18b2b446168c4..4f0afd8f5c33e3c3972b82ce21a77daec47d872a 100644 (file)
@@ -18,8 +18,8 @@
 #define http_encoding_dechunk(e, el, d, dl) _http_encoding_dechunk((e), (el), (d), (dl) TSRMLS_CC)
 PHP_HTTP_API const char *_http_encoding_dechunk(const char *encoded, size_t encoded_len, char **decoded, size_t *decoded_len TSRMLS_DC);
 
-#define http_encoding_response_start(cl) _http_encoding_response_start((cl) TSRMLS_CC)
-PHP_HTTP_API int _http_encoding_response_start(size_t content_length TSRMLS_DC);
+#define http_encoding_response_start(cl, i) _http_encoding_response_start((cl), (i) TSRMLS_CC)
+PHP_HTTP_API int _http_encoding_response_start(size_t content_length, zend_bool ignore_http_ohandler TSRMLS_DC);
 
 #ifdef HTTP_HAVE_ZLIB