All URI, networking, and communication errors are using negative, 0, or NULL status codes.
In various locations, drupal_http_request() ensures this by negating a potential status code:
// When a network error occurs, we use a negative number so it does not
// clash with the HTTP status codes.
$result->code = -$errno;
This was consistent until #156582: drupal_http_request() should support timeout setting came, which added:
/**
* Error code indicating that the request made by drupal_http_request() exceeded
* the specified timeout.
*/
define('HTTP_REQUEST_TIMEOUT', 1);
and directly returns:
if ($info['timed_out']) {
$result->code = HTTP_REQUEST_TIMEOUT;
$result->error = 'request timed out';
return $result;
}
All application-level error handling logic that previously checked for
// Catch 0, NULL, and any negative status code (networking errors).
if ($response->code <= 0) exit;
now has to additionally check for the custom Drupalism and non-existing status code 1.
Comments
Comment #1
sunComment #2
damien tournoud commentedComment #3
dries commentedCommitted to 8.x and 7.x. For 6.x we need to adjust #156582: drupal_http_request() should support timeout setting.
Comment #4
sunComment #5
c960657 commentedDoesn't this collide with the $errno returned by fsockopen() ?