HTTP.FetchOptions (http_fetch v0.11.0)
View SourceOptions processing for HTTP.fetch/2 requests.
HTTP.fetch/2 accepts a flat init keyword list or map, mirroring the browser
fetch(input, init) shape. Supported fetch-style options are:
method- HTTP method, defaulting toGETheaders- request headers as a list, map, orHTTP.Headersbody- request bodyduplex- request streaming mode;:halfor"half"for streaming bodiessignal-HTTP.AbortControllerPIDredirect-:follow,:manual, or:error; defaults to:follow
The socket transport also accepts Elixir-specific extensions:
content_type- convenience Content-Type value for request bodiestimeout- request timeout in millisecondsconnect_timeout- connection timeout in millisecondshttp_version- protocol selection, one of:http1,:http2,:http3,:h2c, or:auto; defaults to:http1ssl- TLS options passed to:sslsocket_opts- socket options passed to the underlying transportunix_socket- Unix Domain Socket path
Summary
Functions
Extracts body from options.
Extracts content type from options.
Extracts the request body streaming mode from options.
Extracts headers from options.
Extracts the HTTP method from options.
Creates a new FetchOptions struct from a flat map, keyword list, or existing FetchOptions struct.
Converts fetch init options to the internal socket transport option list.
Types
@type http_version() :: :http1 | :http2 | :http3 | :h2c | :auto
@type redirect() :: :follow | :manual | :error
@type t() :: %HTTP.FetchOptions{ body: any(), connect_timeout: integer() | nil, content_type: String.t() | nil, duplex: :half | nil, headers: HTTP.Headers.t(), http_version: http_version(), method: atom(), redirect: redirect(), signal: any() | nil, socket_opts: list() | nil, ssl: list() | nil, timeout: integer() | nil, unix_socket: String.t() | nil }
Functions
Extracts body from options.
Extracts content type from options.
@spec get_duplex(t()) :: :half | nil
Extracts the request body streaming mode from options.
@spec get_headers(t()) :: HTTP.Headers.t()
Extracts headers from options.
Extracts the HTTP method from options.
Creates a new FetchOptions struct from a flat map, keyword list, or existing FetchOptions struct.
Converts fetch init options to the internal socket transport option list.