pajoye Mon, 23 Aug 2010 16:54:57 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=302714
Log:
- add follow_location support for http stream, enabled by default to keep BC.
Allows one to ignore the location header, w/o having to ignore errors or other
tricks, the location data is however still available (meta)
Changed paths:
U php/php-src/branches/PHP_5_3/NEWS
U php/php-src/branches/PHP_5_3/ext/standard/http_fopen_wrapper.c
U php/php-src/trunk/ext/standard/http_fopen_wrapper.c
Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS 2010-08-23 15:28:23 UTC (rev 302713)
+++ php/php-src/branches/PHP_5_3/NEWS 2010-08-23 16:54:57 UTC (rev 302714)
@@ -4,6 +4,8 @@
- Upgraded bundled Sqlite3 to version 3.7.0.1. (Ilia)
- Upgraded bundled PCRE to version 8.10. (Ilia)
+- Added follow_location (enabled by default) option for the http stream
support.
+ (Pierre)
- Added new character sets to mysqlnd, which are available in MySQL 5.5
(Andrey)
Modified: php/php-src/branches/PHP_5_3/ext/standard/http_fopen_wrapper.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/standard/http_fopen_wrapper.c
2010-08-23 15:28:23 UTC (rev 302713)
+++ php/php-src/branches/PHP_5_3/ext/standard/http_fopen_wrapper.c
2010-08-23 16:54:57 UTC (rev 302714)
@@ -111,6 +111,7 @@
char *user_headers = NULL;
int header_init = ((flags & HTTP_WRAPPER_HEADER_INIT) != 0);
int redirected = ((flags & HTTP_WRAPPER_REDIRECTED) != 0);
+ int follow_location = 1;
php_stream_filter *transfer_encoding = NULL;
tmp_line[0] = '\0';
@@ -628,6 +629,11 @@
http_header_line[http_header_line_length] = '\0';
if (!strncasecmp(http_header_line, "Location: ", 10)) {
+ if (context &&
php_stream_context_get_option(context, "http", "follow_location", &tmpzval) ==
SUCCESS) {
+ SEPARATE_ZVAL(tmpzval);
+ convert_to_long_ex(tmpzval);
+ follow_location = Z_LVAL_PP(tmpzval);
+ }
strlcpy(location, http_header_line + 10,
sizeof(location));
} else if (!strncasecmp(http_header_line,
"Content-Type: ", 14)) {
php_stream_notify_info(context,
PHP_STREAM_NOTIFY_MIME_TYPE_IS, http_header_line + 14, 0);
@@ -670,9 +676,9 @@
break;
}
}
-
- if (!reqok || location[0] != '\0') {
- if (((options & STREAM_ONLY_GET_HEADERS) || ignore_errors) &&
redirect_max <= 1) {
+
+ if (!reqok || (location[0] != '\0' && follow_location)) {
+ if (!follow_location && (((options & STREAM_ONLY_GET_HEADERS)
|| ignore_errors) && redirect_max <= 1)) {
goto out;
}
Modified: php/php-src/trunk/ext/standard/http_fopen_wrapper.c
===================================================================
--- php/php-src/trunk/ext/standard/http_fopen_wrapper.c 2010-08-23 15:28:23 UTC
(rev 302713)
+++ php/php-src/trunk/ext/standard/http_fopen_wrapper.c 2010-08-23 16:54:57 UTC
(rev 302714)
@@ -111,6 +111,7 @@
char *user_headers = NULL;
int header_init = ((flags & HTTP_WRAPPER_HEADER_INIT) != 0);
int redirected = ((flags & HTTP_WRAPPER_REDIRECTED) != 0);
+ int follow_location = 1;
php_stream_filter *transfer_encoding = NULL;
tmp_line[0] = '\0';
@@ -628,6 +629,11 @@
http_header_line[http_header_line_length] = '\0';
if (!strncasecmp(http_header_line, "Location: ", 10)) {
+ if (context &&
php_stream_context_get_option(context, "http", "follow_location", &tmpzval) ==
SUCCESS) {
+ SEPARATE_ZVAL(tmpzval);
+ convert_to_long_ex(tmpzval);
+ follow_location = Z_LVAL_PP(tmpzval);
+ }
strlcpy(location, http_header_line + 10,
sizeof(location));
} else if (!strncasecmp(http_header_line,
"Content-Type: ", 14)) {
php_stream_notify_info(context,
PHP_STREAM_NOTIFY_MIME_TYPE_IS, http_header_line + 14, 0);
@@ -670,9 +676,9 @@
break;
}
}
-
- if (!reqok || location[0] != '\0') {
- if (((options & STREAM_ONLY_GET_HEADERS) || ignore_errors) &&
redirect_max <= 1) {
+
+ if (!reqok || (location[0] != '\0' && follow_location)) {
+ if (!follow_location && (((options & STREAM_ONLY_GET_HEADERS)
|| ignore_errors) && redirect_max <= 1)) {
goto out;
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php