CURL starttransfer_time execution slow - php

I have a php page that does an order lookup. In the order summary page, I do a while loop to bring up all of the orders. Normally doing this is just fine and isn't an issue. Recently I decided to add the ability to see an order "status" based on its JIRA issue/ticket status. So for instance, if the JIRA ticket state is open, then the order status is "open" as well. If it the JIRA ticket is closed, the order status is "closed" as well.
The way I am doing JIRA ticket lookups is via a CURL GET request. Here is an example of the code:
// CHECK JIRA TICKET
$username = 'xxxx';
$password = 'xxxx';
$proxy = 'http://xxxx.xxxx.xxxx:8080/';
$url = "http://xxxx.xxxx.xxxx/rest/api/2/issue/".$row['jira_ticket']."?fields=status";
$ch = curl_init();
$headers = array(
'Accept: application/json',
'Content-Type: application/json'
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_POST, false);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
$ticket_result = curl_exec($ch);
curl_close($ch);
In order for me to get a JIRA ticket status for each order, I am running this CURL GET request within a while loop. Example of code:
$results = mysqli query...;
while ($row = mysqli_fetch_array($results))
{
....define some variables
....the CURL code
....etc
}
The issue I am having is that the more orders I have, the longer it takes to load the page. I know for certain this is due to the CURL GET request within the while loop, because if I remove it, then the page loads quickly. When I debug the CURL request, the longest time I am seeing is starttransfer_time. Example:
[http_code] => 405
[header_size] => 639
[request_size] => 239
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.294348
[namelookup_time] => 0.004216
[connect_time] => 0.004885
[pretransfer_time] => 0.004928
[size_upload] => 0
[size_download] => 1013
[speed_download] => 3441
[speed_upload] => 0
[download_content_length] => 1013
[upload_content_length] => -1
[starttransfer_time] => 0.294315
[redirect_time] => 0
Sometimes it can go up to .5 seconds. So my question...is there any way I can speed up the CURL request? If not, is there a better way to approach what I'm attempting to do?
EDIT:
I have a workaround, though not really an answer. For the time being I will just store the "order status" as a column in MySQL, and have the actual JIRA CURL request in a different file run as a background cron job that runs every so often. It's not perfect, but at least this allows for the pages to come up much quicker.

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);

Issue using PHP cURL with the Streamable API

I am hoping to build a video upload using the Streamable API and PHP with cURL. https://streamable.com/documentation#upload-video-file
What I'm trying to accomplish is:
User fills out a form of info and selects a video file from their computer/device to upload
Submits the form, PHP handles it from there to talk to the Streamable API to upload the video via the form to my Streamable account, then return the shortcode from Streamable for me to store in a MySQL database with the rest of their info
I've tried, with success, using the curl command via terminal. But, I'm having issues with pulling it off via php form submission.
This is an example of the command I used in terminal to upload, which worked:
curl https://api.streamable.com/upload -u my_email:my_pass -F file=#path/to/file.mp4
With PHP, I have a pretty simple cURL script thanks to the tons of help online. I guess you could say I'm pretty new to using cURL.
$url = 'https://api.streamable.com/upload -u my_email.com:my_pass -F file=#path/to/file.mp4';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
With that, I'm getting a HTTP 400 error.
https://streamable.com/documentation#errors
..codes in the 400 range indicate client errors...
I guess that's what's messing me up here?
I tried it this way, but I get the same error.
$pass = 'my_email:my_pass';
$postFields = array(
'file' => '/path/to/file.mp4',
'title' => 'Example Title'
);
$url = 'https://api.streamable.com/upload';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_USERPWD, $pass);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
I used print_r(curl_getinfo($ch)); to see what's happening, and this is what it's spitting out - maybe this can be useful for some help:
Array ( [url] => https://api.streamable.com/upload
-u my_email:my_pass -F file=#/Path/to/file.mp4 [content_type] => [http_code] => 400 [header_size] => 66 [request_size] => 277 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.36033 [namelookup_time] => 0.00138 [connect_time] => 0.082871 [pretransfer_time] => 0.283219 [size_upload] => 0 [size_download] => 0 [speed_download] => 0 [speed_upload] => 0 [download_content_length] => 0 [upload_content_length] => 275 [starttransfer_time] => 0.36031 [redirect_time] => 0 [redirect_url] => [primary_ip] => xx.xx.xxx.xxx [certinfo] => Array ( ) [primary_port] => 443 [local_ip] => 192.168.0.1 [local_port] => 57288 )
There are couple of things you need to change here:
Set CURLOPT_SSL_VERIFYPEER to false. It can be used to verify peer's certificate. If we specify it as false, it will accept any server(peer) certificate.
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
Here's a good read on the implication of turning CURLOPT_SSL_VERIFYPEER on and off, If CURLOPT_SSL_VERIFYPEER is false, is the data transfer no longer secure?
CURLOPT_POSTFIELDS is used to specify full data we want to submit with the POST request. The $postFields array should be converted to URL-encoded query string using http_build_query() function, so that it could be sent as application/x-www-form-urlencoded.
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postFields));
Try this:
$fields = array("file"=>curl_file_create("video.mp4"));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.streamable.com/upload");
curl_setopt($ch, CURLOPT_USERPWD, "email:pass");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields );
$result = curl_exec($ch);
I think curl_file_create makes the trick, it seems using #fileName no more work for PHP 5.5+

PHP Curl upload_content_length greater than filesize

I'm working on a script to upload files to http://imagerelay.com. This is my first time using a REST API and cURL with PHP. There are two phases to the upload. First you submit metadata to the ImageRelay which includes the filesize for your local file. This returns an ID number which you use to build the URL for uploading the chunks (using CLI 'split' to generate). However, when I upload a file using cURL there are an extra 219 bytes added to each file. I suspect this is related to how cURL works, but I'm not sure how to correct the overage without manually increasing the filesize in phase 1 by 219bytes * x number of chunks.
Here is the response array received from the cURL request. The actual file chunk size is 1M (1,048,576 bytes), whereas the response shows 219 bytes more at 1048795
[http_code] => 201
[header_size] => 583
[request_size] => 346
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 2.039208
[namelookup_time] => 1.2E-5
[connect_time] => 0.040014
[pretransfer_time] => 0.13825
[size_upload] => 1048795
[size_download] => 1
[speed_download] => 0
[speed_upload] => 514314
[download_content_length] => 1
[upload_content_length] => 1048795
[starttransfer_time] => 0.182222
Here's the relevant section of the code. $file represents the chunk, and $resource is pre-determined as it increments each chunk.
$ch = curl_init( $resource );
curl_setopt($ch, CURLOPT_POST, true );
$pdfData = array( 'file' => new CurlFile( "file-chunks/{$file}", 'application/octet-stream') );
curl_setopt($ch, CURLOPT_POSTFIELDS, $params );
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
I appreciate any help that can be provided. I've been working on this for a week and scouring the internet but I can't figure out why the filesize of the chunk doesn't match the upload_content_length or size_upload. I do not have the same issue when doing this over the command line with curl (and not PHP over CLI). Thank you!
[edit]Removed typo in first sentence (accidental paste!)[/edit]
[edit2]Added bounty[/edit]
Try to send file like this
$headers = array(
'Content-Type: multipart/form-data'
);
$file = "/full/path/to/file.pdf"; // Full path to file
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
curl_close($ch);
Try to use the option CURLOPT_VERBOSE and check STDERR to see the complete payload.
You can also try to use WireShark to check what goes on the wire.
(It could be scary at first but fairly easy to use).

Access Exchange Web Services with PHP and cURL

Hello,
I am currently writing a client to access a Microsoft Exchange server and read contacts, appointments etc. from it.
Through days of searching I've been able to connect to the EWS via PHP's Soap client and a custom HTTPS Stream wrapper. This website helped me greatly at this point.
Everything worked fine on my Windows 7 machine using XAMPP
Now I uploaded my project to a Debian 6.0 Squeeze development machine that has exactly the same configuration as my Windows machine regarding the web-server, php settings, mysql settings etc. but it just wont work anymore
The debian machine can resolve and ping the exchange server without problems
I nailed the actual problem down to a point, where cURL isn't able to retrieve the WSDL file of the EWS
It always receives an empty response and a 401 (Unauthorized) status code
The credentials I use are correct, the same credentials work on my windows machine
I extracted the faulty piece of code and tried running it stand-alone, it looks like this:
echo "Trying to get https://".$cfg[ 'Exchange.Server' ]."/EWS/Services.wsdl<br>";
$curl = curl_init( 'https://'.$cfg[ 'Exchange.Server' ].'/EWS/Services.wsdl' );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 );
curl_setopt( $curl, CURLOPT_HTTPAUTH, CURLAUTH_NTLM );
curl_setopt( $curl, CURLOPT_USERPWD, $cfg[ 'Exchange.User' ].':'.$cfg[ 'Exchange.Password' ] );
curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $curl, CURLOPT_SSL_VERIFYHOST, false );
echo '<pre>';
$response = curl_exec( $curl );
$info = curl_getinfo( $curl );
var_dump( $info );
var_dump( $response );
curl_close( $curl );
The result I receive here is the mentioned 401 status code and an empty response
When I call the same url in my browser or with the same code on my windows machine, I get the WSDL file I want
Actually I can't even tell if this is a linux-based problem or if I do something wrong at some point, I'm struggling with this for 2 days now.
Is there someone that may be able to find my mistake or tell me the reason why it doesn't work?
I may provide any further needed information on demand
If you initialize your soap client properly, you should be able to preform any requests requests this way:
$curl = curl_init($location); //'https://'.$server_address.'/EWS/Exchange.asmx'
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); //valid soap headers with keep-alive
curl_setopt($ch, CURLOPT_POST, true );
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_USERPWD, $user.':'.$password);
$response = curl_exec($curl);
As to your code, try commenting out following line:
curl_setopt( $curl, CURLOPT_HTTPAUTH, CURLAUTH_NTLM );
Also take a look wherever this wrapper works on your setup:
http://ewswrapper.lafiel.net/
If it does, take a look at SOAP classes used there - it uses php built-in as base.
Why can't you store wsdl file locally anyways?
UPDATE:
Ok, I played around with this in my Debian box and this works for me flawlessly:
$domain = 'xxxxxx';
$user = 'xxxxxx';
$password = 'xxxxxx';
$ch = curl_init('https://'.$domain.'/EWS/Services.wsdl');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_USERPWD, $user.':'.$password);
$response = curl_exec($ch);
$info = curl_getinfo( $ch );
$error = curl_error ($ch);
print_r(array($response,$info,$error));
returns
Array
(
[0] => <?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions
(...)
</wsdl:definitions>
[1] => Array
(
[url] => xxxxx/EWS/Services.wsdl
[content_type] => text/xml
[http_code] => 200
[header_size] => 250
[request_size] => 147
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.60574
[namelookup_time] => 0.165249
[connect_time] => 0.268173
[pretransfer_time] => 0.474009
[size_upload] => 0
[size_download] => 55607
[speed_download] => 91800
[speed_upload] => 0
[download_content_length] => 55607
[upload_content_length] => 0
[starttransfer_time] => 0.580931
[redirect_time] => 0
[certinfo] => Array
(
)
[redirect_url] =>
)
[2] =>
)
Your first check should not use any complex scripting.
Instead try opening the WDSL from a simple browser window on the Debian machine like so:
https://your.exchange-server.com/EWS/Services.wsdl
If that does not work there are probably access restrictions in place that depend on the client IP or client network (e.g. your development machine being in a trusted network, your Debian not). The fact that you get a 401 ("Unauthorized" - request requires user authentication) suggests that there is no problem with contacting the server but with authentication.
Another check I suggest is that you have a look into your phpinfo() to make sure your PHP installation on Debian is capable of handling HTTP*S* requests. Make sure, OpenSSL is installed!
This article helped point me in the right direction. One thing to keep in mind is that
your PHP installation may not be sharing your system's cURL / libcurl setup.
http://blog.ianty.com/ubuntu/exchange-web-services-ews-ntlmv2-and-linux/

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