HTTP.FetchOptions (http_fetch v0.5.0)

Processes fetch options for HTTP requests, supporting flat map, keyword list, and HTTP.FetchOptions struct formats. Handles conversion to :httpc.request arguments.

Summary

Functions

Extracts body from options.

Extracts content type from options.

Extracts headers from options.

Extracts the HTTP method from options.

Creates a new FetchOptions struct from various input formats. Supports flat map, keyword list, or existing FetchOptions struct.

Converts FetchOptions to HTTP options for :httpc.request 3rd argument. Returns keyword list of HttpOptions.

Converts FetchOptions to options for :httpc.request 4th argument. Returns keyword list of Options.

Types

t()

@type t() :: %HTTP.FetchOptions{
  autoredirect: boolean() | nil,
  body: any(),
  body_format: atom() | nil,
  connect_timeout: integer() | nil,
  content_type: String.t() | nil,
  full_result: boolean() | nil,
  headers: HTTP.Headers.t(),
  headers_as_is: boolean() | nil,
  ipv6_host_with_brackets: boolean() | nil,
  method: atom(),
  options: keyword(),
  opts: keyword(),
  proxy_auth: tuple() | nil,
  receiver: pid() | function() | tuple() | nil,
  relaxed: boolean() | nil,
  signal: any() | nil,
  socket_opts: list() | nil,
  ssl: list() | nil,
  stream: atom() | tuple() | nil,
  timeout: integer() | nil,
  version: String.t() | nil
}

Functions

get_body(fetch_options)

@spec get_body(t()) :: any()

Extracts body from options.

get_content_type(fetch_options)

@spec get_content_type(t()) :: String.t() | nil

Extracts content type from options.

get_headers(fetch_options)

@spec get_headers(t()) :: HTTP.Headers.t()

Extracts headers from options.

get_method(fetch_options)

@spec get_method(t()) :: atom()

Extracts the HTTP method from options.

new(options)

@spec new(map() | keyword() | t()) :: t()

Creates a new FetchOptions struct from various input formats. Supports flat map, keyword list, or existing FetchOptions struct.

to_http_options(options)

@spec to_http_options(t()) :: keyword()

Converts FetchOptions to HTTP options for :httpc.request 3rd argument. Returns keyword list of HttpOptions.

to_options(options)

@spec to_options(t()) :: keyword()

Converts FetchOptions to options for :httpc.request 4th argument. Returns keyword list of Options.