#38802 [Opn->Bgs]: 'max_redirects' context options doesn't work when value is 1

From: Date: Wed, 13 Sep 2006 08:04:46 +0000
Subject: #38802 [Opn->Bgs]: 'max_redirects' context options doesn't work when value is 1
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-102081@lists.php.net to get a copy of this message
 ID:               38802
 Updated by:       tony2001@php.net
 Reported By:      shen dot shenstone at gmail dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         HTTP related
 Operating System: Windows XP Pro SP2
 PHP Version:      5.1.6
 New Comment:

max_redirects - The max number of redirects to follow. Value 1 or less
means that no redirects are followed. 

http://www.php.net/manual/en/wrappers.http.php


Previous Comments:
------------------------------------------------------------------------

[2006-09-13 07:36:04] shen dot shenstone at gmail dot com

Description:
------------
i set 'max_redirects' to 1 to disable redirect, but it did not work and
produce some error....
'PHP Warning:  fopen(): Redirection limit reached, aborting. in
D:\webroot\nlr.ph
p on line 66'

if i set it to 2, everything works well...redirect works.

note: http://172.23.68.8/index.php will simple locate to
another url.


;)
thanks

SHEN ZhiQiang

Reproduce code:
---------------
$access = "http://172.23.68.8/index.php";

$opts = array(
	'http' => array(
		'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" .
					//"Host: www.netlibrary.com\r\n" .
					"Connection: Keep-Alive\r\n",
	'max_redirects' => '1'
	)
);

$context = stream_context_create($opts);

$fp = fopen($access, 'r', false, $context);
$meta_data = stream_get_meta_data($fp);
var_dump($meta_data);
file_put_contents('./test.dump', $fp);
fclose($fp);

Actual result:
--------------
PHP Warning:  fopen(): Redirection limit reached, aborting. in
D:\webroot\nlr.ph
p on line 66

Warning: fopen(): Redirection limit reached, aborting. in
D:\webroot\nlr.php on
line 66
PHP Warning:  fopen(http://172.23.68.8/index.php): failed to open
stream: No err
or in D:\webroot\nlr.php on line 66

Warning: fopen(http://172.23.68.8/index.php): failed to open stream: No
error in
 D:\webroot\nlr.php on line 66
PHP Warning:  stream_get_meta_data(): supplied argument is not a valid
stream re
source in D:\webroot\nlr.php on line 67

Warning: stream_get_meta_data(): supplied argument is not a valid
stream resourc
e in D:\webroot\nlr.php on line 67
bool(false)
PHP Warning:  fclose(): supplied argument is not a valid stream
resource in D:\w
ebroot\nlr.php on line 70

Warning: fclose(): supplied argument is not a valid stream resource in
D:\webroo
t\nlr.php on line 70


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=38802&edit=1


Thread (10 messages)

« previous php.bugs (#102081) next »