Soap.HTTP behaviour (Soap v2.0.0)

View Source

The HTTP client behaviour. Choose an implementation with the :http option.

Soap.HTTP.Req is the default. To use another client, implement this behaviour, which takes a few lines. The README has an example for HTTPoison.

A request returns {:ok, %{status: integer, headers: list, body: binary}} for any HTTP response, whatever its status, and {:error, reason} when there is no response.

Implementations should understand these options, and pass through any others:

  • :timeout - how long to wait for a reply, in milliseconds.
  • :connect_timeout - how long to wait for a connection, in milliseconds.
  • :follow_redirects - whether to follow redirects.
  • :max_reply_size - stop reading a reply past this many bytes, and return {:error, :reply_too_large}. Soap.Decoder also checks the size, so an adapter that ignores this only reads more than it has to.

Summary

Functions

The implementation selected by opts.

Types

response()

@type response() :: %{
  status: pos_integer(),
  headers: [{String.t(), String.t()}],
  body: binary()
}

Callbacks

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

@callback request(
  method :: :get | :post,
  url :: String.t(),
  headers :: [{String.t(), String.t()}],
  body :: iodata(),
  opts :: keyword()
) :: {:ok, response()} | {:error, term()}

Functions

adapter(opts)

The implementation selected by opts.