You are here

function parse_response in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/guzzlehttp/psr7/src/functions.php \GuzzleHttp\Psr7\parse_response()

Parses a response message string into a response object.

Parameters

string $message Response message string.:

Return value

Response

File

vendor/guzzlehttp/psr7/src/functions.php, line 468

Namespace

GuzzleHttp\Psr7

Code

function parse_response($message) {
  $data = _parse_message($message);
  if (!preg_match('/^HTTP\\/.* [0-9]{3} .*/', $data['start-line'])) {
    throw new \InvalidArgumentException('Invalid response string');
  }
  $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);
}