From: Michael Wallner Date: Tue, 11 Oct 2005 10:25:37 +0000 (+0000) Subject: - fix memleak when http_get() etc intermit unexpectedly X-Git-Tag: RELEASE_0_15_0~5 X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=commitdiff_plain;h=eae9ca6014f5d2a20dab69407e80667bcb913ced - fix memleak when http_get() etc intermit unexpectedly - pass supported encodings if we've built with zlib --- diff --git a/http_functions.c b/http_functions.c index cbb487f..9bde4fb 100644 --- a/http_functions.c +++ b/http_functions.c @@ -1028,6 +1028,7 @@ PHP_FUNCTION(http_get) if (SUCCESS == http_get(URL, options ? Z_ARRVAL_P(options) : NULL, info ? Z_ARRVAL_P(info) : NULL, &response)) { RETURN_PHPSTR_VAL(&response); } else { + phpstr_dtor(&response); RETURN_FALSE; } } @@ -1061,6 +1062,7 @@ PHP_FUNCTION(http_head) if (SUCCESS == http_head(URL, options ? Z_ARRVAL_P(options) : NULL, info ? Z_ARRVAL_P(info) : NULL, &response)) { RETURN_PHPSTR_VAL(&response); } else { + phpstr_dtor(&response); RETURN_FALSE; } } @@ -1100,6 +1102,7 @@ PHP_FUNCTION(http_post_data) if (SUCCESS == http_post(URL, &body, options ? Z_ARRVAL_P(options) : NULL, info ? Z_ARRVAL_P(info) : NULL, &response)) { RETVAL_PHPSTR_VAL(&response); } else { + phpstr_dtor(&response); RETVAL_FALSE; } } @@ -1139,6 +1142,7 @@ PHP_FUNCTION(http_post_fields) if (SUCCESS == http_post(URL, &body, options ? Z_ARRVAL_P(options) : NULL, info ? Z_ARRVAL_P(info) : NULL, &response)) { RETVAL_PHPSTR_VAL(&response); } else { + phpstr_dtor(&response); RETVAL_FALSE; } http_request_body_dtor(&body); @@ -1189,6 +1193,7 @@ PHP_FUNCTION(http_put_file) if (SUCCESS == http_put(URL, &body, options ? Z_ARRVAL_P(options) : NULL, info ? Z_ARRVAL_P(info) : NULL, &response)) { RETVAL_PHPSTR_VAL(&response); } else { + phpstr_dtor(&response); RETVAL_FALSE; } http_request_body_dtor(&body); @@ -1237,6 +1242,7 @@ PHP_FUNCTION(http_put_stream) if (SUCCESS == http_put(URL, &body, options ? Z_ARRVAL_P(options) : NULL, info ? Z_ARRVAL_P(info) : NULL, &response)) { RETURN_PHPSTR_VAL(&response); } else { + phpstr_dtor(&response); RETURN_NULL(); } } diff --git a/http_request_api.c b/http_request_api.c index 56373d7..c7bdcb3 100644 --- a/http_request_api.c +++ b/http_request_api.c @@ -433,9 +433,13 @@ PHP_HTTP_API STATUS _http_request_init(CURL *ch, http_request_method meth, char } #endif - /* compress, empty string enables deflate and gzip */ + /* compress, empty string enables all supported if libcurl was build with zlib support */ if ((zoption = http_curl_getopt(options, "compress", IS_BOOL)) && Z_LVAL_P(zoption)) { +#ifdef HTTP_HAVE_ZLIB + HTTP_CURL_OPT(ENCODING, "gzip;q=1.0, deflate;q=0.5, *;q=0"); +#else HTTP_CURL_OPT(ENCODING, ""); +#endif } /* redirects, defaults to 0 */