crawlie v0.5.1 Crawlie.Response

Defines the struct representing a page retrieved by the http client.

Summary

Types

t()

The Crawlie.Response struct type

Functions

Retrieves the content type of the response

Retrieves the content type of the response, just the “type/subtype” part, with no additional parameters, if there are any in the Content-Type header value

Returns the string representation of the uri contained in the Crawlie.Response struct

Types

t()
t() :: %Crawlie.Response{body: binary, headers: [{String.t, String.t}], status_code: integer, uri: URI.t}

The Crawlie.Response struct type.

Functions

content_type(response)
content_type(Crawlie.Response.t) :: String.t | nil

Retrieves the content type of the response.

Example

iex> alias Crawlie.Response
iex> url = "https://foo.bar/"
iex> headers = [{"Content-Type", "text/html; charset=UTF-8"}]
iex> response = Response.new(url, 200, headers, "<html />")
iex> Response.content_type(response)
"text/html; charset=UTF-8"
content_type_simple(this)
content_type_simple(Crawlie.Response.t) :: String.t | nil

Retrieves the content type of the response, just the “type/subtype” part, with no additional parameters, if there are any in the Content-Type header value.

Example

iex> alias Crawlie.Response
iex> url = "https://foo.bar/"
iex> headers = [{"Content-Type", "text/html; charset=UTF-8"}]
iex> response = Response.new(url, 200, headers, "<html />")
iex> Response.content_type_simple(response)
"text/html"
new(url, status_code, headers, body)
new(String.t | URI.t, integer, [{String.t, String.t}], binary) :: Crawlie.Response.t

Constructs the Crawlie.Response struct.

Example

iex> alias Crawlie.Response
iex> url = "https://foo.bar/"
iex> headers = [{"Content-Type", "text/plain"}]
iex> response = Response.new(url, 200, headers, "body")
iex> response.body
"body"
iex> response.status_code
200
url(this)

Returns the string representation of the uri contained in the Crawlie.Response struct.