hackney_cow_http2_machine (hackney v3.0.1)
View SourceSummary
Types
-type continued_frame() :: {headers, hackney_cow_http2:streamid(), hackney_cow_http2:fin(), hackney_cow_http2:head_fin(), binary()} | {push_promise, hackney_cow_http2:streamid(), hackney_cow_http2:head_fin(), hackney_cow_http2:streamid(), binary()}.
-type http2_machine() :: #http2_machine{mode :: client | server, opts :: opts(), state :: settings | normal | {continuation, request | response | trailers | push_promise, continued_frame()}, preface_timer :: undefined | reference(), settings_timer :: undefined | reference(), local_settings :: map(), next_settings :: undefined | map(), remote_settings :: map(), local_window :: integer(), remote_window :: integer(), local_streamid :: pos_integer(), remote_streamid :: non_neg_integer(), last_remote_streamid :: non_neg_integer(), streams :: #{hackney_cow_http2:streamid() => stream()}, local_lingering_streams :: [hackney_cow_http2:streamid()], remote_lingering_streams :: [hackney_cow_http2:streamid()], decode_state :: hackney_cow_hpack:state(), encode_state :: hackney_cow_hpack:state()}.
-type opts() :: #{connection_window_margin_size => 0..2147483647, connection_window_update_threshold => 0..2147483647, enable_connect_protocol => boolean(), initial_connection_window_size => 65535..2147483647, initial_stream_window_size => 0..2147483647, max_connection_window_size => 0..2147483647, max_concurrent_streams => non_neg_integer() | infinity, max_decode_table_size => non_neg_integer(), max_encode_table_size => non_neg_integer(), max_fragmented_header_block_size => 16384..2147483647, max_frame_size_received => 16384..16777215, max_frame_size_sent => 16384..16777215 | infinity, max_stream_window_size => 0..2147483647, message_tag => any(), preface_timeout => timeout(), settings_timeout => timeout(), stream_window_data_threshold => 0..2147483647, stream_window_margin_size => 0..2147483647, stream_window_update_threshold => 0..2147483647}.
-type status() :: 100..999.
-type stream() :: #stream{id :: hackney_cow_http2:streamid(), method :: binary(), local :: idle | hackney_cow_http2:fin(), local_window :: integer(), local_buffer :: queue:queue({hackney_cow_http2:fin(), non_neg_integer(), {data, iodata()} | #sendfile{offset :: non_neg_integer(), bytes :: pos_integer(), path :: file:name_all()}}), local_buffer_size :: non_neg_integer(), local_trailers :: undefined | headers(), remote :: idle | hackney_cow_http2:fin(), remote_window :: integer(), remote_expected_size :: undefined | non_neg_integer(), remote_read_size :: non_neg_integer(), te :: undefined | binary()}.
Functions
-spec ensure_window(non_neg_integer(), State) -> ok | {ok, pos_integer(), State} when State :: http2_machine().
-spec ensure_window(hackney_cow_http2:streamid(), non_neg_integer(), State) -> ok | {ok, pos_integer(), State} when State :: http2_machine().
-spec frame(hackney_cow_http2:frame(), State) -> {ok, State} | {ok, {data, hackney_cow_http2:streamid(), hackney_cow_http2:fin(), binary()}, State} | {ok, {headers, hackney_cow_http2:streamid(), hackney_cow_http2:fin(), headers(), pseudo_headers(), non_neg_integer() | undefined}, State} | {ok, {trailers, hackney_cow_http2:streamid(), headers()}, State} | {ok, {rst_stream, hackney_cow_http2:streamid(), hackney_cow_http2:error()}, State} | {ok, {push_promise, hackney_cow_http2:streamid(), hackney_cow_http2:streamid(), headers(), pseudo_headers()}, State} | {ok, {goaway, hackney_cow_http2:streamid(), hackney_cow_http2:error(), binary()}, State} | {send, [{hackney_cow_http2:streamid(), hackney_cow_http2:fin(), [{data, iodata()} | #sendfile{offset :: non_neg_integer(), bytes :: pos_integer(), path :: file:name_all()} | {trailers, headers()}]}], State} | {error, {stream_error, hackney_cow_http2:streamid(), hackney_cow_http2:error(), atom()}, State} | {error, {connection_error, hackney_cow_http2:error(), atom()}, State} when State :: http2_machine().
-spec get_connection_local_buffer_size(http2_machine()) -> non_neg_integer().
-spec get_last_streamid(http2_machine()) -> hackney_cow_http2:streamid().
-spec get_local_setting(atom(), http2_machine()) -> atom() | integer().
-spec get_remote_settings(http2_machine()) -> map().
-spec get_stream_local_buffer_size(hackney_cow_http2:streamid(), http2_machine()) -> {ok, non_neg_integer()} | {error, not_found | closed}.
-spec get_stream_local_state(hackney_cow_http2:streamid(), http2_machine()) -> {ok, idle | hackney_cow_http2:fin(), empty | nofin | fin} | {error, not_found | closed}.
-spec get_stream_remote_state(hackney_cow_http2:streamid(), http2_machine()) -> {ok, idle | hackney_cow_http2:fin()} | {error, not_found | closed}.
-spec ignored_frame(State) -> {ok, State} | {error, {connection_error, protocol_error, atom()}, State} when State :: http2_machine().
-spec init(client | server, opts()) -> {ok, iodata(), http2_machine()}.
-spec init_stream(binary(), State) -> {ok, hackney_cow_http2:streamid(), State} when State :: http2_machine().
-spec init_upgrade_stream(binary(), State) -> {ok, hackney_cow_http2:streamid(), State} when State :: http2_machine().
-spec is_lingering_stream(hackney_cow_http2:streamid(), http2_machine()) -> boolean().
-spec prepare_headers(hackney_cow_http2:streamid(), State, idle | hackney_cow_http2:fin(), pseudo_headers(), headers()) -> {ok, hackney_cow_http2:fin(), iodata(), State} when State :: http2_machine().
-spec prepare_push_promise(hackney_cow_http2:streamid(), State, pseudo_headers(), headers()) -> {ok, hackney_cow_http2:streamid(), iodata(), State} | {error, no_push} when State :: http2_machine().
-spec prepare_trailers(hackney_cow_http2:streamid(), State, headers()) -> {ok, iodata(), State} when State :: http2_machine().
-spec reset_stream(hackney_cow_http2:streamid(), State) -> {ok, State} | {error, not_found} when State :: http2_machine().
-spec send_or_queue_data(hackney_cow_http2:streamid(), State, hackney_cow_http2:fin(), DataOrFileOrTrailers) -> {ok, State} | {send, [{hackney_cow_http2:streamid(), hackney_cow_http2:fin(), [DataOrFileOrTrailers]}], State} when State :: http2_machine(), DataOrFileOrTrailers :: {data, iodata()} | #sendfile{offset :: non_neg_integer(), bytes :: pos_integer(), path :: file:name_all()} | {trailers, headers()}.
-spec set_last_streamid(http2_machine()) -> {hackney_cow_http2:streamid(), http2_machine()}.
-spec timeout(preface_timeout | settings_timeout, reference(), State) -> {ok, State} | {error, {connection_error, hackney_cow_http2:error(), atom()}, State} when State :: http2_machine().
-spec update_window(1..2147483647, State) -> State when State :: http2_machine().
-spec update_window(hackney_cow_http2:streamid(), 1..2147483647, State) -> State when State :: http2_machine().