package shuttle_http
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=d868723ab7d9b9c7239c30ce0692bc02c8f6ac3f3ff62ef31a0b8a014de45995
sha512=f831285927eae3da9bb6e233e296e0d9193a940faf81850a279d50a1639ad806717054f973e60436d9afa503ae5a800ddd6a5c4b3eaca8457b20ac5d810534f3
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.