php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: kulakov74 at yandex dot ru
New email:
PHP Version: OS:

 

 [2009-05-26 08:37 UTC] kulakov74 at yandex dot ru
Description:
------------
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 http://bugs.php.net/bug.php?id=45533. 

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>
...
</HTML>                         <----------here is the problem!!!
HTTP/1.1 200 OK
Set-Cookie: GoogleAccountsLocale_session=en
...
Server: GFE/2.0

<html><head><title>Redirecting</title>
...
<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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-26 10:01 UTC] jani@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [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] jani@php.net
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-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 13:01:29 2024 UTC