View Source XHTTP.Response protocol (XHTTP v0.1.0)

The Response protocol provides common functions for retrieving data from a HTTP response.

How exactly that data is retrieved is up to the implementation, and the protocol relies on each response consisting of headers and body.

Summary

Types

t()

All the types that implement this protocol.

Functions

Retrieve the last value for a given header.

Checks whether the HTTP response contains the searched header name.

Return an enumerable of headers as {key, value} pairs.

Retrieve the body in the Response.

Types

@type body() :: nil | binary() | Enumerable.t() | struct()
@type header() :: {key :: header_key(), value :: header_value()}
@type header_key() :: String.t() | atom()
@type header_value() :: header_value_single() | Enumerable.t(header_value_single())
@type header_value_single() :: String.t() | number() | nil
@type status() :: nil | pos_integer()
@type t() :: term()

All the types that implement this protocol.

Functions

@spec body(response :: t()) :: body()
Link to this function

header(response, header)

View Source
Link to this function

header(response, header, default)

View Source
@spec header(response :: t(), header :: String.t(), default :: header_value()) ::
  header_value()

Retrieve the last value for a given header.

Link to this function

header_member?(response, header)

View Source
@spec header_member?(response :: t(), header :: String.t()) :: boolean()

Checks whether the HTTP response contains the searched header name.

@spec headers(response :: t()) :: Enumerable.t(header())

Return an enumerable of headers as {key, value} pairs.

@spec status(response :: t()) :: status()

Retrieve the body in the Response.