Skip to content

HTTPClientConnectionActor

[Source]

Trait for actors that make HTTP client connections.

Extends TCPConnectionActor (for lori ASIO plumbing) and HTTPClientLifecycleEventReceiver (for HTTP-level callbacks). The actor stores an HTTPClientConnection as a field and implements _http_client_connection() to return it. All other required methods have default implementations that delegate to the protocol.

Minimal implementation:

actor MyClient is HTTPClientConnectionActor
  var _http: HTTPClientConnection = HTTPClientConnection.none()

  new create(auth: lori.TCPConnectAuth, host: String, port: String,
    config: ClientConnectionConfig)
  =>
    _http = HTTPClientConnection(auth, host, port, this, config)

  fun ref _http_client_connection(): HTTPClientConnection => _http

  fun ref on_connected() =>
    let request = HTTPRequest(GET, "/")
    _http.send_request(request)

  fun ref on_response(version: Version, status: U16,
    reason: String val, headers: Headers val)
  =>
    // process response
    None

For HTTPS, use HTTPClientConnection.ssl(auth, ssl_ctx, host, port, this, config) instead of HTTPClientConnection(auth, host, port, this, config).

The none() default ensures all fields are initialized before the constructor body runs, so this is ref when passed to HTTPClientConnection.create() or HTTPClientConnection.ssl().

trait tag HTTPClientConnectionActor is
  TCPConnectionActor tag,
  HTTPClientLifecycleEventReceiver ref

Implements


Public Behaviours

dispose

[Source]

be dispose()

Public Functions

on_connected

[Source]

fun ref on_connected()
: None val

Returns


on_connection_failure

[Source]

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

Parameters

Returns


on_response

[Source]

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

Parameters

Returns


on_body_chunk

[Source]

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

Parameters

Returns


on_response_complete

[Source]

fun ref on_response_complete()
: None val

Returns


on_parse_error

[Source]

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]

fun ref on_closed()
: None val

Returns


on_throttled

[Source]

fun ref on_throttled()
: None val

Returns


on_unthrottled

[Source]

fun ref on_unthrottled()
: None val

Returns