aboutsummaryrefslogtreecommitdiffstats
path: root/src/cow_http2.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/cow_http2.erl')
-rw-r--r--src/cow_http2.erl19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/cow_http2.erl b/src/cow_http2.erl
index 225d2ec..68f3625 100644
--- a/src/cow_http2.erl
+++ b/src/cow_http2.erl
@@ -1,4 +1,4 @@
-%% Copyright (c) 2015-2018, Loïc Hoguin <[email protected]>
+%% Copyright (c) 2015-2023, Loïc Hoguin <[email protected]>
%%
%% Permission to use, copy, modify, and/or distribute this software for any
%% purpose with or without fee is hereby granted, provided that the above
@@ -39,9 +39,6 @@
-type streamid() :: pos_integer().
-export_type([streamid/0]).
--type fin() :: fin | nofin.
--export_type([fin/0]).
-
-type head_fin() :: head_fin | head_nofin.
-export_type([head_fin/0]).
@@ -66,9 +63,10 @@
| unknown_error.
-export_type([error/0]).
--type frame() :: {data, streamid(), fin(), binary()}
- | {headers, streamid(), fin(), head_fin(), binary()}
- | {headers, streamid(), fin(), head_fin(), exclusive(), streamid(), weight(), binary()}
+-type frame() :: {data, streamid(), cow_http:fin(), binary()}
+ | {headers, streamid(), cow_http:fin(), head_fin(), binary()}
+ | {headers, streamid(), cow_http:fin(), head_fin(),
+ exclusive(), streamid(), weight(), binary()}
| {priority, streamid(), exclusive(), streamid(), weight()}
| {rst_stream, streamid(), error()}
| {settings, settings()}
@@ -192,8 +190,8 @@ parse(<< 5:24, 2:8, _:9, StreamID:31, _:1, StreamID:31, _:8, Rest/bits >>) ->
'PRIORITY frames cannot make a stream depend on itself. (RFC7540 5.3.1)', Rest};
parse(<< 5:24, 2:8, _:9, StreamID:31, E:1, DepStreamID:31, Weight:8, Rest/bits >>) ->
{ok, {priority, StreamID, parse_exclusive(E), DepStreamID, Weight + 1}, Rest};
-%% @todo figure out how to best deal with frame size errors; if we have everything fine
-%% if not we might want to inform the caller how much he should expect so that it can
+%% @todo Figure out how to best deal with non-fatal frame size errors; if we have everything
+%% then OK if not we might want to inform the caller how much he should expect so that it can
%% decide if it should just close the connection
parse(<< BadLen:24, 2:8, _:9, StreamID:31, _:BadLen/binary, Rest/bits >>) ->
{stream_error, StreamID, frame_size_error, 'PRIORITY frames MUST be 5 bytes wide. (RFC7540 6.3)', Rest};
@@ -204,8 +202,7 @@ parse(<< 4:24, 3:8, _:9, 0:31, _/bits >>) ->
{connection_error, protocol_error, 'RST_STREAM frames MUST be associated with a stream. (RFC7540 6.4)'};
parse(<< 4:24, 3:8, _:9, StreamID:31, ErrorCode:32, Rest/bits >>) ->
{ok, {rst_stream, StreamID, parse_error_code(ErrorCode)}, Rest};
-%% @todo same as priority
-parse(<< _:24, 3:8, _:9, _:31, _/bits >>) ->
+parse(<< BadLen:24, 3:8, _:9, _:31, _/bits >>) when BadLen =/= 4 ->
{connection_error, frame_size_error, 'RST_STREAM frames MUST be 4 bytes wide. (RFC7540 6.4)'};
%%
%% SETTINGS frames.