- add ob_(deflate|inflate)handler
authorMichael Wallner <mike@php.net>
Mon, 26 Dec 2005 10:15:55 +0000 (10:15 +0000)
committerMichael Wallner <mike@php.net>
Mon, 26 Dec 2005 10:15:55 +0000 (10:15 +0000)
24 files changed:
docs/http.ini
http.c
http_api.c
http_cache_api.c
http_date_api.c
http_encoding_api.c
http_functions.c
http_headers_api.c
http_info_api.c
http_message_api.c
http_message_object.c
http_request_api.c
http_request_body_api.c
http_request_method_api.c
http_request_object.c
http_request_pool_api.c
http_response_object.c
http_send_api.c
http_url_api.c
php_http.h
php_http_cache_api.h
php_http_encoding_api.h
tests/ut_HttpResponse.phpt [deleted file]
tests/ut_HttpUtil.phpt

index 11e8189..2d96869 100644 (file)
@@ -30,3 +30,11 @@ http.etag_mode = "MD5"
 
 ; composite log file (i.e. log all messages to this file)
 ;http.composite_log =
+
+; automatically deflate content if requested/supported by client
+;http.ob_deflate_auto = 1
+;http.ob_deflate_flags = HTTP_DEFLATE_LEVEL_DEF
+
+; automatically inflate compressed content
+;http.ob_inflate_auto = 0
+;http.ob_inflate_flags =
diff --git a/http.c b/http.c
index 00f8774..5da35c5 100644 (file)
--- a/http.c
+++ b/http.c
@@ -108,6 +108,8 @@ zend_function_entry http_functions[] = {
 #ifdef HTTP_HAVE_ZLIB
        PHP_FE(http_deflate, NULL)
        PHP_FE(http_inflate, NULL)
+       PHP_FE(ob_deflatehandler, NULL)
+       PHP_FE(ob_inflatehandler, NULL)
 #endif
        PHP_FE(http_support, NULL)
        
@@ -157,13 +159,15 @@ static void http_globals_init_once(zend_http_globals *G)
        memset(G, 0, sizeof(zend_http_globals));
 }
 
-static inline void http_globals_init(zend_http_globals *G)
+#define http_globals_init(g) _http_globals_init((g) TSRMLS_CC)
+static inline void _http_globals_init(zend_http_globals *G TSRMLS_DC)
 {
        G->send.buffer_size = HTTP_SENDBUF_SIZE;
        zend_hash_init(&G->request.methods.custom, 0, NULL, ZVAL_PTR_DTOR, 0);
 }
 
-static inline void http_globals_free(zend_http_globals *G)
+#define http_globals_free(g) _http_globals_free((g) TSRMLS_CC)
+static inline void _http_globals_free(zend_http_globals *G TSRMLS_DC)
 {
        STR_SET(G->send.content_type, NULL);
        STR_SET(G->send.unquoted_etag, NULL);
@@ -207,6 +211,12 @@ PHP_INI_BEGIN()
        HTTP_PHP_INI_ENTRY("http.only_exceptions", "0", PHP_INI_ALL, OnUpdateBool, only_exceptions)
 #endif
        HTTP_PHP_INI_ENTRY("http.force_exit", "1", PHP_INI_ALL, OnUpdateBool, force_exit)
+#ifdef HTTP_HAVE_ZLIB
+       HTTP_PHP_INI_ENTRY("http.ob_inflate_auto", "0", PHP_INI_PERDIR, OnUpdateBool, send.inflate.start_auto)
+       HTTP_PHP_INI_ENTRY("http.ob_inflate_flags", "0", PHP_INI_ALL, OnUpdateLong, send.inflate.start_flags)
+       HTTP_PHP_INI_ENTRY("http.ob_deflate_auto", "0", PHP_INI_PERDIR, OnUpdateBool, send.deflate.start_auto)
+       HTTP_PHP_INI_ENTRY("http.ob_deflate_flags", "0", PHP_INI_ALL, OnUpdateLong, send.deflate.start_flags)
+#endif
 PHP_INI_END()
 /* }}} */
 
@@ -271,6 +281,13 @@ PHP_RINIT_FUNCTION(http)
        }
 
        http_globals_init(HTTP_GLOBALS);
+
+#ifdef HTTP_HAVE_ZLIB  
+       if (SUCCESS != PHP_RINIT_CALL(http_encoding)) {
+               return FAILURE;
+       }
+#endif
+       
        return SUCCESS;
 }
 /* }}} */
@@ -280,9 +297,16 @@ PHP_RSHUTDOWN_FUNCTION(http)
 {
        STATUS status = SUCCESS;
        
+       if (
+#ifdef HTTP_HAVE_ZLIB
+               (SUCCESS != PHP_RSHUTDOWN_CALL(http_encoding)) ||
+#endif
 #if defined(ZEND_ENGINE_2) && defined(HTTP_HAVE_CURL)
-       status = PHP_RSHUTDOWN_CALL(http_request_method);
+               (SUCCESS != PHP_RSHUTDOWN_CALL(http_request_method)) ||
 #endif
+       0) {
+               status = FAILURE;
+       }
        
        http_globals_free(HTTP_GLOBALS);
        return status;
index a5ecb12..07cb9f4 100644 (file)
@@ -29,8 +29,6 @@
 #      include "php_http_exception_object.h"
 #endif
 
-ZEND_EXTERN_MODULE_GLOBALS(http);
-
 PHP_MINIT_FUNCTION(http_support)
 {
        HTTP_LONG_CONSTANT("HTTP_SUPPORT", HTTP_SUPPORT);
index f8d1bf0..98cd072 100644 (file)
@@ -27,8 +27,6 @@
 #include "php_http_date_api.h"
 #include "php_http_send_api.h"
 
-ZEND_EXTERN_MODULE_GLOBALS(http);
-
 /* {{{ char *http_etag(void *, size_t, http_send_mode) */
 PHP_HTTP_API char *_http_etag(const void *data_ptr, size_t data_len, http_send_mode data_mode TSRMLS_DC)
 {
index 02f619c..16b5661 100644 (file)
@@ -20,8 +20,6 @@
 #include "php_http_api.h"
 #include "php_http_date_api.h"
 
-ZEND_EXTERN_MODULE_GLOBALS(http);
-
 static inline int check_day(const char *day, size_t len);
 static inline int check_month(const char *month);
 static inline int check_tzone(const char *tzone);
index d1b16c4..f896be4 100644 (file)
@@ -24,8 +24,6 @@
 #include "php_http_send_api.h"
 #include "php_http_headers_api.h"
 
-ZEND_EXTERN_MODULE_GLOBALS(http);
-
 #ifdef HTTP_HAVE_ZLIB
 PHP_MINIT_FUNCTION(http_encoding)
 {
@@ -42,6 +40,28 @@ PHP_MINIT_FUNCTION(http_encoding)
        HTTP_LONG_CONSTANT("HTTP_DEFLATE_STRATEGY_FIXED", HTTP_DEFLATE_STRATEGY_FIXED);
        return SUCCESS;
 }
+
+PHP_RINIT_FUNCTION(http_encoding)
+{
+       if (HTTP_G(send).inflate.start_auto) {
+               php_ob_set_internal_handler(_http_ob_inflatehandler, 0x1000, "http inflate", 0 TSRMLS_CC);
+       }
+       if (HTTP_G(send).deflate.start_auto) {
+               php_ob_set_internal_handler(_http_ob_deflatehandler, 0x8000, "http deflate", 0 TSRMLS_CC);
+       }
+       return SUCCESS;
+}
+
+PHP_RSHUTDOWN_FUNCTION(http_encoding)
+{
+       if (G->send.deflate.stream) {
+               http_encoding_deflate_stream_free((http_encoding_stream **) &G->send.deflate.stream);
+       }
+       if (G->send.inflate.stream) {
+               http_encoding_inflate_stream_free((http_encoding_stream **) &G->send.inflate.stream);
+       }
+       return SUCCESS;
+}
 #endif
 
 static inline int eol_match(char **line, int *eol_len)
@@ -193,7 +213,7 @@ PHP_HTTP_API const char *_http_encoding_dechunk(const char *encoded, size_t enco
 #define HTTP_WINDOW_BITS_ANY   0x0000002f
 #define HTTP_WINDOW_BITS_RAW   -0x000000f
 
-PHP_HTTP_API STATUS _http_encoding_deflate(int flags, const char *data, size_t data_len, char **encoded, size_t *encoded_len TSRMLS_DC)
+PHP_HTTP_API STATUS _http_encoding_deflate(int flags, const char *data, size_t data_len, char **encoded, size_t *encoded_len ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC TSRMLS_DC)
 {
        int status, level, wbits, strategy;
        z_stream Z;
@@ -209,7 +229,7 @@ PHP_HTTP_API STATUS _http_encoding_deflate(int flags, const char *data, size_t d
        status = deflateInit2(&Z, level, Z_DEFLATED, wbits, MAX_MEM_LEVEL, strategy);
        if (Z_OK == status) {
                *encoded_len = HTTP_ENCODING_BUFLEN(data_len);
-               *encoded = emalloc(*encoded_len);
+               *encoded = emalloc_rel(*encoded_len);
                
                Z.next_in = (Bytef *) data;
                Z.next_out = (Bytef *) *encoded;
@@ -221,7 +241,7 @@ PHP_HTTP_API STATUS _http_encoding_deflate(int flags, const char *data, size_t d
                
                if (Z_STREAM_END == status) {
                        /* size buffer down to actual length */
-                       *encoded = erealloc(*encoded, Z.total_out + 1);
+                       *encoded = erealloc_rel(*encoded, Z.total_out + 1);
                        (*encoded)[*encoded_len = Z.total_out] = '\0';
                        return SUCCESS;
                } else {
@@ -234,7 +254,7 @@ PHP_HTTP_API STATUS _http_encoding_deflate(int flags, const char *data, size_t d
        return FAILURE;
 }
 
-PHP_HTTP_API STATUS _http_encoding_inflate(const char *data, size_t data_len, char **decoded, size_t *decoded_len TSRMLS_DC)
+PHP_HTTP_API STATUS _http_encoding_inflate(const char *data, size_t data_len, char **decoded, size_t *decoded_len ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC TSRMLS_DC)
 {
        int status, max = 0, wbits = HTTP_WINDOW_BITS_ANY;
        z_stream Z;
@@ -274,7 +294,7 @@ retry_inflate:
                
                if (Z_STREAM_END == status) {
                        *decoded_len = Z.total_out;
-                       *decoded = erealloc(buffer.data, *decoded_len + 1);
+                       *decoded = erealloc_rel(buffer.data, *decoded_len + 1);
                        (*decoded)[*decoded_len] = '\0';
                        return SUCCESS;
                } else {
@@ -287,12 +307,12 @@ retry_inflate:
 }
 
 
-PHP_HTTP_API http_encoding_stream *_http_encoding_deflate_stream_init(http_encoding_stream *s, int flags TSRMLS_DC)
+PHP_HTTP_API http_encoding_stream *_http_encoding_deflate_stream_init(http_encoding_stream *s, int flags ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC TSRMLS_DC)
 {
        int status, level, wbits, strategy, free_stream;
        
        if ((free_stream = !s)) {
-               s = pemalloc(sizeof(http_encoding_stream), (flags & HTTP_ENCODING_STREAM_PERSISTENT));
+               s = pemalloc_rel(sizeof(http_encoding_stream), (flags & HTTP_ENCODING_STREAM_PERSISTENT));
        }
        memset(s, 0, sizeof(http_encoding_stream));
        s->flags = flags;
@@ -318,12 +338,12 @@ PHP_HTTP_API http_encoding_stream *_http_encoding_deflate_stream_init(http_encod
        return NULL;
 }
 
-PHP_HTTP_API http_encoding_stream *_http_encoding_inflate_stream_init(http_encoding_stream *s, int flags TSRMLS_DC)
+PHP_HTTP_API http_encoding_stream *_http_encoding_inflate_stream_init(http_encoding_stream *s, int flags ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC TSRMLS_DC)
 {
        int status, wbits, free_stream;
        
        if ((free_stream = !s)) {
-               s = emalloc(sizeof(http_encoding_stream));
+               s = pemalloc_rel(sizeof(http_encoding_stream), (flags & HTTP_ENCODING_STREAM_PERSISTENT));
        }
        memset(s, 0, sizeof(http_encoding_stream));
        s->flags = flags;
@@ -347,7 +367,7 @@ PHP_HTTP_API http_encoding_stream *_http_encoding_inflate_stream_init(http_encod
        return NULL;
 }
 
-PHP_HTTP_API STATUS _http_encoding_deflate_stream_update(http_encoding_stream *s, const char *data, size_t data_len, char **encoded, size_t *encoded_len TSRMLS_DC)
+PHP_HTTP_API STATUS _http_encoding_deflate_stream_update(http_encoding_stream *s, const char *data, size_t data_len, char **encoded, size_t *encoded_len ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC TSRMLS_DC)
 {
        int status;
        
@@ -359,7 +379,7 @@ PHP_HTTP_API STATUS _http_encoding_deflate_stream_update(http_encoding_stream *s
        
        /* deflate */
        *encoded_len = HTTP_ENCODING_BUFLEN(data_len);
-       *encoded = emalloc(*encoded_len);
+       *encoded = emalloc_rel(*encoded_len);
        s->stream.avail_out = *encoded_len;
        s->stream.next_out = (Bytef *) *encoded;
        
@@ -372,7 +392,7 @@ PHP_HTTP_API STATUS _http_encoding_deflate_stream_update(http_encoding_stream *s
                        
                        /* size buffer down to actual size */
                        *encoded_len -= s->stream.avail_out;
-                       *encoded = erealloc(*encoded, *encoded_len + 1);
+                       *encoded = erealloc_rel(*encoded, *encoded_len + 1);
                        (*encoded)[*encoded_len] = '\0';
                        return SUCCESS;
                break;
@@ -384,7 +404,7 @@ PHP_HTTP_API STATUS _http_encoding_deflate_stream_update(http_encoding_stream *s
        return FAILURE;
 }
 
-PHP_HTTP_API STATUS _http_encoding_inflate_stream_update(http_encoding_stream *s, const char *data, size_t data_len, char **decoded, size_t *decoded_len TSRMLS_DC)
+PHP_HTTP_API STATUS _http_encoding_inflate_stream_update(http_encoding_stream *s, const char *data, size_t data_len, char **decoded, size_t *decoded_len ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC TSRMLS_DC)
 {
        int status, max = 0;
        
@@ -398,7 +418,7 @@ PHP_HTTP_API STATUS _http_encoding_inflate_stream_update(http_encoding_stream *s
        /* inflate */
        do {
                *decoded_len <<= 1;
-               *decoded = erealloc(*decoded, *decoded_len);
+               *decoded = erealloc_rel(*decoded, *decoded_len);
                
 retry_raw_inflate:
                s->stream.next_in = (Bytef *) PHPSTR_VAL(s->stream.opaque);
@@ -416,7 +436,7 @@ retry_raw_inflate:
                                
                                /* size down */
                                *decoded_len -= s->stream.avail_out;
-                               *decoded = erealloc(*decoded, *decoded_len + 1);
+                               *decoded = erealloc_rel(*decoded, *decoded_len + 1);
                                (*decoded)[*decoded_len] = '\0';
                                return SUCCESS;
                        break;
@@ -439,12 +459,12 @@ retry_raw_inflate:
        return FAILURE;
 }
 
-PHP_HTTP_API STATUS _http_encoding_deflate_stream_flush(http_encoding_stream *s, char **encoded, size_t *encoded_len TSRMLS_DC)
+PHP_HTTP_API STATUS _http_encoding_deflate_stream_flush(http_encoding_stream *s, char **encoded, size_t *encoded_len ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC TSRMLS_DC)
 {
        int status;
        
        *encoded_len = 0x800;
-       *encoded = emalloc(*encoded_len);
+       *encoded = emalloc_rel(*encoded_len);
        
        s->stream.avail_in = 0;
        s->stream.next_in = NULL;
@@ -456,7 +476,7 @@ PHP_HTTP_API STATUS _http_encoding_deflate_stream_flush(http_encoding_stream *s,
                case Z_OK:
                case Z_STREAM_END:
                        *encoded_len = 0x800 - s->stream.avail_out;
-                       *encoded = erealloc(*encoded, *encoded_len + 1);
+                       *encoded = erealloc_rel(*encoded, *encoded_len + 1);
                        (*encoded)[*encoded_len] = '\0';
                        return SUCCESS;
                break;
@@ -468,12 +488,12 @@ PHP_HTTP_API STATUS _http_encoding_deflate_stream_flush(http_encoding_stream *s,
        return FAILURE;
 }
 
-PHP_HTTP_API STATUS _http_encoding_inflate_stream_flush(http_encoding_stream *s, char **decoded, size_t *decoded_len TSRMLS_DC)
+PHP_HTTP_API STATUS _http_encoding_inflate_stream_flush(http_encoding_stream *s, char **decoded, size_t *decoded_len ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC TSRMLS_DC)
 {
        int status;
        
        *decoded_len = 0x800;
-       *decoded = emalloc(*decoded_len);
+       *decoded = emalloc_rel(*decoded_len);
        
        s->stream.avail_in = 0;
        s->stream.next_in = NULL;
@@ -485,7 +505,7 @@ PHP_HTTP_API STATUS _http_encoding_inflate_stream_flush(http_encoding_stream *s,
                case Z_OK:
                case Z_STREAM_END:
                        *decoded_len = 0x800 - s->stream.avail_out;
-                       *decoded = erealloc(*decoded, *decoded_len + 1);
+                       *decoded = erealloc_rel(*decoded, *decoded_len + 1);
                        (*decoded)[*decoded_len] = '\0';
                        return SUCCESS;
                break;
@@ -497,12 +517,12 @@ PHP_HTTP_API STATUS _http_encoding_inflate_stream_flush(http_encoding_stream *s,
        return FAILURE;
 }
 
-PHP_HTTP_API STATUS _http_encoding_deflate_stream_finish(http_encoding_stream *s, char **encoded, size_t *encoded_len TSRMLS_DC)
+PHP_HTTP_API STATUS _http_encoding_deflate_stream_finish(http_encoding_stream *s, char **encoded, size_t *encoded_len ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC TSRMLS_DC)
 {
        int status;
        
        *encoded_len = 0x800;
-       *encoded = emalloc(*encoded_len);
+       *encoded = emalloc_rel(*encoded_len);
        
        /* deflate remaining input */
        s->stream.next_in = (Bytef *) PHPSTR_VAL(s->stream.opaque);
@@ -521,7 +541,7 @@ PHP_HTTP_API STATUS _http_encoding_deflate_stream_finish(http_encoding_stream *s
                
                /* size down */
                *encoded_len -= s->stream.avail_out;
-               *encoded = erealloc(*encoded, *encoded_len + 1);
+               *encoded = erealloc_rel(*encoded, *encoded_len + 1);
                (*encoded)[*encoded_len] = '\0';
                return SUCCESS;
        }
@@ -532,12 +552,12 @@ PHP_HTTP_API STATUS _http_encoding_deflate_stream_finish(http_encoding_stream *s
        return FAILURE;
 }
 
-PHP_HTTP_API STATUS _http_encoding_inflate_stream_finish(http_encoding_stream *s, char **decoded, size_t *decoded_len TSRMLS_DC)
+PHP_HTTP_API STATUS _http_encoding_inflate_stream_finish(http_encoding_stream *s, char **decoded, size_t *decoded_len ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC TSRMLS_DC)
 {
        int status;
        
        *decoded_len = s->stream.avail_in << 2;
-       *decoded = emalloc(*decoded_len);
+       *decoded = emalloc_rel(*decoded_len);
        
        /* inflate remaining input */
        s->stream.next_in = (Bytef *) PHPSTR_VAL(s->stream.opaque);
@@ -552,7 +572,7 @@ PHP_HTTP_API STATUS _http_encoding_inflate_stream_finish(http_encoding_stream *s
                
                /* size down */
                *decoded_len -= s->stream.avail_out;
-               *decoded = erealloc(*decoded, *decoded_len + 1);
+               *decoded = erealloc_rel(*decoded, *decoded_len + 1);
                (*decoded)[*decoded_len] = '\0';
                return SUCCESS;
        }
@@ -605,6 +625,100 @@ PHP_HTTP_API void _http_encoding_inflate_stream_free(http_encoding_stream **s TS
        }
 }
 
+void _http_ob_deflatehandler(char *output, uint output_len, char **handled_output, uint *handled_output_len, int mode TSRMLS_DC)
+{
+       getGlobals(G);
+       
+       *handled_output = NULL;
+       *handled_output_len = 0;
+       
+       if (mode & PHP_OUTPUT_HANDLER_START) {
+               int flags;
+               
+               if (G->send.deflate.stream) {
+                       zend_error(E_ERROR, "ob_deflatehandler() can only be used once");
+                       return;
+               }
+               
+               G->send.deflate.encoding = !0;
+               
+               switch (http_encoding_response_start(0))
+               {
+                       case HTTP_ENCODING_GZIP:
+                               flags = HTTP_DEFLATE_TYPE_GZIP;
+                       break;
+                       
+                       case HTTP_ENCODING_DEFLATE:
+                               flags = HTTP_DEFLATE_TYPE_ZLIB;
+                       break;
+                       
+                       default:
+                               goto deflate_passthru_plain;
+                       break;
+               }
+               
+               flags |= (G->send.deflate.start_flags &~ 0xf);
+               G->send.deflate.stream = http_encoding_deflate_stream_init(NULL, flags);
+       }
+       
+       if (G->send.deflate.stream) {
+               http_encoding_deflate_stream_update((http_encoding_stream *) G->send.deflate.stream, output, output_len, handled_output, handled_output_len);
+               
+               if (mode & PHP_OUTPUT_HANDLER_END) {
+                       char *remaining = NULL;
+                       size_t remaining_len = 0;
+                       
+                       http_encoding_deflate_stream_finish((http_encoding_stream *) G->send.deflate.stream, &remaining, &remaining_len);
+                       http_encoding_deflate_stream_free((http_encoding_stream **) &G->send.deflate.stream);
+                       if (remaining) {
+                               *handled_output = erealloc(*handled_output, *handled_output_len + remaining_len + 1);
+                               memcpy(*handled_output + *handled_output_len, remaining, remaining_len);
+                               (*handled_output)[*handled_output_len += remaining_len] = '\0';
+                               efree(remaining);
+                       }
+               }
+       } else {
+deflate_passthru_plain:
+               *handled_output = estrndup(output, *handled_output_len = output_len);
+       }
+}
+
+void _http_ob_inflatehandler(char *output, uint output_len, char **handled_output, uint *handled_output_len, int mode TSRMLS_DC)
+{
+       getGlobals(G);
+       
+       *handled_output = NULL;
+       *handled_output_len = 0;
+       
+       if (mode & PHP_OUTPUT_HANDLER_START) {
+               if (G->send.inflate.stream) {
+                       zend_error(E_ERROR, "ob_inflatehandler() can only be used once");
+                       return;
+               }
+               G->send.inflate.stream = http_encoding_inflate_stream_init(NULL, (HTTP_G(send).inflate.start_flags &~ 0xf));
+       }
+       
+       if (G->send.inflate.stream) {
+               http_encoding_inflate_stream_update((http_encoding_stream *) G->send.inflate.stream, output, output_len, handled_output, handled_output_len);
+               
+               if (mode & PHP_OUTPUT_HANDLER_END) {
+                       char *remaining = NULL;
+                       size_t remaining_len = 0;
+                       
+                       http_encoding_inflate_stream_finish((http_encoding_stream *) G->send.inflate.stream, &remaining, &remaining_len);
+                       http_encoding_inflate_stream_free((http_encoding_stream **) &G->send.inflate.stream);
+                       if (remaining) {
+                               *handled_output = erealloc(*handled_output, *handled_output_len + remaining_len + 1);
+                               memcpy(*handled_output + *handled_output_len, remaining, remaining_len);
+                               (*handled_output)[*handled_output_len += remaining_len] = '\0';
+                               efree(remaining);
+                       }
+               }
+       } else {
+               *handled_output = estrndup(output, *handled_output_len = output_len);
+       }
+}
+
 static const char http_encoding_gzip_header[] = {
        (const char) 0x1f,                      // fixed value
        (const char) 0x8b,                      // fixed value
@@ -733,13 +847,13 @@ PHP_HTTP_API STATUS _http_encoding_gzdecode_verify(const char *data, size_t data
 
 #endif /* HTTP_HAVE_ZLIB */
 
-PHP_HTTP_API zend_bool _http_encoding_response_start(size_t content_length TSRMLS_DC)
+PHP_HTTP_API int _http_encoding_response_start(size_t content_length TSRMLS_DC)
 {
        if (    php_ob_handler_used("ob_gzhandler" TSRMLS_CC) ||
                        php_ob_handler_used("zlib output compression" TSRMLS_CC)) {
-               HTTP_G(send).gzip_encoding = 0;
+               HTTP_G(send).deflate.encoding = 0;
        } else {
-               if (!HTTP_G(send).gzip_encoding) {
+               if (!HTTP_G(send).deflate.encoding) {
                        /* emit a content-length header */
                        if (content_length) {
                                char cl_header_str[128];
@@ -749,7 +863,7 @@ PHP_HTTP_API zend_bool _http_encoding_response_start(size_t content_length TSRML
                        }
                } else {
 #ifndef HTTP_HAVE_ZLIB
-                       HTTP_G(send).gzip_encoding = 0;
+                       HTTP_G(send).deflate.encoding = 0;
                        php_start_ob_buffer_named("ob_gzhandler", 0, 0 TSRMLS_CC);
 #else
                        HashTable *selected;
@@ -761,7 +875,7 @@ PHP_HTTP_API zend_bool _http_encoding_response_start(size_t content_length TSRML
                        add_next_index_stringl(&zsupported, "x-gzip", lenof("x-gzip"), 1);
                        add_next_index_stringl(&zsupported, "deflate", lenof("deflate"), 1);
                        
-                       HTTP_G(send).gzip_encoding = 0;
+                       HTTP_G(send).deflate.encoding = 0;
                        
                        if ((selected = http_negotiate_encoding(&zsupported))) {
                                STATUS hs = FAILURE;
@@ -771,11 +885,11 @@ PHP_HTTP_API zend_bool _http_encoding_response_start(size_t content_length TSRML
                                if (HASH_KEY_IS_STRING == zend_hash_get_current_key(selected, &encoding, &idx, 0) && encoding) {
                                        if (!strcmp(encoding, "gzip") || !strcmp(encoding, "x-gzip")) {
                                                if (SUCCESS == (hs = http_send_header_string("Content-Encoding: gzip"))) {
-                                                       HTTP_G(send).gzip_encoding = HTTP_ENCODING_GZIP;
+                                                       HTTP_G(send).deflate.encoding = HTTP_ENCODING_GZIP;
                                                }
                                        } else if (!strcmp(encoding, "deflate")) {
                                                if (SUCCESS == (hs = http_send_header_string("Content-Encoding: deflate"))) {
-                                                       HTTP_G(send).gzip_encoding = HTTP_ENCODING_DEFLATE;
+                                                       HTTP_G(send).deflate.encoding = HTTP_ENCODING_DEFLATE;
                                                }
                                        }
                                        if (SUCCESS == hs) {
@@ -788,7 +902,7 @@ PHP_HTTP_API zend_bool _http_encoding_response_start(size_t content_length TSRML
                        }
                        
                        zval_dtor(&zsupported);
-                       return HTTP_G(send).gzip_encoding;
+                       return HTTP_G(send).deflate.encoding;
 #endif
                }
        }
index 39327d1..41afd28 100644 (file)
@@ -41,8 +41,6 @@
 #include "php_http_send_api.h"
 #include "php_http_url_api.h"
 
-ZEND_EXTERN_MODULE_GLOBALS(http)
-
 /* {{{ proto string http_date([int timestamp])
  *
  * Compose a valid HTTP date regarding RFC 822/1123
@@ -1596,13 +1594,11 @@ PHP_FUNCTION(http_deflate)
        RETVAL_NULL();
        
        if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &data, &data_len, &flags)) {
-               {
-                       char *encoded;
-                       size_t encoded_len;
-                       
-                       if (SUCCESS == http_encoding_deflate(flags, data, data_len, &encoded, &encoded_len)) {
-                               RETURN_STRINGL(encoded, (int) encoded_len, 0);
-                       }
+               char *encoded;
+               size_t encoded_len;
+               
+               if (SUCCESS == http_encoding_deflate(flags, data, data_len, &encoded, &encoded_len)) {
+                       RETURN_STRINGL(encoded, (int) encoded_len, 0);
                }
        }
 }
@@ -1635,6 +1631,47 @@ PHP_FUNCTION(http_inflate)
 }
 /* }}} */
 
+/* {{{ proto string ob_deflatehandler(string data, int mode)
+ *
+ * For use with ob_start(). The deflate output buffer handler can only be used once.
+ * It conflicts with ob_gzhanlder and zlib.output_compression as well and should
+ * not be used after ext/mbstrings mb_output_handler and ext/sessions URL-Rewriter (AKA
+ * session.use_trans_sid).
+ */
+PHP_FUNCTION(ob_deflatehandler)
+{
+       char *data;
+       int data_len;
+       long mode;
+
+       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", &data, &data_len, &mode)) {
+               RETURN_FALSE;
+       }
+
+       http_ob_deflatehandler(data, data_len, &Z_STRVAL_P(return_value), (uint *) &Z_STRLEN_P(return_value), mode);
+       Z_TYPE_P(return_value) = Z_STRVAL_P(return_value) ? IS_STRING : IS_NULL;
+}
+/* }}} */
+
+/* {{{ proto string ob_inflatehandler(string data, int mode)
+ *
+ * For use with ob_start().  Same restrictions as with ob_deflatehandler apply.
+ */
+PHP_FUNCTION(ob_inflatehandler)
+{
+       char *data;
+       int data_len;
+       long mode;
+       
+       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", &data, &data_len, &mode)) {
+               RETURN_FALSE;
+       }
+       
+       http_ob_inflatehandler(data, data_len, &Z_STRVAL_P(return_value), (uint *) &Z_STRLEN_P(return_value), mode);
+       Z_TYPE_P(return_value) = Z_STRVAL_P(return_value) ? IS_STRING : IS_NULL;
+}
+/* }}} */
+
 #endif /* HTTP_HAVE_ZLIB */
 /* }}} */
 
index 444c8de..12be14f 100644 (file)
@@ -24,8 +24,6 @@
 #include "php_http_api.h"
 #include "php_http_headers_api.h"
 
-ZEND_EXTERN_MODULE_GLOBALS(http);
-
 #ifndef HTTP_DBG_NEG
 #      define HTTP_DBG_NEG 0
 #endif
index c544ccb..b1ffcbc 100644 (file)
@@ -21,8 +21,6 @@
 #include "php_http_api.h"
 #include "php_http_info_api.h"
 
-ZEND_EXTERN_MODULE_GLOBALS(http);
-
 PHP_HTTP_API void _http_info_default_callback(void **nothing, HashTable **headers, http_info *info TSRMLS_DC)
 {
        zval array;
index e162648..5f51701 100644 (file)
@@ -30,8 +30,6 @@
 #include "php_http_send_api.h"
 #include "php_http_url_api.h"
 
-ZEND_EXTERN_MODULE_GLOBALS(http);
-
 #define http_message_info_callback _http_message_info_callback
 static void _http_message_info_callback(http_message **message, HashTable **headers, http_info *info TSRMLS_DC)
 {
index b84bdfb..fa82822 100644 (file)
@@ -34,8 +34,6 @@ extern PHPAPI zend_class_entry *spl_ce_Countable;
 #      endif
 #endif
 
-ZEND_EXTERN_MODULE_GLOBALS(http);
-
 #define HTTP_BEGIN_ARGS(method, ret_ref, req_args)     HTTP_BEGIN_ARGS_EX(HttpMessage, method, ret_ref, req_args)
 #define HTTP_EMPTY_ARGS(method, ret_ref)                       HTTP_EMPTY_ARGS_EX(HttpMessage, method, ret_ref)
 #define HTTP_MESSAGE_ME(method, visibility)                    PHP_ME(HttpMessage, method, HTTP_ARGS(HttpMessage, method), visibility)
index 6090bc1..f6ee54e 100644 (file)
@@ -29,8 +29,6 @@
 #      include "php_http_request_object.h"
 #endif
 
-ZEND_EXTERN_MODULE_GLOBALS(http);
-
 /* {{{ cruft for thread safe SSL crypto locks */
 #if defined(ZTS) && defined(HTTP_HAVE_SSL)
 #      ifdef PHP_WIN32
index 75b3c45..8476b63 100644 (file)
@@ -25,8 +25,6 @@
 #include "php_http_url_api.h"
 #include "php_http_request_body_api.h"
 
-ZEND_EXTERN_MODULE_GLOBALS(http);
-
 /* {{{ http_request_body *http_request_body_new() */
 PHP_HTTP_API http_request_body *_http_request_body_init_ex(http_request_body *body, int type, void *data, size_t size, zend_bool free ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC TSRMLS_DC)
 {
index 9e5c79a..ead74ac 100644 (file)
@@ -27,8 +27,6 @@
 #      include "php_http_request_object.h"
 #endif
 
-ZEND_EXTERN_MODULE_GLOBALS(http);
-
 /* {{{ char *http_request_methods[] */
 static const char *const http_request_methods[] = {
        "UNKNOWN",
index a3b132e..8ff7b25 100644 (file)
@@ -32,8 +32,6 @@
 #include "php_http_request_pool_api.h"
 #include "php_http_url_api.h"
 
-ZEND_EXTERN_MODULE_GLOBALS(http);
-
 #define HTTP_BEGIN_ARGS(method, ret_ref, req_args)     HTTP_BEGIN_ARGS_EX(HttpRequest, method, ret_ref, req_args)
 #define HTTP_EMPTY_ARGS(method, ret_ref)                       HTTP_EMPTY_ARGS_EX(HttpRequest, method, ret_ref)
 #define HTTP_REQUEST_ME(method, visibility)                    PHP_ME(HttpRequest, method, HTTP_ARGS(HttpRequest, method), visibility)
index 3063330..83c5c59 100644 (file)
@@ -32,8 +32,6 @@
 #      define HTTP_DEBUG_REQPOOLS 0
 #endif
 
-ZEND_EXTERN_MODULE_GLOBALS(http);
-
 #ifndef HAVE_CURL_MULTI_STRERROR
 #      define curl_multi_strerror(dummy) "unknown error"
 #endif
index 5d46fa5..4cbba72 100644 (file)
@@ -33,9 +33,6 @@
 #include "php_http_response_object.h"
 #include "php_http_send_api.h"
 
-
-ZEND_EXTERN_MODULE_GLOBALS(http);
-
 #define GET_STATIC_PROP(n)                     *GET_STATIC_PROP_EX(http_response_object_ce, n)
 #define UPD_STATIC_PROP(t, n, v)       UPD_STATIC_PROP_EX(http_response_object_ce, t, n, v)
 #define SET_STATIC_PROP(n, v)          SET_STATIC_PROP_EX(http_response_object_ce, n, v)
@@ -1158,7 +1155,7 @@ PHP_METHOD(HttpResponse, send)
        }
 
        /* gzip */
-       HTTP_G(send).gzip_encoding = zval_is_true(GET_STATIC_PROP(gzip));
+       HTTP_G(send).deflate.encoding = zval_is_true(GET_STATIC_PROP(gzip));
        
        /* start ob */
        php_start_ob_buffer(NULL, HTTP_G(send).buffer_size, 0 TSRMLS_CC);
index 3b7a74a..103dc95 100644 (file)
@@ -31,8 +31,6 @@
 #include "php_http_headers_api.h"
 #include "php_http_send_api.h"
 
-ZEND_EXTERN_MODULE_GLOBALS(http);
-
 #define http_flush(d, l) _http_flush((d), (l) TSRMLS_CC)
 /* {{{ static inline void http_flush() */
 static inline void _http_flush(const char *data, size_t data_len TSRMLS_DC)
@@ -74,7 +72,6 @@ static inline void _http_send_response_start(void **buffer, size_t content_lengt
        int encoding;
        
        if ((encoding = http_encoding_response_start(content_length))) {
-       //DebugBreak();
 #ifdef HTTP_HAVE_ZLIB
                *buffer = http_encoding_deflate_stream_init(NULL, 
                        (encoding == HTTP_ENCODING_GZIP) ? 
@@ -88,7 +85,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).gzip_encoding) {
+       if (HTTP_G(send).deflate.encoding) {
 #ifdef HTTP_HAVE_ZLIB
                char *encoded;
                size_t encoded_len;
@@ -159,7 +156,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).gzip_encoding) {
+       if (HTTP_G(send).deflate.encoding) {
 #ifdef HTTP_HAVE_ZLIB
                char *encoded = NULL;
                size_t encoded_len = 0;
index 0720460..53faf95 100644 (file)
@@ -27,8 +27,6 @@
 #include "php_http_api.h"
 #include "php_http_url_api.h"
 
-ZEND_EXTERN_MODULE_GLOBALS(http);
-
 PHP_HTTP_API char *_http_absolute_url(const char *url TSRMLS_DC)
 {
        char *abs = estrdup(url);
index f74af3c..6586d06 100644 (file)
@@ -56,6 +56,8 @@ extern zend_module_entry http_module_entry;
 
 extern int http_module_number;
 
+ZEND_EXTERN_MODULE_GLOBALS(http);
+
 ZEND_BEGIN_MODULE_GLOBALS(http)
 
        struct _http_globals_etag {
@@ -77,7 +79,17 @@ ZEND_BEGIN_MODULE_GLOBALS(http)
                char *content_type;
                char *unquoted_etag;
                time_t last_modified;
-               int gzip_encoding;
+               struct _http_globals_send_deflate {
+                       zend_bool start_auto;
+                       long start_flags;
+                       int encoding;
+                       void *stream;
+               } deflate;
+               struct _http_globals_send_inflate {
+                       zend_bool start_auto;
+                       long start_flags;
+                       void *stream;
+               } inflate;
        } send;
 
        struct _http_globals_request {
@@ -150,6 +162,8 @@ PHP_FUNCTION(ob_etaghandler);
 #ifdef HTTP_HAVE_ZLIB
 PHP_FUNCTION(http_deflate);
 PHP_FUNCTION(http_inflate);
+PHP_FUNCTION(ob_deflatehandler);
+PHP_FUNCTION(ob_inflatehandler);
 #endif
 PHP_FUNCTION(http_support);
 
index 1a21ded..ee9e8f8 100644 (file)
@@ -30,8 +30,6 @@
 #      include "ext/hash/php_hash.h"
 #endif
 
-ZEND_EXTERN_MODULE_GLOBALS(http);
-
 #define http_etag_digest(d, l) _http_etag_digest((d), (l))
 static inline char *_http_etag_digest(const unsigned char *digest, int len)
 {
index a8a55bf..4c01360 100644 (file)
 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 zend_bool _http_encoding_response_start(size_t content_length TSRMLS_DC);
+PHP_HTTP_API int _http_encoding_response_start(size_t content_length TSRMLS_DC);
 
 #ifdef HTTP_HAVE_ZLIB
 
 extern PHP_MINIT_FUNCTION(http_encoding);
+extern PHP_RINIT_FUNCTION(http_encoding);
+extern PHP_RSHUTDOWN_FUNCTION(http_encoding);
 
 /* 100% compression should be fairly good */
 #define HTTP_ENCODING_MAXTRY 100
@@ -62,37 +64,42 @@ typedef struct {
        void *storage;
 } http_encoding_stream;
 
-#define http_encoding_deflate(f, d, dl, r, rl) _http_encoding_deflate((f), (d), (dl), (r), (rl) TSRMLS_CC)
-PHP_HTTP_API STATUS _http_encoding_deflate(int flags, const char *data, size_t data_len, char **encoded, size_t *encoded_len TSRMLS_DC);
-#define http_encoding_inflate(d, dl, r, rl) _http_encoding_inflate((d), (dl), (r), (rl) TSRMLS_CC)
-PHP_HTTP_API STATUS _http_encoding_inflate(const char *data, size_t data_len, char **decoded, size_t *decoded_len TSRMLS_DC);
-
-#define http_encoding_deflate_stream_init(s, f) _http_encoding_deflate_stream_init((s), (f) TSRMLS_CC)
-PHP_HTTP_API http_encoding_stream *_http_encoding_deflate_stream_init(http_encoding_stream *s, int flags TSRMLS_DC);
-#define http_encoding_deflate_stream_update(s, d, dl, e, el) _http_encoding_deflate_stream_update((s), (d), (dl), (e), (el) TSRMLS_CC)
-PHP_HTTP_API STATUS _http_encoding_deflate_stream_update(http_encoding_stream *s, const char *data, size_t data_len, char **encoded, size_t *encoded_len TSRMLS_DC);
-#define http_encoding_deflate_stream_flush(s, e, el) _http_encoding_deflate_stream_flush((s), (e), (el) TSRMLS_CC)
-PHP_HTTP_API STATUS _http_encoding_deflate_stream_flush(http_encoding_stream *s, char **encoded, size_t *encoded_len TSRMLS_DC);
-#define http_encoding_deflate_stream_finish(s, e, el) _http_encoding_deflate_stream_finish((s), (e), (el) TSRMLS_CC)
-PHP_HTTP_API STATUS _http_encoding_deflate_stream_finish(http_encoding_stream *s, char **encoded, size_t *encoded_len TSRMLS_DC);
+#define http_encoding_deflate(f, d, dl, r, rl) _http_encoding_deflate((f), (d), (dl), (r), (rl) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC TSRMLS_CC)
+PHP_HTTP_API STATUS _http_encoding_deflate(int flags, const char *data, size_t data_len, char **encoded, size_t *encoded_len ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC TSRMLS_DC);
+#define http_encoding_inflate(d, dl, r, rl) _http_encoding_inflate((d), (dl), (r), (rl) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC TSRMLS_CC)
+PHP_HTTP_API STATUS _http_encoding_inflate(const char *data, size_t data_len, char **decoded, size_t *decoded_len ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC TSRMLS_DC);
+
+#define http_encoding_deflate_stream_init(s, f) _http_encoding_deflate_stream_init((s), (f) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC TSRMLS_CC)
+PHP_HTTP_API http_encoding_stream *_http_encoding_deflate_stream_init(http_encoding_stream *s, int flags ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC TSRMLS_DC);
+#define http_encoding_deflate_stream_update(s, d, dl, e, el) _http_encoding_deflate_stream_update((s), (d), (dl), (e), (el) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC TSRMLS_CC)
+PHP_HTTP_API STATUS _http_encoding_deflate_stream_update(http_encoding_stream *s, const char *data, size_t data_len, char **encoded, size_t *encoded_len ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC TSRMLS_DC);
+#define http_encoding_deflate_stream_flush(s, e, el) _http_encoding_deflate_stream_flush((s), (e), (el) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC TSRMLS_CC)
+PHP_HTTP_API STATUS _http_encoding_deflate_stream_flush(http_encoding_stream *s, char **encoded, size_t *encoded_len ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC TSRMLS_DC);
+#define http_encoding_deflate_stream_finish(s, e, el) _http_encoding_deflate_stream_finish((s), (e), (el) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC TSRMLS_CC)
+PHP_HTTP_API STATUS _http_encoding_deflate_stream_finish(http_encoding_stream *s, char **encoded, size_t *encoded_len ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC TSRMLS_DC);
 #define http_encoding_deflate_stream_dtor(s) _http_encoding_deflate_stream_dtor((s) TSRMLS_CC)
 PHP_HTTP_API void _http_encoding_deflate_stream_dtor(http_encoding_stream *s TSRMLS_DC);
 #define http_encoding_deflate_stream_free(s) _http_encoding_deflate_stream_free((s) TSRMLS_CC)
 PHP_HTTP_API void _http_encoding_deflate_stream_free(http_encoding_stream **s TSRMLS_DC);
 
-#define http_encoding_inflate_stream_init(s, f) _http_encoding_inflate_stream_init((s), (f) TSRMLS_CC)
-PHP_HTTP_API http_encoding_stream *_http_encoding_inflate_stream_init(http_encoding_stream *s, int flags TSRMLS_DC);
-#define http_encoding_inflate_stream_update(s, d, dl, e, el) _http_encoding_inflate_stream_update((s), (d), (dl), (e), (el) TSRMLS_CC)
-PHP_HTTP_API STATUS _http_encoding_inflate_stream_update(http_encoding_stream *s, const char *data, size_t data_len, char **decoded, size_t *decoded_len TSRMLS_DC);
-#define http_encoding_inflate_stream_flush(s, d, dl) _http_encoding_inflate_stream_flush((s), (d), (dl) TSRMLS_CC)
-PHP_HTTP_API STATUS _http_encoding_inflate_stream_flush(http_encoding_stream *s, char **decoded, size_t *decoded_len TSRMLS_DC);
-#define http_encoding_inflate_stream_finish(s, e, el) _http_encoding_inflate_stream_finish((s), (e), (el) TSRMLS_CC)
-PHP_HTTP_API STATUS _http_encoding_inflate_stream_finish(http_encoding_stream *s, char **decoded, size_t *decoded_len TSRMLS_DC);
+#define http_encoding_inflate_stream_init(s, f) _http_encoding_inflate_stream_init((s), (f) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC TSRMLS_CC)
+PHP_HTTP_API http_encoding_stream *_http_encoding_inflate_stream_init(http_encoding_stream *s, int flags ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC TSRMLS_DC);
+#define http_encoding_inflate_stream_update(s, d, dl, e, el) _http_encoding_inflate_stream_update((s), (d), (dl), (e), (el) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC TSRMLS_CC)
+PHP_HTTP_API STATUS _http_encoding_inflate_stream_update(http_encoding_stream *s, const char *data, size_t data_len, char **decoded, size_t *decoded_len ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC TSRMLS_DC);
+#define http_encoding_inflate_stream_flush(s, d, dl) _http_encoding_inflate_stream_flush((s), (d), (dl) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC TSRMLS_CC)
+PHP_HTTP_API STATUS _http_encoding_inflate_stream_flush(http_encoding_stream *s, char **decoded, size_t *decoded_len ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC TSRMLS_DC);
+#define http_encoding_inflate_stream_finish(s, e, el) _http_encoding_inflate_stream_finish((s), (e), (el) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC TSRMLS_CC)
+PHP_HTTP_API STATUS _http_encoding_inflate_stream_finish(http_encoding_stream *s, char **decoded, size_t *decoded_len ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC TSRMLS_DC);
 #define http_encoding_inflate_stream_dtor(s) _http_encoding_inflate_stream_dtor((s) TSRMLS_CC)
 PHP_HTTP_API void _http_encoding_inflate_stream_dtor(http_encoding_stream *s TSRMLS_DC);
 #define http_encoding_inflate_stream_free(s) _http_encoding_inflate_stream_free((s) TSRMLS_CC)
 PHP_HTTP_API void _http_encoding_inflate_stream_free(http_encoding_stream **s TSRMLS_DC);
 
+#define http_ob_deflatehandler(o, ol, h, hl, m) _http_ob_deflatehandler((o), (ol), (h), (hl), (m) TSRMLS_CC)
+void _http_ob_deflatehandler(char *, uint, char **, uint *, int TSRMLS_DC);
+
+#define http_ob_inflatehandler(o, ol, h, hl, m) _http_ob_inflatehandler((o), (ol), (h), (hl), (m) TSRMLS_CC)
+void _http_ob_inflatehandler(char *, uint, char **, uint *, int TSRMLS_DC);
 #endif /* HTTP_HAVE_ZLIB */
 
 #endif
diff --git a/tests/ut_HttpResponse.phpt b/tests/ut_HttpResponse.phpt
deleted file mode 100644 (file)
index 7a95112..0000000
+++ /dev/null
@@ -1,170 +0,0 @@
---TEST--
-PHPUnit HttpResponse
---SKIPIF--
-<?php
-include 'skip.inc';
-checkcls('HttpResponse');
-skipif(!@include 'PHPUnit2/Framework/TestCase.php', 'need PHPUnit2');
-?>
---FILE--
-<?php
-echo "-TEST\n";
-
-error_reporting(E_ALL);
-ini_set('html_errors', 0);
-
-require_once 'PHPUnit2/Framework/TestSuite.php';
-require_once 'PHPUnit2/Framework/TestCase.php';
-require_once 'PHPUnit2/TextUI/ResultPrinter.php';
-
-class HttpResponseTest extends PHPUnit2_Framework_TestCase
-{
-    function test_setHeader()
-    {
-    }
-
-    function test_getHeader()
-    {
-    }
-
-    function test_setETag()
-    {
-    }
-
-    function test_getETag()
-    {
-    }
-
-    function test_setLastModified()
-    {
-    }
-
-    function test_getLastModified()
-    {
-    }
-
-    function test_setContentDisposition()
-    {
-    }
-
-    function test_getContentDisposition()
-    {
-    }
-
-    function test_setContentType()
-    {
-    }
-
-    function test_getContentType()
-    {
-    }
-
-    function test_guessContentType()
-    {
-    }
-
-    function test_setCache()
-    {
-    }
-
-    function test_getCache()
-    {
-    }
-
-    function test_setCacheControl()
-    {
-    }
-
-    function test_getCacheControl()
-    {
-    }
-
-    function test_setGzip()
-    {
-    }
-
-    function test_getGzip()
-    {
-    }
-
-    function test_setThrottleDelay()
-    {
-    }
-
-    function test_getThrottleDelay()
-    {
-    }
-
-    function test_setBufferSize()
-    {
-    }
-
-    function test_getBufferSize()
-    {
-    }
-
-    function test_setData()
-    {
-    }
-
-    function test_getData()
-    {
-    }
-
-    function test_setFile()
-    {
-    }
-
-    function test_getFile()
-    {
-    }
-
-    function test_setStream()
-    {
-    }
-
-    function test_getStream()
-    {
-    }
-
-    function test_send()
-    {
-    }
-
-    function test_capture()
-    {
-    }
-
-    function test_redirect()
-    {
-    }
-
-    function test_status()
-    {
-    }
-
-    function test_getRequestHeaders()
-    {
-    }
-
-    function test_getRequestBody()
-    {
-    }
-
-
-}
-
-$s = new PHPUnit2_Framework_TestSuite('HttpResponseTest');
-$p = new PHPUnit2_TextUI_ResultPrinter();
-$p->printResult($s->run(), 0);
-
-echo "Done\n";
-?>
---EXPECTF--
-%sTEST
-
-
-Time: 0
-
-OK (33 tests)
-Done
index 98a11e8..3c5f70a 100644 (file)
@@ -27,9 +27,9 @@ class HttpUtilTest extends PHPUnit2_Framework_TestCase
     function test_buildUrl()
     {
        $_SERVER['SERVER_NAME'] = 'www.example.com';
-       $this->assertEquals('http://www.example.com/test.php?foo=bar', HttpUtil::buildUrl('/test.php?foo=bar', null, null, 80));
-       $this->assertEquals('https://www.example.com/', HttpUtil::buildUrl('/', 'https'));
-       $this->assertEquals('ftp://ftp.example.com/pub', HttpUtil::buildUrl('/pub', null, 'ftp.example.com', 21));
+       $this->assertEquals('http://www.example.com/test.php?foo=bar', HttpUtil::buildUrl('/test.php?foo=bar', array('port' => 80)));
+       $this->assertEquals('https://www.example.com/', HttpUtil::buildUrl('/', array('scheme' => 'https')));
+       $this->assertEquals('ftp://ftp.example.com/pub', HttpUtil::buildUrl('/pub', array('host' => 'ftp.example.com', 'port' => 21)));
     }
 
     function test_negotiateLanguage()