Curl sends the keep-alive header by default, but:
- create a context using
curl_init()
without any parameters. - store the context in a scope where it will survive (not a local var)
- use
CURLOPT_URL
option to pass the url to the context - execute the request using
curl_exec()
- don't close the connection with
curl_close()
very basic example:
function get($url) {
global $context;
curl_setopt($context, CURLOPT_URL, $url);
return curl_exec($context);
}
$context = curl_init();
//multiple calls to get() here
curl_close($context);
No comments:
Post a Comment