fluminus v2.2.1 Fluminus.HTTPClient View Source

A HTTP client backed by HTTPoison that manages cookies.

Struct fields:

  • :cookies - cookies stored by this HTTP client.

Link to this section Summary

Types

All the header keys converted to lowercase, and in case there are some headers with the same key, the value will contain the value of the last header with that key as returned by HTTPoison.

t()

Link to this section Types

Specs

flattened_headers() :: %{required(String.t()) => String.t()}

All the header keys converted to lowercase, and in case there are some headers with the same key, the value will contain the value of the last header with that key as returned by HTTPoison.

Specs

headers() :: [{String.t(), String.t()}]

Specs

methods() :: :get | :post

Specs

t() :: %Fluminus.HTTPClient{cookies: %{required(String.t()) => String.t()}}

Link to this section Functions

Link to this function

download(client, url, destination, overwrite \\ false, headers \\ [], verbose \\ false)

View Source

Specs

download(t(), String.t(), Path.t(), bool(), headers(), bool()) ::
  :ok | {:error, :exists | any()}

Downloads from the url to the destination.

If overwrite is false, this function will return {:error, :exists} if destination alread exists.

Link to this function

get(client, url, headers \\ [])

View Source

Specs

get(t(), String.t(), headers()) ::
  {:ok, t(), flattened_headers(), HTTPoison.Response.t()}
  | {:error,
     %HTTPoison.Error{__exception__: term(), id: term(), reason: term()}}

Performs a GET request.

This is a convenience method that will call request/5

Link to this function

post(client, url, body, headers \\ [{"Content-Type", "application/x-www-form-urlencoded"}])

View Source

Specs

post(t(), String.t(), String.t(), headers()) ::
  {:ok, t(), flattened_headers(), HTTPoison.Response.t()}
  | {:error,
     %HTTPoison.Error{__exception__: term(), id: term(), reason: term()}}

Performs a POST request.

This is a convenience method that will call request/5

Link to this function

request(client, method, url, body, headers)

View Source

Specs

request(t(), methods(), String.t(), String.t(), headers()) ::
  {:ok, t(), flattened_headers(), HTTPoison.Response.t()}
  | {:error,
     %HTTPoison.Error{__exception__: term(), id: term(), reason: term()}}

Performs a HTTP request.