Mint v0.2.0 Mint.HTTP1 View Source
Processless HTTP client with support for HTTP/1 and HTTP/1.1.
This module provides a data structure that represents an HTTP/1 or HTTP/1.1 connection to
a given server. The connection is represented as an opaque struct %Mint.HTTP1{}
.
The connection is a data structure and is not backed by a process, and all the
connection handling happens in the process that creates the struct.
This module and data structure work exactly like the ones described in the Mint
module, with the exception that Mint.HTTP1
specifically deals with HTTP/1 and HTTP/1.1 while
Mint
deals seamlessly with HTTP/1, HTTP/1.1, and HTTP/2. For more information on
how to use the data structure and client architecture, see Mint
.
Link to this section Summary
Functions
Same as Mint.HTTP.connect/4
, but forces an HTTP/1 or HTTP/1.1 connection
Link to this section Types
error_reason()
View Source
error_reason() :: term()
error_reason() :: term()
An HTTP/1-specific error reason.
The values can be:
:closed
- when you try to make a request or stream a body chunk but the connection is closed.:request_body_is_streaming
- when you callrequest/5
to send a new request but another request is already streaming.{:unexpected_data, data}
- when unexpected data is received from the server.:invalid_status_line
- when the HTTP/1 status line is invalid.{:invalid_request_target, target}
- when the request target is invalid.:invalid_header
- when headers can't be parsed correctly.{:invalid_header_name, name}
- when a header name is invalid.{:invalid_header_value, name, value}
- when a header value is invalid.name
is the name of the header andvalue
is the invalid value.:invalid_chunk_size
- when the chunk size is invalid.:missing_crlf_after_chunk
- when the CRLF after a chunk is missing.:invalid_trailer_header
- when trailer headers can't be parsed.:more_than_one_content_length_header
- when more than onecontent-length
headers are in the response.:transfer_encoding_and_content_length
- when both thecontent-length
as well as thetransfer-encoding
headers are in the response.{:invalid_content_length_header, value}
- when the value of thecontent-length
header is invalid, that is, is not an non-negative integer.:empty_token_list
- when a header that is supposed to contain a list of tokens (such as theconnection
header) doesn't contain any.{:invalid_token_list, string}
- when a header that is supposed to contain a list of tokens (such as theconnection
header) contains a malformed list of tokens.
t()
View Source
(opaque)
t()
t()
Link to this section Functions
close(conn) View Source
See Mint.HTTP.close/1
.
connect(scheme, hostname, port, opts \\ [])
View Source
connect(Mint.Types.scheme(), String.t(), :inet.port_number(), keyword()) ::
{:ok, t()} | {:error, Mint.Types.error()}
connect(Mint.Types.scheme(), String.t(), :inet.port_number(), keyword()) :: {:ok, t()} | {:error, Mint.Types.error()}
Same as Mint.HTTP.connect/4
, but forces an HTTP/1 or HTTP/1.1 connection.
This function doesn't support proxying.
delete_private(conn, key) View Source
get_private(conn, key, default \\ nil) View Source
get_socket(conn)
View Source
get_socket(t()) :: Mint.Types.socket()
get_socket(t()) :: Mint.Types.socket()
open?(conn, type \\ :read_write) View Source
See Mint.HTTP.open?/1
.
open_request_count(conn)
View Source
open_request_count(t()) :: non_neg_integer()
open_request_count(t()) :: non_neg_integer()
See Mint.HTTP.open_request_count/1
.
In HTTP/1, the number of open requests is the number of pipelined requests.
put_private(conn, key, value) View Source
request(conn, method, path, headers, body \\ nil)
View Source
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()}
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/1 and HTTP/1.1, you can't open a new request if you're streaming the body of
another request. If you try, the error reason {:error, :request_body_is_streaming}
is
returned.
stream(conn, message)
View Source
stream(t(), term()) ::
{:ok, t(), [Mint.Types.response()]}
| {:error, t(), Mint.Types.error(), [Mint.Types.response()]}
| :unknown
stream(t(), term()) :: {:ok, t(), [Mint.Types.response()]} | {:error, t(), Mint.Types.error(), [Mint.Types.response()]} | :unknown
See Mint.HTTP.stream/2
.
stream_request_body(conn, ref, body)
View Source
stream_request_body(t(), Mint.Types.request_ref(), iodata() | :eof) ::
{:ok, t()} | {:error, t(), Mint.Types.error()}
stream_request_body(t(), Mint.Types.request_ref(), iodata() | :eof) :: {:ok, t()} | {:error, t(), Mint.Types.error()}