Skip to content

Commit

Permalink
Merge branch 'PHp-5.4' into PHP-5.5
Browse files Browse the repository at this point in the history
* PHp-5.4:
  Fix bug #62524, only follow redirects in file streams for 3xx HTTP statuses
  • Loading branch information
smalyshev committed Jan 29, 2013
2 parents 389d41c + 5382e15 commit 489073b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ext/standard/http_fopen_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,
int redirected = ((flags & HTTP_WRAPPER_REDIRECTED) != 0);
int follow_location = 1;
php_stream_filter *transfer_encoding = NULL;
int response_code;

tmp_line[0] = '\0';

Expand Down Expand Up @@ -657,7 +658,6 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,

if (php_stream_get_line(stream, tmp_line, sizeof(tmp_line) - 1, &tmp_line_len) != NULL) {
zval *http_response;
int response_code;

if (tmp_line_len > 9) {
response_code = atoi(tmp_line + 9);
Expand Down Expand Up @@ -731,7 +731,9 @@ 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) {
/* we only care about Location for 300, 301, 302, 303 and 307 */
/* see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.1 */
if ((response_code >= 300 && response_code < 304 || 307 == response_code) && 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);
Expand Down

0 comments on commit 489073b

Please sign in to comment.