summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierrick Charron <pierrick@php.net>2012-12-19 19:44:08 -0500
committerPierrick Charron <pierrick@php.net>2012-12-19 19:44:08 -0500
commit66b88c92bb7796b65f2f1da4b04ef91c0ce7a850 (patch)
tree111f2f27f4853236da0984f8f15c441c2c144d78
parent59692de77facceada2dd19167c4706c0c2a80ba2 (diff)
parentc46e1cdcae70254cfc0b7d5781f2c71162a3734d (diff)
downloadphp-git-66b88c92bb7796b65f2f1da4b04ef91c0ce7a850.tar.gz
Merge branch 'PHP-5.3' into PHP-5.4
* PHP-5.3: Fixed bug #55438 (Curlwapper is not sending http header randomly)
-rw-r--r--NEWS4
-rw-r--r--ext/curl/php_curl.h1
-rw-r--r--ext/curl/streams.c22
3 files changed, 14 insertions, 13 deletions
diff --git a/NEWS b/NEWS
index 2a8660e25d..81bc7a6838 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,10 @@ PHP NEWS
. Update list of common mime types. Added webm, ogv, ogg. (Lars,
pascalc at gmail dot com)
+- cURL extension:
+ . Fixed bug #55438 (Curlwapper is not sending http header randomly).
+ (phpnet@lostreality.org, Pierrick)
+
?? ??? 2012, PHP 5.4.10
- Core:
diff --git a/ext/curl/php_curl.h b/ext/curl/php_curl.h
index 05275455e7..af6a965c99 100644
--- a/ext/curl/php_curl.h
+++ b/ext/curl/php_curl.h
@@ -181,6 +181,7 @@ typedef struct {
CURLMcode mcode;
int pending;
zval *headers;
+ struct curl_slist *headers_slist; /* holds custom headers sent out in the request */
} php_curl_stream;
diff --git a/ext/curl/streams.c b/ext/curl/streams.c
index 821c2ecad8..887c6f572c 100644
--- a/ext/curl/streams.c
+++ b/ext/curl/streams.c
@@ -218,6 +218,10 @@ static int php_curl_stream_close(php_stream *stream, int close_handle TSRMLS_DC)
curl_easy_cleanup(curlstream->curl);
curl_multi_cleanup(curlstream->multi);
+ if (curlstream->headers_slist) {
+ curl_slist_free_all(curlstream->headers_slist);
+ }
+
/* we are not closing curlstream->readbuf here, because we export
* it as a zval with the wrapperdata - the engine will garbage collect it */
@@ -268,7 +272,6 @@ php_stream *php_curl_stream_opener(php_stream_wrapper *wrapper, char *filename,
php_stream *stream;
php_curl_stream *curlstream;
zval *tmp, **ctx_opt = NULL;
- struct curl_slist *slist = NULL;
curlstream = emalloc(sizeof(php_curl_stream));
memset(curlstream, 0, sizeof(php_curl_stream));
@@ -279,6 +282,7 @@ php_stream *php_curl_stream_opener(php_stream_wrapper *wrapper, char *filename,
curlstream->curl = curl_easy_init();
curlstream->multi = curl_multi_init();
curlstream->pending = 1;
+ curlstream->headers_slist = NULL;
/* if opening for an include statement, ensure that the local storage will
* have a FILE* associated with it.
@@ -351,7 +355,7 @@ php_stream *php_curl_stream_opener(php_stream_wrapper *wrapper, char *filename,
zend_hash_move_forward_ex(Z_ARRVAL_PP(ctx_opt), &pos)
) {
if (Z_TYPE_PP(header) == IS_STRING) {
- slist = curl_slist_append(slist, Z_STRVAL_PP(header));
+ curlstream->headers_slist = curl_slist_append(curlstream->headers_slist, Z_STRVAL_PP(header));
}
}
} else if (Z_TYPE_PP(ctx_opt) == IS_STRING && Z_STRLEN_PP(ctx_opt)) {
@@ -361,14 +365,14 @@ php_stream *php_curl_stream_opener(php_stream_wrapper *wrapper, char *filename,
p = php_strtok_r(copy_ctx_opt, "\r\n", &token);
while (p) {
trimmed = php_trim(p, strlen(p), NULL, 0, NULL, 3 TSRMLS_CC);
- slist = curl_slist_append(slist, trimmed);
+ curlstream->headers_slist = curl_slist_append(curlstream->headers_slist, trimmed);
efree(trimmed);
p = php_strtok_r(NULL, "\r\n", &token);
}
efree(copy_ctx_opt);
}
- if (slist) {
- curl_easy_setopt(curlstream->curl, CURLOPT_HTTPHEADER, slist);
+ if (curlstream->headers_slist) {
+ curl_easy_setopt(curlstream->curl, CURLOPT_HTTPHEADER, curlstream->headers_slist);
}
}
if (SUCCESS == php_stream_context_get_option(context, "http", "method", &ctx_opt) && Z_TYPE_PP(ctx_opt) == IS_STRING) {
@@ -500,18 +504,10 @@ php_stream *php_curl_stream_opener(php_stream_wrapper *wrapper, char *filename,
}
}
- /* context headers are not needed anymore */
- if (slist) {
- curl_easy_setopt(curlstream->curl, CURLOPT_HTTPHEADER, NULL);
- curl_slist_free_all(slist);
- }
return stream;
exit_fail:
php_stream_close(stream);
- if (slist) {
- curl_slist_free_all(slist);
- }
return NULL;
}