diff options
author | Pierre Joye <pajoye@php.net> | 2010-08-23 16:54:57 +0000 |
---|---|---|
committer | Pierre Joye <pajoye@php.net> | 2010-08-23 16:54:57 +0000 |
commit | a0e223b8ba773ce4c855c6bfaea234bb121d5306 (patch) | |
tree | 5b67bab0ca43453c3e5c54b2fce4e25aa3eefe5a /ext/standard/http_fopen_wrapper.c | |
parent | a532eefe29611f22c79b5e41aec899a27e55a353 (diff) | |
download | php-git-a0e223b8ba773ce4c855c6bfaea234bb121d5306.tar.gz |
- 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)
Diffstat (limited to 'ext/standard/http_fopen_wrapper.c')
-rw-r--r-- | ext/standard/http_fopen_wrapper.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c index 5b4cae2074..4ae78f3ac4 100644 --- a/ext/standard/http_fopen_wrapper.c +++ b/ext/standard/http_fopen_wrapper.c @@ -111,6 +111,7 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path, 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 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path, 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 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path, 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; } |