Mint.HTTP2.request
request
, go back to Mint.HTTP2 module for more information.
Specs
request( t(), method :: String.t(), path :: String.t(), Mint.Types.headers(), body :: iodata() | nil | :stream ) :: {:ok, t(), Mint.Types.request_ref()} | {:error, t(), Mint.Types.error()}
See Mint.HTTP.request/5
.
In HTTP/2, opening a request means opening a new HTTP/2 stream (see the
module documentation). This means that a request could fail because the
maximum number of concurrent streams allowed by the server has been reached.
In that case, the error reason :too_many_concurrent_requests
is returned.
If you want to avoid incurring in this error, you can retrieve the value of
the maximum number of concurrent streams supported by the server through
get_server_setting/2
(passing in the :max_concurrent_streams
setting name).
Header list size
In HTTP/2, the server can optionally specify a maximum header list size that
the client needs to respect when sending headers. The header list size is calculated
by summing the length (in bytes) of each header name plus value, plus 32 bytes for
each header. Note that pseudo-headers (like :path
or :method
) count towards
this size. If the size is exceeded, an error is returned. To check what the size
is, use get_server_setting/2
.
Request body size
If the request body size will exceed the window size of the HTTP/2 stream created by the
request or the window size of the connection Mint will return a :exceeds_window_size
error.
To ensure you do not exceed the window size it is recommended to stream the request
body by initially passing :stream
as the body and sending the body in chunks using
stream_request_body/3
and using get_window_size/2
to get the window size of the
request and connection.