View Source HTTPSpec.Response (http_spec v2.0.1)

A struct for describing HTTP response.

Summary

Functions

Returns the values of the header specified by name.

Returns the values of the trailer specified by name.

Types

@type body() :: binary() | nil
@type headers() :: [{header_name :: String.t(), header_value :: String.t()}]
@type status() :: non_neg_integer()
@type t() :: %HTTPSpec.Response{
  body: body(),
  headers: headers(),
  status: status(),
  trailers: headers()
}

Functions

Link to this function

get_header(response, name)

View Source
@spec get_header(t(), binary()) :: [binary()]

Returns the values of the header specified by name.

Examples

iex> Response.get_header(response, "content-type")
["application/json"]

iex> Response.get_header(response, "x-unknown")
[]
Link to this function

get_trailer(response, name)

View Source
@spec get_trailer(t(), binary()) :: [binary()]

Returns the values of the trailer specified by name.

Examples

iex> Response.get_trailer(response, "expires")
["Wed, 21 Oct 2015 07:28:00 GMT"]

iex> Response.get_trailer(response, "x-unknown")
[]
@spec new(keyword() | map()) :: {:ok, t()} | {:error, HTTPSpec.ArgumentError.t()}
@spec new!(keyword() | map()) :: t()