|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48396 cURL output includes content from redirects when CURLOPT_FOLLOWLOCATION set
Submitted: 2009-05-26 08:37 UTC Modified: 2009-05-26 17:36 UTC
From: kulakov74 at yandex dot ru Assigned:
Status: Not a bug Package: cURL related
PHP Version: 5.2.6 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: kulakov74 at yandex dot ru
New email:
PHP Version: OS:


 [2009-05-26 08:37 UTC] kulakov74 at yandex dot ru
Sorry, this is not a bug in itself but an addition to the bug 45533 because it was closed and I can't add it there. You can move the message to 

I reconfirm the issue with PHP 5.2.6
cURL Information  libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5

To make it short here is some output from CURL: 

HTTP/1.1 302 Moved Temporarily
Date: Tue, 26 May 2009 07:55:51 GMT
Location: ...

</HTML>                         <----------here is the problem!!!
HTTP/1.1 200 OK
Set-Cookie: GoogleAccountsLocale_session=en
Server: GFE/2.0

<body ...</body></html>

Note how headers and bodies follow each other. Normally I get 2 (or more) chunks of headers and only the last response as the body, but this time I got a mixture. So it DOES depend on the server. In this case I log in to my google account and then go to the gmail link with a PHP-script (don't ask me why :) ).

I don't think I will go into the mess of reproducing this with the command line curl, though it might be possible. 

Note that if I do not set the option CURLOPT_HEADER the problem still remains, but I get 2 bodies merged without headers.

Reproduce code:
I can send or provide URL to the code, of course it's not trivial. 

Expected result:
See above.

Actual result:
See above.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-26 10:01 UTC]
Please try using this CVS snapshot:
For Windows:

 [2009-05-26 12:52 UTC] kulakov74 at yandex dot ru
Sorry, cannot install PHP on the servers I work with. 
I submitted my comment because the author of the original bug wrote that he had reproduced the bug with many versions up to 5.2.9, so I thought 5.2.6 would do. I now have reproduced the problem with 5.2.9 too (finally found the server with it). 

With Windows, I reproduced this with my "old" PHP 4.4.1. This is definitely related to the way Google responds, it must be using some different syntax or something that CURL does not expect. For example my own http client implementation (using fsockopen()) handles the response properly.
 [2009-05-26 17:36 UTC]
To get better control over these, use CURLOPT_HEADERFUNCTION and CURLOPT_WRITEFUNCTION. The rest is cURL internals which we have no control over.

PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Aug 04 05:13:43 2020 UTC