#39095 [NEW]: 'max_redirects' context options doesn't work when value is 1

From: Date: Mon, 09 Oct 2006 14:05:04 +0000
Subject: #39095 [NEW]: 'max_redirects' context options doesn't work when value is 1
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-103303@lists.php.net to get a copy of this message
From: shen dot shenstone at gmail dot com Operating system: Windows XP Pro SP2 PHP version: 5.1.6 PHP Bug Type: Streams related Bug description: 'max_redirects' context options doesn't work when value is 1 Description: ------------ I resubmit this issus because when i add comment to old post, it always return that "Please do not SPAM our bug system." Three Scripts for Test ====================== re1.php ------- <?php header('Location: re2.php'); ?> re2.php ------- <?php header('Location: re3.php'); ?> re3.php ------- <?php echo 'reached.'; ?> TEST SCRIPT =========== <?php $dlp = "http://localhost:8080/re1.php"; $opts = array( 'http' => array( 'max_redirects' => 1, 'method' => "GET", 'header' => "Accept: */*\r\n" . "Accept-Language: en-us\r\n" . "Accept-Encoding: gzip, deflate\r\n" . "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 1.1.4322)\r\n" . "Connection: Close\r\n" ) ); $context = stream_context_create($opts); $fp = fopen($dlp, 'r', false, $context); $meta_data = stream_get_meta_data($fp); var_dump($fp); var_dump($meta_data); ?> RESULT(Copy & Paste from Windows Console) ========================================= 1. max_redirects = 1 -------------------- PHP Warning: fopen(): Redirection limit reached, aborting. in D:\webroot\test.p hp on line 18 Warning: fopen(): Redirection limit reached, aborting. in D:\webroot\test.php on line 18 PHP Warning: fopen(http://localhost:8080/re1.php): failed to open stream: No er ror in D:\webroot\test.php on line 18 Warning: fopen(http://localhost:8080/re1.php): failed to open stream: No error i n D:\webroot\test.php on line 18 PHP Warning: stream_get_meta_data(): supplied argument is not a valid stream re source in D:\webroot\test.php on line 19 Warning: stream_get_meta_data(): supplied argument is not a valid stream resourc e in D:\webroot\test.php on line 19 bool(false) bool(false) 2. max_redirects = 2 -------------------- PHP Warning: fopen(): Redirection limit reached, aborting. in D:\webroot\test.p hp on line 18 Warning: fopen(): Redirection limit reached, aborting. in D:\webroot\test.php on line 18 PHP Warning: fopen(http://localhost:8080/re1.php): failed to open stream: No er ror in D:\webroot\test.php on line 18 Warning: fopen(http://localhost:8080/re1.php): failed to open stream: No error i n D:\webroot\test.php on line 18 PHP Warning: stream_get_meta_data(): supplied argument is not a valid stream re source in D:\webroot\test.php on line 19 Warning: stream_get_meta_data(): supplied argument is not a valid stream resourc e in D:\webroot\test.php on line 19 bool(false) bool(false) 3. max_redirects = 3 -------------------- resource(7) of type (stream) array(10) { ["wrapper_data"]=> array(23) { [0]=> string(18) "HTTP/1.1 302 Found" [1]=> string(35) "Date: Mon, 09 Oct 2006 13:37:38 GMT" [2]=> string(14) "Server: Apache" [3]=> string(53) "Set-Cookie: ZDEDebuggerPresent=php,phtml,php3; path=/" [4]=> string(17) "Location: re2.php" [5]=> string(17) "Content-Length: 0" [6]=> string(17) "Connection: close" [7]=> string(39) "Content-Type: text/html; charset=GB2312" [8]=> string(18) "HTTP/1.1 302 Found" [9]=> string(35) "Date: Mon, 09 Oct 2006 13:37:38 GMT" [10]=> string(14) "Server: Apache" [11]=> string(53) "Set-Cookie: ZDEDebuggerPresent=php,phtml,php3; path=/" [12]=> string(17) "Location: re3.php" [13]=> string(17) "Content-Length: 0" [14]=> string(17) "Connection: close" [15]=> string(39) "Content-Type: text/html; charset=GB2312" [16]=> string(15) "HTTP/1.1 200 OK" [17]=> string(35) "Date: Mon, 09 Oct 2006 13:37:38 GMT" [18]=> string(14) "Server: Apache" [19]=> string(53) "Set-Cookie: ZDEDebuggerPresent=php,phtml,php3; path=/" [20]=> string(17) "Content-Length: 8" [21]=> string(17) "Connection: close" [22]=> string(39) "Content-Type: text/html; charset=GB2312" } ["wrapper_type"]=> string(4) "http" ["stream_type"]=> string(10) "tcp_socket" ["mode"]=> string(2) "r+" ["unread_bytes"]=> int(8) ["seekable"]=> bool(false) ["uri"]=> string(29) "http://localhost:8080/re1.php" ["timed_out"]=> bool(false) ["blocked"]=> bool(true) ["eof"]=> bool(false) } -- Edit bug report at http://bugs.php.net/?id=39095&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=39095&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=39095&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=39095&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=39095&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=39095&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=39095&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=39095&r=needscript Try newer version: http://bugs.php.net/fix.php?id=39095&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=39095&r=support Expected behavior: http://bugs.php.net/fix.php?id=39095&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=39095&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=39095&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=39095&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39095&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=39095&r=dst IIS Stability: http://bugs.php.net/fix.php?id=39095&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=39095&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=39095&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=39095&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=39095&r=mysqlcfg

« previous php.bugs (#103303) next »