]> granicus.if.org Git - php/commitdiff
Added max_redirects context option that specifies how many HTTP redirects
authorIlia Alshanetsky <iliaa@php.net>
Fri, 6 May 2005 02:31:07 +0000 (02:31 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Fri, 6 May 2005 02:31:07 +0000 (02:31 +0000)
to follow.

NEWS
ext/standard/http_fopen_wrapper.c

diff --git a/NEWS b/NEWS
index d74ecf3c7fee72036e0bac94a5afee5290b19b1f..8e6d2bb9e72789bae670ca9d1da213085fe5f4f0 100644 (file)
--- 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.
index 0fd2918583a5448a1676d6cb4cbafd9eaaaba78b..f34910eb168ab5af2e2511e6c4ac7bdf805040e2 100644 (file)
@@ -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) {