function _drupal_parse_response_status in Drupal 7
Splits an HTTP response status line into components.
See the status line definition in RFC 2616.
Parameters
string $respone: The response status line, for example 'HTTP/1.1 500 Internal Server Error'.
Return value
array Keyed array containing the component parts. If the response is malformed, all possible parts will be extracted. 'reason_phrase' could be empty. Possible keys:
- 'http_version'
- 'response_code'
- 'reason_phrase'
Related topics
2 calls to _drupal_parse_response_status()
- DrupalHTTPResponseStatusLineTest::testStatusLine in modules/
simpletest/ tests/ common.test - Tests parsing HTTP response status line.
- drupal_http_request in includes/
common.inc - Performs an HTTP request.
File
- includes/
common.inc, line 1142 - Common functions that many Drupal modules will need to reference.
Code
function _drupal_parse_response_status($response) {
$response_array = explode(' ', trim($response), 3);
// Set up empty values.
$result = array(
'reason_phrase' => '',
);
$result['http_version'] = $response_array[0];
$result['response_code'] = $response_array[1];
if (isset($response_array[2])) {
$result['reason_phrase'] = $response_array[2];
}
return $result;
}