Fetch.Response (Fetch v0.1.0)

View Source

An HTTP response.

Header names are lowercase. Order and duplicate headers are preserved, so headers is a list, not a map: set-cookie for example is commonly sent several times.

Summary

Functions

Returns all values of a header, in the order they were received.

Types

t()

@type t() :: %Fetch.Response{
  body: binary(),
  headers: [{String.t(), String.t()}],
  status: 100..599
}

Functions

get_header(response, name)

@spec get_header(t(), String.t()) :: [String.t()]

Returns all values of a header, in the order they were received.

iex> response = %Fetch.Response{status: 200, headers: [{"set-cookie", "a=1"}, {"set-cookie", "b=2"}]}
iex> Fetch.Response.get_header(response, "Set-Cookie")
["a=1", "b=2"]