class HttpTransport implements Transport, StreamsMessages

Properties

protected bool $streaming
protected null|list<string> $messages

Methods

__construct(Request $request, Closure|null $handler = null, string|null $reply = null, Closure|null $stream = null)

Create an HTTP transport for one request.

void
onReceive(Closure $handler)

Register the incoming message handler.

void
send(string $message)

Send an encoded protocol message.

run()

Dispatch the request and transfer stream ownership to its response.

int
statusCode()

Determine the status of a non-streaming response.

void
stream(Closure $stream)

Register a streaming callback.

void
streamMessages(Closure $producer, bool $cancelOnDisconnect)

Stream messages with the negotiated protocol's disconnect behavior.

messageStream(Closure $producer)

Yield messages after each producer advancement without retaining its callback.

streamPayloads(iterable $messages)

Frame direct generator output without bypassing the message hook.

drainMessages()

Drain messages before advancing the producer again.

void
sendStreamMessage(string $message)

Write one event to a callback-based stream.

array
getHeaders()

Return the response headers for the current delivery mode.

Details

at line 30
__construct(Request $request, Closure|null $handler = null, string|null $reply = null, Closure|null $stream = null)

Create an HTTP transport for one request.

Parameters

Request $request
Closure|null $handler
string|null $reply
Closure|null $stream

at line 41
void onReceive(Closure $handler)

Register the incoming message handler.

Parameters

Closure $handler

Return Value

void

at line 49
void send(string $message)

Send an encoded protocol message.

Parameters

string $message

Return Value

void

at line 63
run()

Dispatch the request and transfer stream ownership to its response.

at line 113
protected int statusCode()

Determine the status of a non-streaming response.

Return Value

int

at line 140
void stream(Closure $stream)

Register a streaming callback.

The callback may echo SSE-formatted output directly or return an iterable of message payloads.

Parameters

Closure $stream

Return Value

void

at line 150
void streamMessages(Closure $producer, bool $cancelOnDisconnect)

Stream messages with the negotiated protocol's disconnect behavior.

Parameters

Closure $producer
bool $cancelOnDisconnect

Return Value

void

at line 173
protected Generator messageStream(Closure $producer)

Yield messages after each producer advancement without retaining its callback.

Parameters

Closure $producer

Return Value

Generator

at line 196
protected Generator streamPayloads(iterable $messages)

Frame direct generator output without bypassing the message hook.

Parameters

iterable $messages

Return Value

Generator

at line 212
protected Generator drainMessages()

Drain messages before advancing the producer again.

Return Value

Generator

at line 247
protected void sendStreamMessage(string $message)

Write one event to a callback-based stream.

Parameters

string $message

Return Value

void

at line 263
protected array getHeaders()

Return the response headers for the current delivery mode.

Return Value

array