I have the CURL request below, and it is returning a 504 error. I want to echo out the fact that it is timing out to the UI, right now the UI isn't notified, but the Chrome console is. Is there a way I can grab the 504 and drop it in an if statement:
if ($error == 504) {
// tell the UI it timed out
} else {
// report the response
}
Right now I am using:
curl_getinfo($curl, CURLINFO_HTTP_CODE)
but it doesn't seem to grab the 504, probably because there was no response.
curl_setopt_array($curl, array(
CURLOPT_URL => $endpoint,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 60000,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_USERAGENT => $userAgent,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLINFO_HEADER_OUT => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Authorization: Basic xxx'
),
));