package shuttle_http
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=69bf4d3ec9262dc981db5b6073c1d9e581c24fa1f1a49d20798eb3ae953ecdc3
sha512=36e95dcfce349f1acc586afa30c6b74d8212b9a8c0e32a2abcdbe09a87208b9ed2dc2c27aed3d65f4e9031260a3c54af7d0e9ebd7ba3d0b80182f17773dae24f
doc/shuttle_http/Shuttle_http/Client/index.html
Module Shuttle_http.Client
Source
HTTP/1.1 client that supports keep-alives. A client entity can be created once with an address and re-used for multiple requests. The client is closed either when a user explicitly closes it, or if there is an exception when performing a HTTP request using the client.
It is the responsiblity of the user to check that a http call raised an exception and avoid using a connection once an exception is seen in a call.
val create :
?interrupt:unit Async.Deferred.t ->
?connect_timeout:Core.Time.Span.t ->
?ssl:Ssl.t ->
Address.t ->
t Async.Deferred.Or_error.t
Initiate a TCP connection targeting the user provided Address and perform SSL handshake if needed. If an interrup deferred is provided the underlying socket is closed when it resolves. If address is a host + port pair the client will automatically populate the Host HTTP header for outgoing calls, and ensure that SNI and hostname validation is configured if using an SSL connection.
Remote_connection_closed
is raised if attempting if an EOF is reached before the full response has been read.
Request_aborted
is raised if attempting to enqueue a request within a closed http client.
call
Attempts to perform a HTTP request using the user provided client. If the response contains a "Connection: close" header or if there's an exception when performing the call the client will be closed and should not be used for any future calls. If performing multiple calls on a client, users should ensure to only wait on a response promise if all previous responses have been fully read.
closed
returns a deferred that's resolved when the http client is closed.
close
initiates shutdown for an http client. Any request that's currently in-flight will be attempt to run, and any pending requests will fail with exception.
Persistent clients, not to be confused with HTTP/1.1 persistent connections are durable clients that maintain a connection to a service and eagerly and repeatedly reconnect if the underlying socket connection is lost.