Bug #63795 [Asn]: url-7.28.1 breaks PHP curl_getinfo and curl_multi_getcontent
| From: | pierrick@php.net | Date: | Wed, 19 Dec 2012 04:35:50 +0000 |
| Subject: | Bug #63795 [Asn]: url-7.28.1 breaks PHP curl_getinfo and curl_multi_getcontent | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-175449@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=63795&edit=1
ID: 63795
Updated by: pierrick@php.net
Reported by: blueness at gentoo dot org
Summary: url-7.28.1 breaks PHP curl_getinfo and
curl_multi_getcontent
Status: Assigned
Type: Bug
Package: cURL related
Operating System: Linux
PHP Version: 5.4.9
Assigned To: pierrick
Block user comment: N
Private report: N
New Comment:
This bug was introduced when the support of the value 1 for
CURLOPT_SSL_VERIFYHOST was removed in 7.28.1.
In your code sample, you're using curl_setopt_array. How this function work
internally is that it will loop over all your options and set them one by one on
your curl handle using the libcurl curl_easy_setopt function. If one of this set
fail, the function will break the iteration and will return false.
In your case, when you're using libcurl 7.28.1, curl_setopt_array will fail when
it will try to set CURLOPT_SSL_VERIFYHOST to 1, and then will not set
CURLOPT_HEADER. The result of your curl_exec function will then not include the
headers. Then when you remove the begining of your string to remove your header,
you're in fact removing the begining of your content since there is no header
included in the original string.
If you move your CURLOPT_SSL_VERIFYHOST to the end of your array this should fix
your problem. Can you confirm ?
I started a discussion on internal to see how we want to deal with this problem.
Previous Comments:
------------------------------------------------------------------------
[2012-12-18 02:26:43] blueness at gentoo dot org
Description:
------------
When php 5.4.9 is built against curl-7.28.1, curl_multi_getcontent($stuff) does not return the full
content of the web page but truncates some characters from the beginning. See the following
downstream bugs for more details:
https://sourceforge.net/p/curl/bugs/1172/
https://bugs.gentoo.org/show_bug.cgi?id=444788
In the gentoo bug, please look at comment #14 since it pin points the curl commit that deprecated
CURLOPT_SSL_VERIFYHOST=1 and led to the breakage in php.
Test script:
---------------
<?php
$cm = curl_multi_init();
$stuffs = curl_init();
$curl_options = array(
CURLOPT_URL => 'http://www.google.ca',
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_SSL_VERIFYHOST => 0, // these are the problem
CURLOPT_SSL_VERIFYPEER => 0, // toggle 0/1 to test
CURLOPT_HEADER => 1
);
curl_setopt_array($stuffs, $curl_options);
curl_multi_add_handle($cm, $stuffs);
do { curl_multi_exec($cm, $running); } while($running > 0);
$content = curl_multi_getcontent($stuffs);
$info = curl_getinfo($stuffs);
curl_multi_remove_handle($cm, $stuffs);
curl_multi_close($cm);
print_r($info);
// cuts off too much, the header size is incorrect
echo mb_substr($content, $info['header_size']);
?>
Expected result:
----------------
For the expected and actual results, please see
https://bugs.gentoo.org/show_bug.cgi?id=444788
comments #10-13
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=63795&edit=1