PHP cURL - HTTP Code 0 - php

I've looked at the prior posts about cURL and HTTP code 0, but they aren't helping.
I can cURL into www.bambooping.com with script below from localhost - ie, test_curl.php on localhost calls test_curl2.php on bambooping.com. However, if I run it on bambooping.com, I get HTTP code 0. (I know calling this on same host is dumb - it's just to isolate problem.)
On bambooping.com safe_mode is not set, and curl is compiled in (ie, should be since I can cURL in). This is very strange - the calling host is preventing the cURL. Why would calling out with cURL fail like this, yet calling into that same host with cURL be ok?
test_curl.php:
<?php
error_reporting(E_ALL); ini_set("display_errors", 1);
function curl_download($Url){
// is cURL installed yet?
if (!function_exists('curl_init')){
die('Sorry cURL is not installed!');
}
// OK cool - then let's create a new cURL resource handle
$ch = curl_init();
// Now set some options (most are optional)
// Set URL to download
curl_setopt($ch, CURLOPT_URL, $Url);
// Set a referer
// curl_setopt($ch, CURLOPT_REFERER, $_SERVER['REQUEST_URI']);
// make it blank - then it is ignored - otherwise, checked and error returned!
curl_setopt($ch, CURLOPT_REFERER, '');
// User agent
curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");
// Include header in result? (0 = yes, 1 = no)
curl_setopt($ch, CURLOPT_HEADER, 0);
// Should cURL return or print out the data? (true = return, false = print)
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Timeout in seconds
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
// curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
// Download the given URL, and return output
$output = curl_exec($ch);
print_r(curl_getinfo($ch));
// Close the cURL resource, and free system resources
curl_close($ch);
return $output;
}
$str = curl_download("http://www.bambooping.com/test_curl2.php");
echo $str;
?>
test_curl2.php
<?php
echo "I am here";
?>
The curl_getinfo is:
Array
(
[url] => http://www.bambooping.com/test_curl2.php
[content_type] =>
[http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0
[namelookup_time] => 4.3E-5
[connect_time] => 0
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => 0
[upload_content_length] => 0
[starttransfer_time] => 0
[redirect_time] => 0
)
Ideas? I'm fresh out...
Thanks -

Please check there is a curl error
it's say the problem to you
<?php
if(curl_errno($ch)) echo 'Curl error: ' . curl_error($ch);
?>

The server for www.bambooping.com is probably sitting behind a firewall that prevents outgoing HTTP requests. Even though it's the same server, the request still needs to go out into the wild to resolve the DNS.
You could either edit the hosts file on your server to include 127.0.0.1 www.bampooing.com. Or you could change the URL to http://127.0.0.1/test_curl2.php, as this localhost domain is probably not blocked by the firewall.

Related

PHP - Using cURL to get a cookie from a redirecting URL but getting no response

I have a cURL command using which I get authenticated to a website and it gives a cookie in response, then subsequently using this cookie I can make REST API calls to this service
Here is the working cURL command:
curl -v -l -H "Content-Type: application/x-www-form-urlencoded" -H "Referrer:https://mywebsiteurl.com?ticket=unique_ticket_id" -d "_charset_=UTF-8&errorMessage=User+name+and+password+do+not+match&resource=%2F&username=username%40domain.com&password=XXXXXX&nextpage=welcomeCM.jsp&viewInfo=&ticket=unique_ticket_id" -X POST https://mywebsiteurl.com/index.jsp
In the above command ticket parameter contains a unique ticket id that is passed along with the website url
Now, I'm trying to accomplish the same using cURL PHP, here is the PHP code:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://mywebsiteurl.com/index.jsp");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "_charset_=UTF-8&errorMessage=User+name+and+password+do+not+match&resource=%2F&username=username%40domain.com&password=XXXXXX&nextpage=welcomeCM.jsp&viewInfo=&ticket=unique_ticket_id");
curl_setopt($ch, CURLOPT_POST, 1);
$headers = array(
'Content-Type: application/x-www-form-urlencoded',
'Referrer: https://mywebsiteurl.com?ticket=unique_ticket_id'
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
echo $result;
curl_close ($ch);
Here echo $result shows nothing
I then tried var_dump($result); and it gives this output: string(0) "" which means nothing is getting returned in $response
After this I tried curl_getinfo and added the following code:
echo "<pre>";
$info = curl_getinfo($ch);
print_r($info);
echo "</pre>";
And this gave me the following array:
Array
(
[url] => https://mywebsiteurl.com/index.jsp
[content_type] => text/html;charset=UTF-8
[http_code] => 302
[header_size] => 1306
[request_size] => 619
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 1.540687
[namelookup_time] => 0.028262
[connect_time] => 0.171774
[pretransfer_time] => 0.462507
[size_upload] => 280
[size_download] => 0
[speed_download] => 0
[speed_upload] => 181
[download_content_length] => 0
[upload_content_length] => 280
[starttransfer_time] => 1.54066
[redirect_time] => 0
[redirect_url] => https://mywebsiteurl.com/welcomeCM.jsp?username=username#domain.com&locale=en_US
[primary_ip] => YY.YYY.YYY.YY
[certinfo] => Array
(
)
[primary_port] => 443
[local_ip] => XX.XX.XXX.XX
[local_port] => 47692
)
Now my goal is to get the cookie in $result, but it is empty & nothing is getting returned into it
Is it that something is missing in the cURL command equivalent PHP code?
Can someone please help me out & point me in the direction to retrieve the cookie
Thanks a lot!
UPDATE
I added curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); to the request to have it follow the 302 redirect after successful login
But this time after the execution of cURL, echo $result is redirecting my current local webpage to /Dashboard?viewInfo= which obviously does not exist
Also this time var_dump($result); is resulting in: string(1462) " "
And curl_getinfo($ch) this time is giving the following array:
Array
(
[url] => https://mywebsiteurl.com/welcomeCM.jsp?username=username#domain.com&locale=en_US
[content_type] => text/html;charset=UTF-8
[http_code] => 200
[header_size] => 1821
[request_size] => 956
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 1
[total_time] => 1.746911
[namelookup_time] => 1.5E-5
[connect_time] => 1.5E-5
[pretransfer_time] => 6.2E-5
[size_upload] => 0
[size_download] => 1462
[speed_download] => 836
[speed_upload] => 0
[download_content_length] => 1462
[upload_content_length] => 0
[starttransfer_time] => 0.146587
[redirect_time] => 1.6003
[redirect_url] =>
[primary_ip] => YY.YYY.YYY.YY
[certinfo] => Array
(
)
[primary_port] => 443
[local_ip] => YY.YY.YYY.YY
[local_port] => 47705
)
Still can't get the required cookie here,
Please help!
If you want to use curls given functionality you can try using CURLOPT_COOKIEJAR / CURLOPT_COOKIEFILE, to store and get your cookie. This if file based.
In this case, curl will then write any Cookie related Information in a file.
You can define where this file will be located.
By using CURLOPT_COOKIEJAR , you will tell curl that it shall capture the cookie data.
// create cookie file
$cookie = __DIR__ . "/where/you/want/to/store/your/cookie/mycookie.txt";
fopen($cookie, "w");
// you may want to use some random identicator in your cookie file
// to make sure it does not get overwritten by some action
// prepare login
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://mywebsiteurl.com/index.jsp");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// tell curl to follow redirects
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURlOPT_POSTFIELDS, "username=usernam&password=XXXXXX");
curl_setopt($ch, CURLOPT_POST, 1);
// set a jar, to store your cookie
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
$headers = array(
'Content-Type: application/x-www-form-urlencoded',
'Referrer: https://mywebsiteurl.com?ticket=unique_ticket_id'
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// do login
$loginResult = curl_exec($ch);
// check if your login has worked according to the given result by any method you want
if (preg_match("/Welcome/", $loginResult)) {
// simple regex for demonstration purpose
}
// now you could load your cookie out of the file, or just use the file for future requests
If your login has worked, you will have all information stored in your cookie file.
Now you can use that cookie again with the curlopt CURLOPT_COOKIEFILE for future requests.
// do other request, with your cookie
curl_setopt($ch, CURLOPT_URL, "https://mywebsiteurl.com/api/rest.php");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "your new post data");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
// set a jar to update your cookie if needed
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
// give curl the location of your cookie file, so it can send it
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);

cURL takes too long to load

I am calling a REST endpoint in PHP using cURL to fetch some JSON data:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
echo $result;
curl_close($ch);
It takes 2.5 seconds to fetch the data using the above code on my localhost. The same code takes around 7.5 seconds when run on the live server. When the URL is opened directly on a browser it takes only 1.5 seconds.
My question is: Why does it take so long for cURL to fetch data on the live server and how can I solve this problem?
Below is the output of curl_getinfo($ch) on the server:
Array
(
[content_type] => application/json
[http_code] => 200
[header_size] => 420
[request_size] => 113
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 7.305496
[namelookup_time] => 0.150378
[connect_time] => 0.473187
[pretransfer_time] => 0.473237
[size_upload] => 0
[size_download] => 1291504
[speed_download] => 176785
[speed_upload] => 0
[download_content_length] => -1
[upload_content_length] => 0
[starttransfer_time] => 1.787901
[redirect_time] => 0
[redirect_url] =>
[certinfo] => Array
(
)
[primary_port] => 80
[local_port] => 53962
)
I found the solution to my problem. As I had mentioned in the question, the service was loading the fastest in browsers. So, I checked the 'Request Headers' of the request in the 'Network' tab of Google Chrome Inspector. I copied those headers and used them in my cURL request in PHP. After scraping those headers I found that all I needed to do was to add an Accept-Encoding header. I passed a value of gzip like so:
curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
but setting it to an empty string also works.
curl_setopt($ch, CURLOPT_ENCODING, '');
According to the php.net manual for CURLOPT_ENCODING:
The contents of the "Accept-Encoding: " header. This enables decoding
of the response. Supported encodings are "identity", "deflate", and
"gzip". If an empty string, "", is set, a header containing all
supported encoding types is sent.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "set ur url");
curl_setopt($ch, CURLOPT_ENCODING , "gzip");
curl_setopt($ch, CURLOPT_ENCODING, '');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
Please check this example

CURL cannot run URL and return 302

I'm trying to run an URL (which have signout functionality) through the CURL. But it is returning 302 http code. Same url when i run through the POSTMAN ( Google Chrome addon ) or POSTER ( Firefox Addon) , then it is return proper result ( {"status" : "success" } ). Any help would be greatly appreciated.
URL (JAVA APPLICATION URL) : http://website.mywebsite.com:8083/VideoBook/signout.action
MY CODE :
// Open log file
$logfh = fopen("GeoserverPHP.log", 'w') or die("can't open log file");
// Initiate cURL session
$service = "http://website.mywebsite.com:8083/VideoBook/";
$request = "signout.action";
$url = $service . $request;
$ch = curl_init($url);
// Optional settings for debugging
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_STDERR, $logfh);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_REFERER, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, true);
curl_setopt($ch, CURLOPT_COOKIEFILE, true);
//Required GET request settings
// $passwordStr = "geosolutions:Geos";
// curl_setopt($ch, CURLOPT_USERPWD, $passwordStr);
//GET data
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/json"));
//GET return code
$successCode = 200;
$buffer = curl_exec($ch);
echo "CURL INFO : <BR/> " ;
print_r(curl_getinfo($ch));
echo "CURL OUTPUT : <BR/> " ;
print_r($buffer);
// Check for errors and process results
$info = curl_getinfo($ch);
if ($info['http_code'] != $successCode) {
$msgStr = "# Unsuccessful cURL request to ";
$msgStr .= $url." [". $info['http_code']. "]\n";
fwrite($logfh, $msgStr);
} else {
$msgStr = "# Successful cURL request to ".$url."\n";
fwrite($logfh, $msgStr);
}
fwrite($logfh, $buffer."\n");
curl_close($ch);
fclose($logfh);
OUTPUT IN BROWSER :
CURL INFO :
Array
(
[url] => http://website.mywebsite.com:8083/VideoBook/signout.action
[content_type] =>
[http_code] => 302
[header_size] => 254
[request_size] => 105
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.58976
[namelookup_time] => 0.004162
[connect_time] => 0.297276
[pretransfer_time] => 0.297328
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => 0
[upload_content_length] => 0
[starttransfer_time] => 0.589739
[redirect_time] => 0
[redirect_url] => https://hpecp.mywebsite.com:8443/cas/login?service=http%3A%2F%2Fwebsite.mywebsite.com%3A8083%2FVideoBook%2Flogin.action
[primary_ip] => 125.21.227.2
[certinfo] => Array
(
)
[primary_port] => 8083
[local_ip] => 10.0.0.8
[local_port] => 50710
)
CURL OUTPUT :
LOG File Details :
* Hostname was NOT found in DNS cache
* Trying 125.21.227.2...
* Connected to website.mywebsite.com (125.21.227.2) port 8083 (#0)
> GET /VideoBook/signout.action HTTP/1.1
Host: website.mywebsite.com:8083
Accept: application/json
< HTTP/1.1 302 Moved Temporarily
* Server Apache-Coyote/1.1 is not blacklisted
< Server: Apache-Coyote/1.1
< Location: https://hpecp.mywebsite.com:8443/cas/login?service=http%3A%2F%2Fwebsite.mywebsite.com%3A8083%2FVideoBook%2Flogin.action
< Content-Length: 0
< Date: Tue, 20 May 2014 06:02:29 GMT
<
* Connection #0 to host website.mywebsite.com left intact
* Issue another request to this URL: 'https://hpecp.mywebsite.com:8443/cas/login?service=http%3A%2F%2Fwebsite.mywebsite.com%3A8083%2FVideoBook%2Flogin.action'
* Hostname was NOT found in DNS cache
* Trying 15.126.214.121...
* Connected to hpecp.mywebsite.com (15.126.214.121) port 8443 (#1)
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* Unknown SSL protocol error in connection to hpecp.mywebsite.com:8443
* Closing connection 1
# Unsuccessful cURL request to http://website.mywebsite.com:8083/VideoBook/signout.action [302]
try to add ssl verify false and follow location and now all set
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
//output:-
CURL INFO :
Array ( [url] => https://exampl.com:8443/cas/login?service=http%3A%2F%2Fexample%3A8083%2FVideoBook%2Flogin.action [content_type] => text/html;charset=UTF-8 [http_code] => 200 [header_size] => 593 [request_size] => 273 [filetime] => -1 [ssl_verify_result] => 18 [redirect_count] => 1 [total_time] => 3.073 [namelookup_time] => 0 [connect_time] => 0.577 [pretransfer_time] => 1.794 [size_upload] => 0 [size_download] => 8003 [speed_download] => 2604 [speed_upload] => 0 [download_content_length] => 8003 [upload_content_length] => -1 [starttransfer_time] => 2.387 [redirect_time] => 0.686 )
You so need to check auth credentials on your end
I think, adding these three parameter CURLOPT_REFERER, CURLOPT_COOKIEJAR, CURLOPT_COOKIEFILE and an valid cookie file can solve this. I didn't tested the code.
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
Do the job.
In order to log out of any kind of session, you first need to be logged in, so the service must be expecting some reference to an existing session.
Either it expects you to give it information about which user should be logged out, or it is intended to log your script out after a series of calls to other services.
What it cannot do is automatically log out the user who is accessing your page, because it has no way of seeing them. The request originates entirely on your server, and only contains the information you pass to it with CURL. Nor will you be able to give it the information a browser would have, unless your script is on the same domain, as the browser will not pass your script the cookies set by the other site.

grab image using curl_exec not working on certain domain

enter code herePreviously, the below function to save image from a certain "$url" to "$saveto" was working properly. Somehow, when i try to grab this domain picture, i.e. http://pic.pimg.tw/ellenitn/4a439fc4b1c2e.jpg
It failed to work anymore (it was working 2 days ago and now it stopped working, the images saved is all 0kb)
function grab_image($url,$saveto)
{
$ch = curl_init ($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
$raw=curl_exec($ch);
curl_close ($ch);
if(file_exists($saveto)){
unlink($saveto);
}
$fp = fopen($saveto,'x');
$var = fwrite($fp, $raw);
fclose($fp);
return $var;
}
Can I know how to go around debugging this? I have tried file_get_contents(), but it failed to work as well, code error -> php_network_getaddresses: getaddrinfo failed: Name or service not known.
Edited:
When I use:
print_r(curl_getinfo($ch));
I got this information:
Array (
[url] => http://pic.pimg.tw/ellenitn/4a439fc4b1c2e.jpg
[content_type] =>
[http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => 0
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0
[namelookup_time] => 0
[connect_time] => 0
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => -1
[upload_content_length] => -1
[starttransfer_time] => 0
[redirect_time] => 0
[certinfo] => Array ( )
[primary_ip] =>
[redirect_url] =>
)
The given URL returns an "unknown host" error.
As from your code, you are not doing any error handling. Suppose the following:
the server name is wrong (as the above url)
the server doesn't respond
the server gives an error (http 50x)
the link is not an image
the link is gone (http 40x)
you need to catch all of the above in order to be sure to actually got at least what you want before starting to save something to a file.
As from your try:
I have tried file_get_contents(), but it failed to work as well, code
error -> php_network_getaddresses: getaddrinfo failed: Name or service
not known.
you are getting the proper error message already. file_get_contents()will give you all needed control to handle such errors.
1: Downloading a file and saving it with file_put_contents()
<?php
$url = 'http://pic.pimg.tw/ellenitn/4a439fc4b1c2e.jpg;
$savepath = '/local/path/to/4a439fc4b1c2e.jpg'; //make sure you have write permissions on "/local/path/to/"
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$data = curl_exec($ch);
curl_close($ch);
file_put_contents($savepath, $data);
?>
2: Use cURL to download straight to a file stream
<?php
$url = 'http://pic.pimg.tw/ellenitn/4a439fc4b1c2e.jpg';
$savepath = '/local/path/to/4a439fc4b1c2e.jpg';
$fp = fopen($savepath, 'w');
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FILE, $fp);
$data = curl_exec($ch);
curl_close($ch);
fclose($fp);
?>

CURL with PHP - Very slow

All,
I have to request a URL which returns a JSON request. I am using PHP and CURL to do this. Currently it takes around 3-4 seconds for the request and response.
Following is the curl code
$ch = curl_init();
$devnull = fopen('/tmp/curlcookie.txt', 'w');
curl_setopt($ch, CURLOPT_STDERR, $devnull);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, $desturl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
$ret = curl_exec($ch);
curl_close($ch);
if ($devnull)
{
fclose($devnull);
}
Following is the CURL_GETINFO array
Array
(
[url] => https://xx.xx.xxx.xx/portalsite/tester
[content_type] => application/json
[http_code] => 200
[header_size] => 198
[request_size] => 835
[filetime] => -1
[ssl_verify_result] => 20
[redirect_count] => 0
[total_time] => 2.054561
[namelookup_time] => 6.5E-5
[connect_time] => 0.016048
[pretransfer_time] => 0.123947
[size_upload] => 699
[size_download] => 46735
[speed_download] => 22746
[speed_upload] => 340
[download_content_length] => 0
[upload_content_length] => 0
[starttransfer_time] => 1.743973
[redirect_time] => 0
)
How can I speed up the CURL processing time?
Thanks
According to this answer (similar problem) cURL can be slow if you are on Mac OS X and you access to your project with xxxx.local (with 127.0.0.1 myproject.localin your /etc/hosts/
As #lepix said:
It is because the .local tld is reserved for Bonjour service, and this
since Mac OS X Lion (10.7).
Hope it will help, thanks to lepix.
it looks like most of the time is waiting for the server to respond (starttransfer_time - pretransfer_time = 1.620026)... maybe the server is doing some database or other operation that takes time?
I had some problem like that, using wget it was fast (1 second max), using cURL it took about 5 seconds to get the page, when tcpdump-ing I have found that cURL try to do a revers DNS lookup, and if the server doesn't have the revers DNS registred it will slow you down, I set up an reverse DNS on my local DNS server so every request to that site using cURL now goes very fast. I didn't find a way to disable revers DNS lookup from cURL settings.
My sugestion is to scan your trafic to see where it is waiting so long.

Categories