h1_parse_erl (h1 v0.2.0)
View SourceSummary
Functions
Stateless chunk parser (livery style) — useful when caller drives the body loop directly.
Parse a full request head in one call (for callers who already have the complete bytes buffered). Returns path + query-string split.
Types
-type http_method() :: binary().
-type http_reason() :: binary().
-type http_version() :: {non_neg_integer(), non_neg_integer()}.
-type parser() :: #h1_parser{type :: auto | request | response, state :: on_first_line | on_header | on_body | on_trailers | on_junk | done, buffer :: binary(), version :: undefined | {non_neg_integer(), non_neg_integer()}, method :: undefined | binary(), status :: undefined | 100..599, partial_headers :: [{binary(), binary()}], clen :: undefined | non_neg_integer() | bad_int | conflict, te :: undefined | binary(), connection :: undefined | binary(), ctype :: undefined | binary(), upgrade :: undefined | binary(), expect :: undefined | binary(), body_framing :: undefined | no_body | {content_length, non_neg_integer()} | chunked | close_delimited, body_state :: waiting | done | {stream, fun(), term(), fun()}, body_read :: non_neg_integer(), max_line_length :: pos_integer(), max_empty_lines :: non_neg_integer(), max_header_name_size :: pos_integer(), max_header_value_size :: pos_integer(), max_headers :: pos_integer(), max_body_size :: pos_integer() | infinity, empty_lines :: non_neg_integer(), header_count :: non_neg_integer()}.
-type parser_option() :: request | response | auto | {max_line_length, pos_integer()} | {max_empty_lines, non_neg_integer()} | {max_header_name_size, pos_integer()} | {max_header_value_size, pos_integer()} | {max_headers, pos_integer()} | {max_body_size, pos_integer() | infinity} | {method, binary()} | {status, 100..599}.
-type parser_result() :: {response, http_version(), status(), http_reason(), parser()} | {request, http_method(), uri(), http_version(), parser()} | {more, parser()} | header_result() | body_result() | {error, term()}.
-type request_result() :: {ok, http_method(), binary(), binary(), http_version(), [{binary(), binary()}], binary()} | {more, binary()} | {error, term()}.
-type response_result() :: {ok, http_version(), status(), http_reason(), [{binary(), binary()}], binary()} | {more, binary()} | {error, term()}.
-type status() :: 100..599.
-type uri() :: binary().
Functions
-spec execute(parser()) -> parser_result().
-spec execute(parser(), binary()) -> parser_result().
Stateless chunk parser (livery style) — useful when caller drives the body loop directly.
-spec parse_request(binary()) -> request_result().
Parse a full request head in one call (for callers who already have the complete bytes buffered). Returns path + query-string split.
-spec parse_request(binary(), map()) -> request_result().
-spec parse_response(binary()) -> response_result().
-spec parse_response(binary(), map()) -> response_result().
-spec parser() -> parser().
-spec parser([parser_option()]) -> parser().
-spec to_int(binary()) -> {ok, non_neg_integer()} | false.