Skip to content

SwooleResponseWriterInterface

The slice of \Swoole\Http\Response the emitter needs, so the emitter can be tested against a recording double on a machine with no ext-swoole.

interface SwooleResponseWriterInterface

Implemented bySwooleResponseWriter
SourceSwooleResponseWriterInterface.php
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

abstract 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 SwooleResponseWriterInterface::write().

ParameterTypeDescription
$bodystring

abstract 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>`

abstract public function status(int $code): void

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

ParameterTypeDescription
$codeint

abstract public function write(string $chunk): bool

ParameterTypeDescription
$chunkstring

Returns bool — False once the client is gone, which ends a stream early.