/* }}} */
/* {{{ 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);
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;
/* {{{ 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;
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;
}
/* 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))) {
{
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) ?
#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;
#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;
<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>
</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="/">
#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"
char *unquoted_etag;
time_t last_modified;
struct _http_globals_send_deflate {
+ zend_bool response;
zend_bool start_auto;
long start_flags;
int encoding;
#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