From:             shen dot shenstone at gmail dot com
Operating system: Windows XP Pro SP2
PHP version:      5.1.6
PHP Bug Type:     HTTP related
Bug description:  'max_redirects' context options doesn't work when value is 1

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 bug report at http://bugs.php.net/?id=38802&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=38802&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=38802&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=38802&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=38802&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=38802&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=38802&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=38802&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=38802&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=38802&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=38802&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=38802&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=38802&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=38802&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=38802&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=38802&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=38802&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=38802&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=38802&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=38802&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=38802&r=mysqlcfg

Reply via email to