You are here

public function Response::__construct in RESTful 7.2

Constructor.

Parameters

mixed $content: The response content, see setContent()

int $status: The response status code

array $headers: An array of response headers

Throws

UnprocessableEntityException When the HTTP status code is not valid

File

src/Http/Response.php, line 134
Contains \Drupal\restful\Http\Response.

Class

Response

Namespace

Drupal\restful\Http

Code

public function __construct($content = '', $status = 200, $headers = array()) {
  $this->headers = new HttpHeaderBag($headers);
  $this
    ->setContent($content);
  $this
    ->setStatusCode($status);
  $this
    ->setProtocolVersion('1.0');
  if (!$this->headers
    ->has('Date')) {
    $this
      ->setDate(new \DateTime(NULL, new \DateTimeZone('UTC')));
  }
}