You are here

function parse_response in Auth0 Single Sign On 8.2

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 495

Namespace

GuzzleHttp\Psr7

Code

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);
}