Dowser.Client.Response (Dowser.Client v0.1.1)

View Source

A normalized HTTP response.

HTTP adapters build responses with new/3, which normalizes headers into a map of downcased string keys to string values (duplicate header names are folded into a single comma-joined value).

:body starts as the raw payload binary. decode/2 is the decoding phase: it turns the body into a decoded term according to the request :format (:json or :ndjson); :raw leaves it a binary. Dowser.Client.request/4 runs the decode phase automatically after the adapter returns.

Summary

Functions

Builds a response, normalizing headers into a map of downcased string keys and string values.

Types

format()

@type format() :: :json | :ndjson | :raw

headers()

@type headers() :: %{optional(String.t()) => String.t()}

t()

@type t() :: %Dowser.Client.Response{
  body: term(),
  headers: headers(),
  status: non_neg_integer()
}

Functions

decode(response, request)

new(status, headers, body)

@spec new(non_neg_integer(), Enumerable.t(), term()) :: t()

Builds a response, normalizing headers into a map of downcased string keys and string values.

headers may be any enumerable of {name, value} pairs (names/values as binaries or charlists). Duplicate names are folded into one comma-joined value.