php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50719 get_headers and file_get_contents always follows location redirect
Submitted: 2010-01-11 12:18 UTC Modified: 2010-01-11 12:32 UTC
From: php at hm2k dot org Assigned:
Status: Not a bug Package: Streams related
PHP Version: 5.3.1 OS:
Private report: No CVE-ID:
 [2010-01-11 12:18 UTC] php at hm2k dot org
Description:
------------
get_headers and file_get_contents should not blindly follow the location redirect.

The reason for this is that I, like others, want to get_headers  of the url i've supplied, not the ultimate location.

I'm not the only one having this issue, also see:

http://www.php.net/manual/en/function.get-headers.php#90434

Reproduce code:
---------------
$headers=get_headers('http://tinyurl.com/hm2k');

Expected result:
----------------
echo $headers['Location']; //returns http://connecting.nokia.com/NOKIA/WWW/HRJEdisc.nsf/HNew/0CB2705072779CACC2256D630080E7F4

Actual result:
--------------
Warning: get_headers(http://tinyurl.com/hm2k) [function.get-headers]: failed to open stream: Connection timed out

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-01-11 12:32 UTC] iliaa@php.net
You can control the number of redirects (or disable them entirely) via 
the max_redirects streams context option.
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Fri Apr 18 20:01:57 2014 UTC