Reputation: 8372
In PHP (v5), is there a way to make multiple requests on an open curl connection?
I'm noticing that my big bottleneck is the timeout/teardown of the connection its self (i'm making lots of small data requests that finish quickly), so I would like to be able to do something like open
init curl connection,
set url/params, do request, get results set url/params, do request, get results
close curl
I just dont know if this is possible at all.
Upvotes: 1
Views: 2029
Reputation: 321854
You should be able to do this by adding Keep-alive
headers:
$headers = array
(
"Keep-alive: 300",
"Connection: keep-alive",
// ... other headers...
);
curl_setopt($this->curl_handle, CURLOPT_HTTPHEADER, $headers);
Upvotes: 0
Reputation: 288280
Probably the curl_multi_*
functions are what you are looking for.
Upvotes: 1