From: Ilia Alshanetsky Date: Fri, 6 May 2005 02:31:07 +0000 (+0000) Subject: Added max_redirects context option that specifies how many HTTP redirects X-Git-Tag: php-5.0.1b1~308 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3ae10919c4a311381d8c47debddfc2de4d7f2941;p=php Added max_redirects context option that specifies how many HTTP redirects to follow. --- diff --git a/NEWS b/NEWS index d74ecf3c7f..8e6d2bb9e7 100644 --- a/NEWS +++ b/NEWS @@ -101,6 +101,8 @@ PHP NEWS - Added zlib stream filter support. (Sara) - Added bz2 stream filter support. (Sara) - Added HTTP/1.1 and chunked encoding support to http:// wrapper. (Sara) +- Added max_redirects context option that specifies how many HTTP + redirects to follow. (Ilia) - Added support of parameter=>value arrays to xsl_xsltprocessor_set_parameter(). (Tony) - Fixed extension initialization to respect dependancies between extensions. diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c index 0fd2918583..f34910eb16 100644 --- a/ext/standard/http_fopen_wrapper.c +++ b/ext/standard/http_fopen_wrapper.c @@ -104,7 +104,7 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path, int protocol_version_len = 3; /* Default: "1.0" */ if (redirect_max < 1) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Circular redirect, aborting."); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Redirection limit reached, aborting."); return NULL; } @@ -182,6 +182,12 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path, php_stream_notify_info(context, PHP_STREAM_NOTIFY_CONNECT, NULL, 0); + if (header_init && context && php_stream_context_get_option(context, "http", "max_redirects", &tmpzval) == SUCCESS) { + SEPARATE_ZVAL(tmpzval); + convert_to_long_ex(tmpzval); + redirect_max = Z_LVAL_PP(tmpzval); + } + if (context && php_stream_context_get_option(context, "http", "method", &tmpzval) == SUCCESS) { if (Z_TYPE_PP(tmpzval) == IS_STRING && Z_STRLEN_PP(tmpzval) > 0) {