public function Response::__construct

Same name in this branch

Constructor.

@api

Parameters

string $content The response content:

integer $status The response status code:

array $headers An array of response headers:

4 calls to Response::__construct()
JsonResponse::__construct in drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/JsonResponse.php
Constructor.
RedirectResponse::__construct in drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RedirectResponse.php
Creates a redirect response so that it conforms to the rules defined for a redirect status code.
ResourceResponse::__construct in drupal/core/modules/rest/lib/Drupal/rest/ResourceResponse.php
Constructor for ResourceResponse objects.
StreamedResponse::__construct in drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/StreamedResponse.php
Constructor.
4 methods override Response::__construct()
JsonResponse::__construct in drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/JsonResponse.php
Constructor.
RedirectResponse::__construct in drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RedirectResponse.php
Creates a redirect response so that it conforms to the rules defined for a redirect status code.
ResourceResponse::__construct in drupal/core/modules/rest/lib/Drupal/rest/ResourceResponse.php
Constructor for ResourceResponse objects.
StreamedResponse::__construct in drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/StreamedResponse.php
Constructor.

File

drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php, line 136

Class

Response
Response represents an HTTP response.

Namespace

Symfony\Component\HttpFoundation

Code

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