Hello,
The following code is failing and I do not find the cause (please, note
that checkurl value and CURLOPT_PROXY are NOT the real values I'm using,
of course):
$ch = curl_init();
$checkurl = 'http://mycheckhost.com/';
curl_setopt ($ch, CURLOPT_TIMEOUT, 6000);
curl_setopt ($ch, CURLOPT_URL, $checkurl);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_HEADER, false);
curl_setopt ($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt ($ch, CURLOPT_PROXY, '1.2.3.4:8888' );
$data = curl_exec($ch);
$curl_info = curl_getinfo ($ch);
if ( $data === false ) {
$rtn = false;
} else {
$rtn = true;
}
return $rtn;
Every curl_exec returns false, and a var_dump of $curl_info looks as
follows:
array(21) {
["url"]=>
string(25) "http://mycheckhost.com/"
["content_type"]=>
NULL
["http_code"]=>
int(0)
["header_size"]=>
int(0)
["request_size"]=>
int(99)
["filetime"]=>
int(-1)
["ssl_verify_result"]=>
int(0)
["redirect_count"]=>
int(0)
["total_time"]=>
float(1.843925)
["namelookup_time"]=>
float(0.00018)
["connect_time"]=>
float(0.333015)
["pretransfer_time"]=>
float(0)
["size_upload"]=>
float(0)
["size_download"]=>
float(0)
["speed_download"]=>
float(0)
["speed_upload"]=>
float(0)
["download_content_length"]=>
float(-1)
["upload_content_length"]=>
float(-1)
["starttransfer_time"]=>
float(0)
["redirect_time"]=>
float(0)
["certinfo"]=>
array(0) {
}
}
I know it is NOT a problem with the website, because if I comment out
the line curl_setopt ($ch, CURLOPT_HTTPPROXYTUNNEL, 1) disabling the use
of a proxy, it works fine.
I know the proxy is working fine, because if I use curl from command
line like:
curl -x 1.2.3.4:8888 http://mycheckhost.com/
It also WORKS fine.
So the problem may be or within the PHP5 curl implementation, or in my
own code, but I have not been able to find the problem with my code.
Any hints?
BTW:
$ php --version
PHP 5.3.6-13ubuntu3.3 with Suhosin-Patch (cli) (built: Dec 13 2011
18:37:10)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
Thanks a lot in advance,
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php