Mojito.request

You're seeing just the function request, go back to Mojito module for more information.

Specs

request(request() | request_kwlist()) :: {:ok, response()} | {:error, error()}

Performs an HTTP request and returns the response.

If the pool: true option is given, or :pool is not specified, the request will be made using Mojito's automatic connection pooling system. For more details, see Mojito.Pool.request/1. This is the default mode of operation, and is recommended for best performance.

If pool: false is given as an option, the request will be made on a brand new connection. This does not spawn an additional process. Messages of the form {:tcp, _, _} or {:ssl, _, _} will be sent to and handled by the caller. If the caller process expects to receive other :tcp or :ssl messages at the same time, conflicts can occur; in this case, it is recommended to wrap request/1 in Task.async/1, or use one of the pooled request modes.

Options:

  • :pool - See above.
  • :timeout - Response timeout in milliseconds, or :infinity. Defaults to Application.get_env(:mojito, :timeout, 5000).
  • :raw - Set this to true to prevent the decompression of gzip or compress-encoded responses.
  • :transport_opts - Options to be passed to either :gen_tcp or :ssl. Most commonly used to perform insecure HTTPS requests via transport_opts: [verify: :verify_none].
Link to this function

request(method, url, headers \\ [], body \\ "", opts \\ [])

View Source

Specs

request(method(), url(), headers(), body() | nil, Keyword.t()) ::
  {:ok, response()} | {:error, error()} | no_return()

Performs an HTTP request and returns the response.

See request/1 for details.