public function Response::__construct

Same name in this branch

Construct the response

Parameters

string $statusCode The response status code (e.g. 200, 404, etc):

Collection|array $headers The response headers:

string|resource|EntityBodyInterface $body The body of the response:

Throws

BadResponseException if an invalid response code is given

File

drupal/core/vendor/guzzle/http/Guzzle/Http/Message/Response.php, line 158

Class

Response
Guzzle HTTP response object

Namespace

Guzzle\Http\Message

Code

public function __construct($statusCode, $headers = null, $body = null) {
  $this
    ->setStatus($statusCode);
  $this->params = new Collection();
  $this->body = EntityBody::factory($body !== null ? $body : '');
  if ($headers) {
    if (!is_array($headers) && !$headers instanceof Collection) {
      throw new BadResponseException('Invalid headers argument received');
    }
    foreach ($headers as $key => $value) {
      $this
        ->addHeaders(array(
        $key => $value,
      ));
    }
  }
}