I use this function to make cURL requests:
function curl_request($options) //single custom cURL request.
{
$ch = curl_init();
$options[CURLOPT_FOLLOWLOCATION] = true;
$options[CURLOPT_COOKIEJAR] = 'cookies.txt';
$options[CURLOPT_COOKIEFILE] = 'cookies.txt';
$options[CURLINFO_HEADER_OUT] = true;
$options[CURLOPT_VERBOSE] = true;
$options[CURLOPT_RETURNTRANSFER] = true;
$options[CURLOPT_CONNECTTIMEOUT] = 5;
$options[CURLOPT_TIMEOUT] = 5;
curl_setopt_array($ch, $options);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
The script hangs sometimes, but not always, on the $response = curl_exec($ch) line. This occurs even when the PHP script is set with infinite timeout (on the client side, Firebug takes this as "Aborted"). There is nothing in the error log.. It just doesn't get past that line when it hangs.
What could be going on? Any suggestions?
CURLOPT_COOKIEJARandCURLOPT_COOKIEFILEpointing to the same file? you're sure this is what you want? For testing I would just comment these two lines to prevent a deadlock because of file access.