function parse_response in Lockr 7.3
Parses a response message string into a response object.
Parameters
string $message Response message string.:
Return value
File
- vendor/
guzzlehttp/ psr7/ src/ functions.php, line 495
Namespace
GuzzleHttp\Psr7Code
function parse_response($message) {
$data = _parse_message($message);
// According to https://tools.ietf.org/html/rfc7230#section-3.1.2 the space
// between status-code and reason-phrase is required. But browsers accept
// responses without space and reason as well.
if (!preg_match('/^HTTP\\/.* [0-9]{3}( .*|$)/', $data['start-line'])) {
throw new \InvalidArgumentException('Invalid response string: ' . $data['start-line']);
}
$parts = explode(' ', $data['start-line'], 3);
return new Response($parts[1], $data['headers'], $data['body'], explode('/', $parts[0])[1], isset($parts[2]) ? $parts[2] : null);
}