ID:               38802
 Updated by:       [EMAIL PROTECTED]
 Reported By:      shen dot shenstone at gmail dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         HTTP related
 Operating System: Windows XP Pro SP2
 PHP Version:      5.1.6
 New Comment:

The first header is "Location", this is pretty clear.
If you want to get the header itself you can use fsockopen().



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

[2006-09-13 12:44:51] shen dot shenstone at gmail dot com

i just want get first hrader and not let php automatic follow the
redirect.

i try again and it did not work.

;(

thanks

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

[2006-09-13 10:11:25] shen dot shenstone at gmail dot com

i see, no redirects followed, but it didn't fetch any info(headers)
from the first request.
it produce error "Redirection limit reached", i just need the first
header.

thanks
sorry for poor english.;)

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

[2006-09-13 08:04:45] [EMAIL PROTECTED]

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

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

[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

Reply via email to