HTTPClient¶
Manages a group of HTTP connections on behalf of a client application. A client should create one instance of this class.
Constructors¶
create¶
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¶
- auth: TCPConnectAuth val
- handlermaker: HandlerFactory val
- sslctx: (SSLContext val | None val) = reference
- pipeline: Bool val = true
- keepalive_timeout_secs: U32 val = 0
Returns¶
- HTTPClient ref^
Public Functions¶
apply¶
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
.
Parameters¶
- request: Payload trn
Returns¶
- Payload val ?
dispose¶
Disposes the sessions and cancels all pending requests.
Returns¶
- None val
send_body¶
Parameters¶
- data: (String val | Array[U8 val] val)
- session: HTTPSession tag
Returns¶
- None val