View Source XHTTP.ResponseDocument protocol (XHTTP v0.1.0)
The ResponseDocument protocol provides common functions for retrieving document data from a HTTP response, such as a HTML, XML or JSON document.
How exactly that data is retrieved is up to the implementation, and the protocol relies on each response containing some basic document-like information.
Summary
Functions
Retrieve the Age header value as a positive integer or zero.
Retrieve the body of a HTTP response as document content.
Retrieve the Content-Length header value, nil if no such header.
Retrieve the Content-Type header value, nil if no such header.
Retrieve the Date header value as DateTime.t(), nil if no such header.
Retrieve the Expires header value as DateTime.t(), nil if no such header.
Retrieve the Last-Modified header value as DateTime.t(), nil if no such header.
Types
@type content() :: binary() | struct() | nil | Enumerable.t()
@type t() :: term()
All the types that implement this protocol.
Functions
@spec age(response :: t()) :: non_neg_integer()
Retrieve the Age header value as a positive integer or zero.
Retrieve the body of a HTTP response as document content.
@spec content_length(response :: t()) :: non_neg_integer() | nil
Retrieve the Content-Length header value, nil if no such header.
Retrieve the Content-Type header value, nil if no such header.
@spec date(response :: t()) :: DateTime.t() | nil
Retrieve the Date header value as DateTime.t(), nil if no such header.
@spec expires(response :: t()) :: DateTime.t() | nil
Retrieve the Expires header value as DateTime.t(), nil if no such header.
@spec last_modified(response :: t()) :: DateTime.t() | nil
Retrieve the Last-Modified header value as DateTime.t(), nil if no such header.