hackney_util (hackney v4.11.0)

View Source

Summary

Functions

Get the default protocols for HTTP connections. Returns the value of the default_protocols` application env, or `[http2, http1] if not set.

The caller's socket options to merge over a transport's own base options when it dials. Only gen_tcp/inet socket options are kept: connect_options also carries hackney's own entries for the proxy transports (on_connect_response, proxy_auth_fun, ...), and the framing options the transport reads its socket with (binary, active, packet, mode) stay the transport's.

filter a proplists and only keep allowed keys

The caller's socket options that apply to the UDP socket of an HTTP/3 connection, forwarded to quic as extra_socket_opts.

Start the given applications if they were not already started.

set the default options in a proplists if not defined

The socket options in a connect_options list: everything except the entries hackney reads itself. Used to key pooled and shared connections by the socket options they were opened with.

Functions

default_protocols()

-spec default_protocols() -> [http3 | http2 | http1].

Get the default protocols for HTTP connections. Returns the value of the default_protocols` application env, or `[http2, http1] if not set.

The order determines preference: HTTP/2 is preferred, then HTTP/1.1.

To enable HTTP/3 (experimental):

  application:set_env(hackney, default_protocols, [http3, http2, http1]).

dial_socket_opts(ConnectOpts)

-spec dial_socket_opts(list()) -> list().

The caller's socket options to merge over a transport's own base options when it dials. Only gen_tcp/inet socket options are kept: connect_options also carries hackney's own entries for the proxy transports (on_connect_response, proxy_auth_fun, ...), and the framing options the transport reads its socket with (binary, active, packet, mode) stay the transport's.

filter_options(Tail, AllowedKeys, Acc)

-spec filter_options([{atom(), any()} | {raw, any(), any(), any()}], [atom()], Acc) -> Acc
                        when Acc :: [any()].

filter a proplists and only keep allowed keys

is_ipv6(Host)

maybe_apply_defaults(Rest, Options)

merge_opts(Rest, Options)

privdir()

quic_socket_opts(ConnectOpts)

-spec quic_socket_opts(list()) -> list().

The caller's socket options that apply to the UDP socket of an HTTP/3 connection, forwarded to quic as extra_socket_opts.

require(Rest)

-spec require([module()]) -> ok.

Start the given applications if they were not already started.

set_option_default(Opts, Key, Value)

-spec set_option_default(Opts, atom(), any()) -> Opts when Opts :: [{atom(), any()}].

set the default options in a proplists if not defined

socket_opts(ConnectOpts)

-spec socket_opts(list()) -> list().

The socket options in a connect_options list: everything except the entries hackney reads itself. Used to key pooled and shared connections by the socket options they were opened with.

to_atom(V)

to_int(S)