Skip to content

HTTPClient

[Source]

Manages a group of HTTP connections on behalf of a client application. A client should create one instance of this class.

class ref HTTPClient

Constructors

create

[Source]

Create the context in which all HTTP sessions will originate. The handlermaker is used to create the HTTPHandler that is applied with each received payload after making a request. All requests made with one client are created using the same handler factory, if you need different handlers for different requests, you need to create different clients.

Parameters:

  • keepalive_timeout_secs: Use TCP Keepalive and check if the other side is down every keepalive_timeout_secs seconds.
new ref create(
  auth: TCPConnectAuth val,
  handlermaker: HandlerFactory val,
  sslctx: (SSLContext val | None val) = reference,
  pipeline: Bool val = true,
  keepalive_timeout_secs: U32 val = 0)
: HTTPClient ref^

Parameters

Returns


Public Functions

apply

[Source]

Schedule a request on an HTTP session. If a new connection is created, a new instance of the application's Receive Handler will be created for it. A val copy of the Payload is returned, and it can not be modified after this point. This is useful in Stream and Chunked transfer modes, so that the application can follow up with calls to Client.send_body.

fun ref apply(
  request: Payload trn)
: Payload val ?

Parameters

Returns


dispose

[Source]

Disposes the sessions and cancels all pending requests.

fun ref dispose()
: None val

Returns


send_body

[Source]

fun ref send_body(
  data: (String val | Array[U8 val] val),
  session: HTTPSession tag)
: None val

Parameters

Returns