Bug #53018 [Asn]: file_get_contents does not follow 301 and 302 redirects with curlwrappers
| From: | pierrick@php.net | Date: | Mon, 24 Dec 2012 13:49:32 +0000 |
| Subject: | Bug #53018 [Asn]: file_get_contents does not follow 301 and 302 redirects with curlwrappers | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-175593@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=53018&edit=1
ID: 53018
Updated by: pierrick@php.net
Reported by: techs at remsys dot com
Summary: file_get_contents does not follow 301 and 302
redirects with curlwrappers
Status: Assigned
Type: Bug
Package: cURL related
Operating System: Linux x86_64 CentOS release 5.5
PHP Version: 5.2.14
Assigned To: cataphract
Block user comment: N
Private report: N
New Comment:
cataphract, any idea on how to reproduce this ? or what was the problem ? I'm
trying to fix as much bug as possible in ext/curl but can not reproduce this one.
Previous Comments:
------------------------------------------------------------------------
[2010-10-18 17:45:29] techs at remsys dot com
As a workaround we have recompiled php without --with-curlwrappers option and file_get_contents
started to work as it should.
We have latest curl on that server curl-7.15.5-9.el5 here is version info:
curl 7.15.5 (x86_64-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
------------------------------------------------------------------------
[2010-10-08 20:27:31] techs at remsys dot com
Thank you for reply.
Well same situation with max_redirects. It works only for cli. It seems SAPI ignore it and set to
zero or 1.
And yes both versions are comiled with curlwrappers. You can see phpinfo() here
isonet.ru/test/pi.php
I would really appreciate any other thoughts or suggestions.
Thank you.
------------------------------------------------------------------------
[2010-10-08 05:07:37] aharvey@php.net
The redirections are followed for me both in the CLI and Apache SAPIs; I can't see any obvious
reason why one would be different to the other.
Immediate thoughts:
- Does your Apache script set any context options at any point? There is a HTTP context option
called "max_redirects" which controls this behaviour -- if it's set to 0, then
redirects aren't followed.
- Did either (or both) builds have --with-curlwrappers enabled at build time? You can check that in
the "Configure Command" line in phpinfo().
------------------------------------------------------------------------
[2010-10-07 22:43:32] techs at remsys dot com
Description:
------------
Function file_get_contents() does not follow 301 and 302 redirects sub apache module.
It returns following:
--8< -----------------------
<HTML><HEAD><meta http-equiv="content-type"
content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
--8< -----------------------
We got this situation on a 20 servers and even on php-5.2.13, but in the same time it works on
others servers with same configuration.
Mystery starts when we run this script from command line. It works fine with cli, wich is compiled
with same options and use same php.ini.
Test script:
---------------
<?php
echo file_get_contents("http://google.com");
Expected result:
----------------
file_get_contents should follow redirects.
Actual result:
--------------
Now it doesn't in some cases.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=53018&edit=1