ID: 48550
User updated by: victorepand at gmail dot com
Reported By: victorepand at gmail dot com
-Status: Feedback
+Status: Open
Bug Type: cURL related
Operating System: FreeBSD
PHP Version: 5.2.9
New Comment:
The error returned by cURL is:
22 The requested URL returned error: 404
I created this function which solves the problem:
function urlencode_url($url) {
if (!($ei=strpos($url,"?"))) $ei=strlen($url);
$newurl=str_replace(array("%3A","%2F"),array(":","/"),urlencode(urldecode(substr($url,0,$ei)))).substr($url,$ei);
return $newurl;
}
By passing the URL through this function, the offending character is
converted to its urlencoded equivalent (%##). With these codes instead
of the bad character, cURL reads the URL with no problem.
Nonetheless, I reported this issue because Internet Explorer does not
require the urlencoded codes. It loads the original URL with no problem,
using the original bad character in the URL. Therefore, the cURL
behavior is more strict in its requirement of the URL being urlencoded
than Internet Explorer is.
Perhaps cURL could automatically urlencode the URL, or perhaps a
function should be made for this purpose like the one I have shown
above.
Previous Comments:
------------------------------------------------------------------------
[2009-06-15 14:31:33] [email protected]
What error does it give? See http://www.php.net/curl_error
------------------------------------------------------------------------
[2009-06-14 17:13:56] victorepand at gmail dot com
Description:
------------
cURL does not work when the URL has a â character in it. Such as, for
example, this one:
http://www.motorcycle-superstore.com/ProductImages/60/2009_GMax_Womenâs_GM17_Derk_Open-Face_Helmet.jpg
Reproduce code:
---------------
$ch=curl_init();
$url="http://www.motorcycle-superstore.com/ProductImages/60/2009_GMax_Womenâs_GM17_Derk_Open-Face_Helmet.jpg"
curl_setopt($ch,CURLOPT_URL,$url);
$result=curl_exec ($ch);
Expected result:
----------------
thumbnail image in binary stored in result
Actual result:
--------------
curl error
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=48550&edit=1