What happens when you use a negative curl timeout?
$curlOptions[CURLOPT_TIMEOUT] = -2;
Does it get transformed into positive 2, or remains -2?
Because, sometimes curl works, sometimes doesn't...
This is how curl works:
First it connects to the url that you provide.
Then it perform the overall curl operation for the amount of seconds you have specified through the CURLOPT_TIMEOUT
option.
So if you set the CURLOPT_TIMEOUT
as -2 it will never execute after connecting to the host. To verify this, run the script by enabling the CURLOPT_VERBOSE
option. And you'll get the following msg always.
* Operation timed out after -2000 milliseconds with 0 bytes received