abstract datatype: handle()
cancel/1 | Cancel an asynchronous request at any stage. |
finish_send/1 | Complete sending the request body. |
read/2 | Read a chunk of the response body, waiting for at most period ms or
until at least length bytes have been read. |
req/4 | Make an asynchronous request. |
send/2 | Asynchronously stream a chunk of the request body. |
cancel(Handle::handle()) -> ok
Cancel an asynchronous request at any stage. A reply will always still
be sent, either {error, #{code := cancelled}}
, another error
or a reply
depending on the state of the connection. Has no effect if the request has
already completed or was already cancelled.
finish_send(Handle::handle()) -> ok
Complete sending the request body. The message flow continues as
described for req/4
, ie. the next message will be reply
or error
.
read(Handle::handle(), Opts::erqwest:read_opts()) -> ok
Read a chunk of the response body, waiting for at most period
ms or
until at least length
bytes have been read. Note that more than length
bytes can be returned. length
defaults to 8 MB if omitted, and period
to
infinity
. Note that more than length
bytes can be returned. Replies with
{erqwest_response, Ref, chunk, Data}
, {erqwest_response, Ref, fin, Data}
or {erqwest_response, Ref, error, erqwest:err()}`. A `fin
or error
response will be the final message.
req(Client::erqwest:client() | atom(), Pid::pid(), Ref::any(), Req::erqwest:req_opts()) -> handle()
Make an asynchronous request.
A Response will be sent to Pid
as follows:
* If body
is stream
, and the request was successfully initated,
{erqwest_response, Ref, next}
. See send/2
and finish_send/2
for how to respond. Alternatively {erqwest_response, Ref, error,
erqwest:err()}
.
* If body
is omitted or is of type iodata()
, {erqwest_response, Ref,
reply, erqwest:resp()}
or {erqwest_response, Ref, error, erqwest:err()}
.
* If response_body
is stream
, erqwest:resp()
will contain a handle
which should be passed to read/2
. Alternatively, call cancel/1
if you do not intend to consume the body.
An error
response is _always_ the final response. If streaming is not used,
a single reply is guaranteed.
send(Handle::handle(), Data::iodata()) -> ok
Asynchronously stream a chunk of the request body. Replies with
{erqwest_response, Ref, next}
when the connection is ready to receive more
data. Replies with {erqwest_response, Ref, error, erqwest:err()}
if
something goes wrong, or {erqwest_response, Ref, reply, erqwest:resp()}
if
the server has already decided to reply. Call finish_send/1
when the
request body is complete.
Generated by EDoc