Skip to content

SwooleResponseWriter

The only place in this package that touches \Swoole\Http\Response.

Pure delegation, so there is nothing here that needs testing without the extension.

final class SwooleResponseWriter implements SwooleResponseWriterInterface

ImplementsSwooleResponseWriterInterface
SourceSwooleResponseWriter.php

public function __construct(Response $response): mixed

ParameterTypeDescription
$responseResponse

Returns mixed

MethodDescription
end(string $body = ''): voidFinishes the response, optionally sending a final body.
[`header(string $name, stringlist $value): void`](#header)
status(int $code): voidSets the response status code; must be called before any body is written.
write(string $chunk): bool

public function end(string $body = ''): void

Finishes the response, optionally sending a final body.

Called once per request. After a streamed body the argument is omitted, because everything has already gone out through SwooleResponseWriter::write().

ParameterTypeDescription
$bodystring

public function header(string $name, string|list<string> $value): void

An array sends one header line per value, which is how multiple Set-Cookie headers survive.

ParameterTypeDescription
$namestring
$value`string“list<string>`

public function status(int $code): void

Sets the response status code; must be called before any body is written.

ParameterTypeDescription
$codeint

public function write(string $chunk): bool

ParameterTypeDescription
$chunkstring

Returns bool