|  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
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:

Reproduce code:

Expected result:
echo $headers['Location']; //returns

Actual result:
Warning: get_headers( [function.get-headers]: failed to open stream: Connection timed out


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-01-11 12:32 UTC]
You can control the number of redirects (or disable them entirely) via 
the max_redirects streams context option.
PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Wed Nov 25 12:01:35 2015 UTC