livery_client_hackney (livery v0.3.0)

View Source

Default client adapter: hackney.

hackney 4.2 speaks HTTP/1.1, HTTP/2, and HTTP/3 (with TLS, pooling, and IPv6), so this one adapter covers every protocol. The request body may be buffered ({full, _}) or a producer ({stream, Fun}); the response is buffered by default, or streamed ({stream, Reader}) when the request sets stream => true.

Opts (the client's adapter_opts) may carry hackney => [opt], a list of raw hackney options forwarded verbatim (e.g. {ssl_options, _}, a pool name, HTTP/3 controls like zero_rtt/family).

hackney's request/5 always buffers the response, so any request that either streams its body or wants a streamed response goes through the connection API (request with a stream body, start_response, stream_body).

Push streaming (stream/3, stream_next/1, stop_stream/1) runs the request in hackney's async mode ({async, true | once}) under a small relay process that translates hackney's {hackney_response, _, _} messages into Livery's {livery_response, Ref, _} messages, folding hackney's separate status and headers events into one {status, Status, Headers}. The relay monitors the recipient and tears the connection down if it dies, so a caller that aborts mid-download never leaks a connection.

Summary

Functions

read(Conn, Timeout)

-spec read(term(), timeout()) -> {ok, binary(), term()} | {done, term()} | {error, term()}.

request(Req, Opts)

-spec request(livery_client:request(), map()) -> {ok, livery_client:response()} | {error, term()}.

stop_stream/1

-spec stop_stream(livery_client_adapter:stream_ref()) -> ok.

stream/3

stream_next/1

-spec stream_next(livery_client_adapter:stream_ref()) -> ok.