Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Message.php

function Message::parseResponse

Parses a response message string into a response object.

Parameters

string $message Response message string.:

File

vendor/guzzlehttp/psr7/src/Message.php, line 227

Class

Message

Namespace

GuzzleHttp\Psr7

Code

public static function parseResponse(string $message) : ResponseInterface {
    $data = self::parseMessage($message);
    // According to https://datatracker.ietf.org/doc/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((int) $parts[1], $data['headers'], $data['body'], explode('/', $parts[0])[1], $parts[2] ?? null);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal