aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cow_http2.erl9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/cow_http2.erl b/src/cow_http2.erl
index c2dba8b..555dfc2 100644
--- a/src/cow_http2.erl
+++ b/src/cow_http2.erl
@@ -218,7 +218,7 @@ parse(<< 4:24, 8:8, _:9, StreamID:31, _:1, 0:31, _/bits >>) ->
{stream_error, StreamID, protocol_error, 'WINDOW_UPDATE frames MUST have a non-zero increment. (RFC7540 6.9)'};
parse(<< 4:24, 8:8, _:9, StreamID:31, _:1, Increment:31, Rest/bits >>) ->
{ok, {window_update, StreamID, Increment}, Rest};
-parse(<< _:24, 8:8, _/bits >>) ->
+parse(<< Len:24, 8:8, _/bits >>) when Len =/= 4->
{connection_error, frame_size_error, 'WINDOW_UPDATE frames MUST be 4 bytes wide. (RFC7540 6.9)'};
%%
%% CONTINUATION frames.
@@ -240,6 +240,13 @@ parse_ping_test() ->
{ok, {ping, 1234567890}, <<>>} = parse(Ping),
{ok, {ping, 1234567890}, << 42 >>} = parse(<< Ping/binary, 42 >>),
ok.
+
+parse_windows_update_test() ->
+ WindowUpdate = << 4:24, 8:8, 0:9, 0:31, 0:1, 12345:31 >>,
+ _ = [more = parse(binary:part(WindowUpdate, 0, I)) || I <- lists:seq(1, byte_size(WindowUpdate) - 1)],
+ {ok, {window_update, 12345}, <<>>} = parse(WindowUpdate),
+ {ok, {window_update, 12345}, << 42 >>} = parse(<< WindowUpdate/binary, 42 >>),
+ ok.
-endif.
parse_fin(0) -> nofin;