-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathhttp2_spec_6_1_SUITE.erl
58 lines (47 loc) · 1.54 KB
/
http2_spec_6_1_SUITE.erl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
-module(http2_spec_6_1_SUITE).
-include("http2.hrl").
-include_lib("eunit/include/eunit.hrl").
-include_lib("common_test/include/ct.hrl").
-compile([export_all]).
all() ->
[
sends_data_with_invalid_pad_length
].
init_per_suite(Config) ->
application:ensure_started(crypto),
chatterbox_test_buddy:start(Config).
end_per_suite(Config) ->
chatterbox_test_buddy:stop(Config),
ok.
sends_data_with_invalid_pad_length(_Config) ->
{ok, Client} = http2c:start_link(),
RequestHeaders =
[
{<<":method">>, <<"GET">>},
{<<":path">>, <<"/index.html">>},
{<<":scheme">>, <<"https">>},
{<<":authority">>, <<"localhost:8080">>},
{<<"accept">>, <<"*/*">>},
{<<"accept-encoding">>, <<"gzip, deflate">>},
{<<"user-agent">>, <<"chattercli/0.0.1 :D">>}
],
{ok, {HeadersBin, _}} = hpack:encode(RequestHeaders, hpack:new_context()),
HF = {
#frame_header{
stream_id=1,
flags=?FLAG_END_HEADERS bor ?FLAG_PADDED
},
h2_frame_headers:new(HeadersBin)
},
http2c:send_unaltered_frames(Client, [HF]),
http2c:send_binary(
Client,
<<16#00,16#00,16#05,16#00,16#0b,16#00,16#00,16#00,16#01,
16#06,16#54,16#65,16#73,16#74>>),
Resp = http2c:wait_for_n_frames(Client, 0, 1),
ct:pal("Resp: ~p", [Resp]),
?assertEqual(1, (length(Resp))),
[{GoAwayH, GoAway}] = Resp,
?assertEqual(?GOAWAY, (GoAwayH#frame_header.type)),
?assertEqual(?PROTOCOL_ERROR, (h2_frame_goaway:error_code(GoAway))),
ok.