Mojito.request
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 toApplication.get_env(:mojito, :timeout, 5000)
.:raw
- Set this totrue
to prevent the decompression ofgzip
orcompress
-encoded responses.:transport_opts
- Options to be passed to either:gen_tcp
or:ssl
. Most commonly used to perform insecure HTTPS requests viatransport_opts: [verify: :verify_none]
.
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.