cvs: php-src(PHP_5_2) / NEWS /ext/standard url.c
| From: | Ilia Alshanetsky | Date: | Mon, 25 Sep 2006 16:00:43 +0000 |
| Subject: | cvs: php-src(PHP_5_2) / NEWS /ext/standard url.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-40705@lists.php.net to get a copy of this message | ||
iliaa Mon Sep 25 16:00:43 2006 UTC
Modified files: (Branch: PHP_5_2)
/php-src NEWS
/php-src/ext/standard url.c
Log:
Fixed bug #38891 (get_headers() do not work with curl-wrappers).
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.263&r2=1.2027.2.547.2.264&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.263 php-src/NEWS:1.2027.2.547.2.264
--- php-src/NEWS:1.2027.2.547.2.263 Mon Sep 25 14:48:32 2006
+++ php-src/NEWS Mon Sep 25 16:00:43 2006
@@ -9,6 +9,7 @@
- Fixed bug #38941 (imap extension does not compile against new version of
the imap library). (Ilia)
- Fixed bug #38904 (apache2filter changes cwd to /). (Ilia, bjori)
+- Fixed bug #38891 (get_headers() do not work with curl-wrappers). (Ilia)
- Fixed bug #38844 (curl_easy_strerror() is defined only since cURL 7.12.0).
(Tony)
- Fixed bug #38623 (leaks in a tricky code with switch() and exceptions).
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/url.c?r1=1.86.2.5.2.3&r2=1.86.2.5.2.4&diff_format=u
Index: php-src/ext/standard/url.c
diff -u php-src/ext/standard/url.c:1.86.2.5.2.3 php-src/ext/standard/url.c:1.86.2.5.2.4
--- php-src/ext/standard/url.c:1.86.2.5.2.3 Sat Sep 23 11:58:58 2006
+++ php-src/ext/standard/url.c Mon Sep 25 16:00:43 2006
@@ -15,7 +15,7 @@
| Author: Jim Winstead <jimw@php.net> |
+----------------------------------------------------------------------+
*/
-/* $Id: url.c,v 1.86.2.5.2.3 2006/09/23 11:58:58 tony2001 Exp $ */
+/* $Id: url.c,v 1.86.2.5.2.4 2006/09/25 16:00:43 iliaa Exp $ */
#include <stdlib.h>
#include <string.h>
@@ -661,8 +661,9 @@
int url_len;
php_stream_context *context;
php_stream *stream;
- zval **prev_val, **hdr = NULL;
+ zval **prev_val, **hdr = NULL, **h;
HashPosition pos;
+ HashTable *hashT;
long format = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &url, &url_len,
&format) == FAILURE) {
@@ -676,10 +677,22 @@
array_init(return_value);
- zend_hash_internal_pointer_reset_ex(HASH_OF(stream->wrapperdata), &pos);
- while (zend_hash_get_current_data_ex(HASH_OF(stream->wrapperdata), (void**)&hdr, &pos)
!= FAILURE) {
+ /* check for curl-wrappers that provide headers via a special "headers" element */
+ if (zend_hash_find(HASH_OF(stream->wrapperdata), "headers",
sizeof("headers"), (void **)&h) != FAILURE && Z_TYPE_PP(h) == IS_ARRAY) {
+ /* curl-wrappers don't load data until the 1st read */
+ if (!Z_ARRVAL_PP(h)->nNumOfElements) {
+ php_stream_getc(stream);
+ }
+ zend_hash_find(HASH_OF(stream->wrapperdata), "headers", sizeof("headers"),
(void **)&h);
+ hashT = Z_ARRVAL_PP(h);
+ } else {
+ hashT = HASH_OF(stream->wrapperdata);
+ }
+
+ zend_hash_internal_pointer_reset_ex(hashT, &pos);
+ while (zend_hash_get_current_data_ex(hashT, (void**)&hdr, &pos) != FAILURE) {
if (!hdr || Z_TYPE_PP(hdr) != IS_STRING) {
- zend_hash_move_forward_ex(HASH_OF(stream->wrapperdata), &pos);
+ zend_hash_move_forward_ex(hashT, &pos);
continue;
}
if (!format) {
@@ -709,7 +722,7 @@
goto no_name_header;
}
}
- zend_hash_move_forward_ex(HASH_OF(stream->wrapperdata), &pos);
+ zend_hash_move_forward_ex(hashT, &pos);
}
php_stream_close(stream);