Skip to content

HTTPClientLifecycleEventReceiver

[Source]

HTTP response lifecycle callbacks delivered to the client actor.

All callbacks have default no-op implementations. Override only the callbacks your actor needs. Callbacks are invoked synchronously inside the actor that owns the HTTPClientConnection.

Typical usage: override on_connected() to send the first request, on_response() and on_body_chunk() to process the response, and on_response_complete() to send follow-up requests or close.

trait ref HTTPClientLifecycleEventReceiver

Public Functions

on_connected

[Source]

Called when the connection is ready for application data.

For plain TCP connections, this fires after TCP connect. For SSL connections, this fires after the TLS handshake completes. Safe to call send_request() from this callback.

fun ref on_connected()
: None val

Returns


on_connection_failure

[Source]

Called when a connection attempt fails.

The reason indicates which stage failed: DNS resolution, TCP connect, SSL handshake, or connection timeout. The connection is unusable after this callback.

fun ref on_connection_failure(
  reason: (ConnectionFailedDNS val | ConnectionFailedTCP val | ConnectionFailedSSL val | 
    ConnectionFailedTimeout val))
: None val

Parameters

Returns


on_response

[Source]

Called when the response status line and all headers have been parsed.

For responses with a body, on_body_chunk() calls follow. For responses without a body (HEAD, 204, 304), on_response_complete() is called immediately after.

fun ref on_response(
  response: Response val)
: None val

Parameters

Returns


on_body_chunk

[Source]

Called for each chunk of response body data as it arrives.

Body data is delivered incrementally. Accumulate chunks manually if you need the complete body before processing.

fun ref on_body_chunk(
  data: Array[U8 val] val)
: None val

Parameters

Returns


on_response_complete

[Source]

Called when the entire response (including any body) has been received.

After this call, the connection is ready for another send_request() (connection reuse / keep-alive).

fun ref on_response_complete()
: None val

Returns


on_parse_error

[Source]

Called when a response parse error is encountered.

The connection is closed after this callback. No further callbacks will be delivered except on_closed().

fun ref on_parse_error(
  err: (TooLarge val | InvalidStatusLine val | InvalidVersion val | 
    MalformedHeaders val | InvalidContentLength val | InvalidChunk val | 
    BodyTooLarge val))
: None val

Parameters

Returns


on_closed

[Source]

Called when the connection closes.

Fires on remote disconnect, local close, idle timeout, or any other reason. Not called if the connection fails before connecting (use on_connection_failure for that case).

fun ref on_closed()
: None val

Returns


on_throttled

[Source]

Called when backpressure is applied on the connection.

The TCP send buffer is full — avoid sending more requests until on_unthrottled() is called.

fun ref on_throttled()
: None val

Returns


on_unthrottled

[Source]

Called when backpressure is released on the connection.

The TCP send buffer has drained — request sending may resume.

fun ref on_unthrottled()
: None val

Returns