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

Breadcrumb

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

function StreamedJsonResponse::__construct

Parameters

mixed[] $data JSON Data containing PHP generators which will be streamed as list of data or a Generator:

int $status The HTTP status code (200 "OK" by default):

array<string, string|string[]> $headers An array of HTTP headers:

int $encodingOptions Flags for the json_encode() function:

Overrides StreamedResponse::__construct

File

vendor/symfony/http-foundation/StreamedJsonResponse.php, line 55

Class

StreamedJsonResponse
StreamedJsonResponse represents a streamed HTTP response for JSON.

Namespace

Symfony\Component\HttpFoundation

Code

public function __construct(iterable $data, int $status = 200, array $headers = [], int $encodingOptions = JsonResponse::DEFAULT_ENCODING_OPTIONS) {
    parent::__construct($this->stream(...), $status, $headers);
    if (!$this->headers
        ->get('Content-Type')) {
        $this->headers
            ->set('Content-Type', 'application/json');
    }
}

API Navigation

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