class ResponseBridge

Constants

protected FORBIDDEN_TRAILER_NAMES

Trailer fields that cannot be emitted safely as HTTP trailers.

Methods

static void
send(Response $response, Response $swooleResponse, bool $withBody = true, string $protocol = 'HTTP/1.1', Request|null $request = null)

Send an HttpFoundation response through Swoole.

static void
sendStatusAndHeaders(Response $response, Response $swooleResponse)

Send status code, headers, and cookies to Swoole.

static void
sendBinaryFile(BinaryFileResponse $response, Response $swooleResponse, bool $withBody, string $protocol, Request|null $request)

Send a prepared binary file response.

static array
binaryFileState(BinaryFileResponse $response)

Read the prepared BinaryFileResponse state Symfony does not expose.

static void
streamBinaryFile(BinaryFileResponse $response, Response $swooleResponse, array $state)

Stream a prepared binary response through checked bounded writes.

static void
announceTrailers(Response $response)

Announce the trailer names known before response emission.

static void
sendTrailers(HasTrailers $response, Response $swooleResponse)

Send the final response trailers.

static array
normalizeTrailerNames(array $names)

Normalize and validate response trailer names.

static string
normalizeTrailerName(string $name)

Normalize and validate one response trailer name.

static void
sendStreamedContent(StreamedResponse $response, Response $swooleResponse)

Stream a Symfony StreamedResponse through Swoole's write() method.

static bool
sendIterableContent(IterableStreamedResponse $response, Response $swooleResponse)

Stream retained iterable chunks directly through Swoole.

static bool
sendTrailerIterableContent(IterableStreamedResponse&HasTrailers $response, Response $swooleResponse)

Stream retained iterable chunks with one-chunk trailer lookahead.

static void
sendTrailerStreamedContent(StreamedResponse&HasTrailers $response, Response $swooleResponse)

Stream a trailer-bearing callback response through an output buffer.

static void
restoreOutputBufferLevel(int $level)

Restore removable output buffers after streamed response production.

static bool
deleteBinaryFile(string $path)

Delete a binary response file.

static void
end(Response $swooleResponse, string|null $content = null)

Complete a response and require native success.

static void
sendFile(Response $swooleResponse, string $path, int $offset, int $maxlen)

Send a response file and require native success.

Details

at line 41
static void send(Response $response, Response $swooleResponse, bool $withBody = true, string $protocol = 'HTTP/1.1', Request|null $request = null)

Send an HttpFoundation response through Swoole.

Parameters

Response $response
Response $swooleResponse
bool $withBody
string $protocol
Request|null $request

Return Value

void

at line 99
static protected void sendStatusAndHeaders(Response $response, Response $swooleResponse)

Send status code, headers, and cookies to Swoole.

Parameters

Response $response
Response $swooleResponse

Return Value

void

at line 136
static protected void sendBinaryFile(BinaryFileResponse $response, Response $swooleResponse, bool $withBody, string $protocol, Request|null $request)

Send a prepared binary file response.

Parameters

BinaryFileResponse $response
Response $swooleResponse
bool $withBody
string $protocol
Request|null $request

Return Value

void

at line 236
static protected array binaryFileState(BinaryFileResponse $response)

Read the prepared BinaryFileResponse state Symfony does not expose.

Parameters

BinaryFileResponse $response

Return Value

array

at line 273
static protected void streamBinaryFile(BinaryFileResponse $response, Response $swooleResponse, array $state)

Stream a prepared binary response through checked bounded writes.

Parameters

BinaryFileResponse $response
Response $swooleResponse
array $state

Return Value

void

at line 369
static protected void announceTrailers(Response $response)

Announce the trailer names known before response emission.

Parameters

Response $response

Return Value

void

at line 399
static protected void sendTrailers(HasTrailers $response, Response $swooleResponse)

Send the final response trailers.

Parameters

HasTrailers $response
Response $swooleResponse

Return Value

void

at line 436
static protected array normalizeTrailerNames(array $names)

Normalize and validate response trailer names.

Parameters

array $names

Return Value

array

at line 462
static protected string normalizeTrailerName(string $name)

Normalize and validate one response trailer name.

Parameters

string $name

Return Value

string

at line 495
static protected void sendStreamedContent(StreamedResponse $response, Response $swooleResponse)

Stream a Symfony StreamedResponse through Swoole's write() method.

Retained iterables are consumed directly so a failed write stops their producer. Ordinary callbacks use echo, so their output is routed through a non-throwing output-buffer handler instead.

The chunk_size of 1 means the buffer flushes after every output operation that produces 1+ bytes (not per byte). A single echo "data: ...\n\n" triggers one write() call with the full string.

Removable output buffers are cleaned without spinning on a non-removable user buffer before the earliest callback, write, or end failure is rethrown.

Parameters

StreamedResponse $response
Response $swooleResponse

Return Value

void

at line 551
static protected bool sendIterableContent(IterableStreamedResponse $response, Response $swooleResponse)

Stream retained iterable chunks directly through Swoole.

Parameters

IterableStreamedResponse $response
Response $swooleResponse

Return Value

bool

at line 588
static protected bool sendTrailerIterableContent(IterableStreamedResponse&HasTrailers $response, Response $swooleResponse)

Stream retained iterable chunks with one-chunk trailer lookahead.

Parameters

IterableStreamedResponse&HasTrailers $response
Response $swooleResponse

Return Value

bool

at line 632
static protected void sendTrailerStreamedContent(StreamedResponse&HasTrailers $response, Response $swooleResponse)

Stream a trailer-bearing callback response through an output buffer.

Parameters

StreamedResponse&HasTrailers $response
Response $swooleResponse

Return Value

void

at line 708
static protected void restoreOutputBufferLevel(int $level)

Restore removable output buffers after streamed response production.

Parameters

int $level

Return Value

void

at line 724
static protected bool deleteBinaryFile(string $path)

Delete a binary response file.

Parameters

string $path

Return Value

bool

at line 732
static protected void end(Response $swooleResponse, string|null $content = null)

Complete a response and require native success.

Parameters

Response $swooleResponse
string|null $content

Return Value

void

at line 746
static protected void sendFile(Response $swooleResponse, string $path, int $offset, int $maxlen)

Send a response file and require native success.

Parameters

Response $swooleResponse
string $path
int $offset
int $maxlen

Return Value

void