Module hackney_http

HTTP parser in pure Erlang This parser is able to parse HTTP responses and requests in a streaming fashion.

Description

HTTP parser in pure Erlang This parser is able to parse HTTP responses and requests in a streaming fashion. If not set it will be autodetect the type of binary parsed, if it's a request or a response.

Internally it is keeping a buffer for intermediary steps but don't keep any state in memory.

The first time you initialise a parser using hackney_http:parser/0 or hackney_http:parser/1 you will receive an opaque record You can then process it using the function hackney_http:execute/2.

Each steps will return the status, some data and the new parser that you can process later with hackney_http:execute/2 when {more, ...} is returnned or hackney_http:execute/1 in other cases:

Data Types

body_result()

body_result() = {more, parser(), binary()} | {ok, binary(), parser()} | {done, binary()} | done

header_result()

header_result() = {headers_complete, parser()} | {header, {binary(), binary()}, parser()}

http_method()

http_method() = binary()

http_reason()

http_reason() = binary()

http_version()

http_version() = {integer(), integer()}

parser()

parser() = #hparser{}

parser_option()

parser_option() = request | response | auto | {max_empty_lines, integer()} | {max_line_length, integer()}

parser_options()

parser_options() = [parser_option()]

parser_result()

parser_result() = {response, http_version(), status(), http_reason(), parser()} | {request, http_method(), uri(), http_version(), parser()} | {more, parser()} | header_result() | body_result() | {error, term()}

status()

status() = integer()

uri()

uri() = binary()

Function Index

execute/1Execute the parser with the current buffer.
execute/2Execute the parser with the new buffer.
get/2retrieve a parser property.
parse_response_version/2
parser/0Create a new HTTP parser.
parser/1create a new HTTP parser with options.

Function Details

execute/1

execute(Hparser::#hparser{}) -> parser_result()

Execute the parser with the current buffer.

execute/2

execute(Hparser::#hparser{}, Bin::binary()) -> parser_result()

Execute the parser with the new buffer

get/2

get(Parser::parser(), Props::atom() | [atom()]) -> any()

retrieve a parser property. Properties are:

parse_response_version/2

parse_response_version(X1, St) -> any()

parser/0

parser() -> parser()

Create a new HTTP parser. The parser will autodetect if the parded binary is a response or a request.

parser/1

parser(Options::parser_options()) -> parser()

create a new HTTP parser with options. By default the type of parsed binary will be detected.

Available options:


Generated by EDoc