cvs: php4 /ext/zlib zlib.c

From: Date: Mon, 13 Nov 2000 19:05:26 +0000
Subject: cvs: php4 /ext/zlib zlib.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-2590@lists.php.net to get a copy of this message
zeev Mon Nov 13 11:05:26 2000 EDT Modified files: /php4/ext/zlib zlib.c Log: Handle unable-to-add-new-headers error nicely Index: php4/ext/zlib/zlib.c diff -u php4/ext/zlib/zlib.c:1.65 php4/ext/zlib/zlib.c:1.66 --- php4/ext/zlib/zlib.c:1.65 Mon Nov 13 10:54:37 2000 +++ php4/ext/zlib/zlib.c Mon Nov 13 11:05:25 2000 @@ -16,7 +16,7 @@ | Stefan Röhrich <sr@linux.de> | +----------------------------------------------------------------------+ */ -/* $Id: zlib.c,v 1.65 2000/11/13 18:54:37 zeev Exp $ */ +/* $Id: zlib.c,v 1.66 2000/11/13 19:05:25 zeev Exp $ */ #define IS_EXT_MODULE #ifndef PHP_WIN32 @@ -1071,11 +1071,6 @@ return FAILURE; } - /* - sapi_add_header("Content-Encoding: gzip", sizeof("Content-Encoding: gzip") - 1, 1); - sapi_send_headers(); - */ - /* Write a very simple .gz header: */ sprintf(header_buffer, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1], Z_DEFLATED, 0 /*flags*/, @@ -1087,9 +1082,6 @@ /* TODO: print out error */ return FAILURE; } - /* - sapi_add_header("Content-Encoding: deflate", sizeof("Content-Encoding: deflate") - 1, 1); - */ break; } @@ -1167,6 +1159,7 @@ int coding; zval **zv_string; zval **data, **a_encoding; + zend_bool return_original=0; if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &zv_string)==FAILURE) { ZEND_WRONG_PARAM_COUNT(); @@ -1192,13 +1185,27 @@ Z_TYPE_P(return_value) = IS_STRING; switch (coding) { case CODING_GZIP: - sapi_add_header("Content-Encoding: gzip", sizeof("Content-Encoding: gzip") - 1, 1); + if (sapi_add_header("Content-Encoding: gzip", sizeof("Content-Encoding: gzip") - 1, 1)==FAILURE) { + return_original = 1; + } break; case CODING_DEFLATE: - sapi_add_header("Content-Encoding: deflate", sizeof("Content-Encoding: deflate") - 1, 1); + if (sapi_add_header("Content-Encoding: deflate", sizeof("Content-Encoding: deflate") - 1, 1)==FAILURE) { + return_original = 1; + } + break; + default: + return_original = 1; break; } + if (return_original) { + zval_dtor(return_value); + } } else { + return_original = 1; + } + + if (return_original) { /* return the original string */ *return_value = **zv_string; zval_copy_ctor(return_value);

« previous php.cvs (#2590) next »