biryani 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/biryani.gemspec +5 -2
- data/conformance/server_spec.rb +11 -4
- data/lib/biryani/connection.rb +11 -7
- data/lib/biryani/hpack/field.rb +5 -9
- data/lib/biryani/http_request.rb +2 -1
- data/lib/biryani/state.rb +1 -1
- data/lib/biryani/streams_context.rb +15 -15
- data/lib/biryani/version.rb +1 -1
- metadata +3 -74
- data/.github/workflows/ci.yml +0 -30
- data/.github/workflows/conformance.yml +0 -46
- data/.gitignore +0 -18
- data/spec/connection/handle_connection_window_update_spec.rb +0 -16
- data/spec/connection/handle_data_spec.rb +0 -58
- data/spec/connection/handle_headers_spec.rb +0 -19
- data/spec/connection/handle_ping_spec.rb +0 -21
- data/spec/connection/handle_rst_stream_spec.rb +0 -16
- data/spec/connection/handle_settings_spec.rb +0 -37
- data/spec/connection/handle_stream_window_update_spec.rb +0 -20
- data/spec/connection/read_http2_magic_spec.rb +0 -26
- data/spec/connection/send_spec.rb +0 -104
- data/spec/connection/transition_stream_state_send_spec.rb +0 -39
- data/spec/data_buffer_spec.rb +0 -135
- data/spec/frame/continuation_spec.rb +0 -39
- data/spec/frame/data_spec.rb +0 -25
- data/spec/frame/goaway_spec.rb +0 -23
- data/spec/frame/headers_spec.rb +0 -52
- data/spec/frame/ping_spec.rb +0 -22
- data/spec/frame/priority_spec.rb +0 -22
- data/spec/frame/push_promise_spec.rb +0 -24
- data/spec/frame/read_spec.rb +0 -30
- data/spec/frame/rst_stream_spec.rb +0 -21
- data/spec/frame/settings_spec.rb +0 -23
- data/spec/frame/window_update_spec.rb +0 -21
- data/spec/hpack/decoder_spec.rb +0 -170
- data/spec/hpack/encoder_spec.rb +0 -48
- data/spec/hpack/field_spec.rb +0 -43
- data/spec/hpack/fields_spec.rb +0 -17
- data/spec/hpack/huffman_spec.rb +0 -20
- data/spec/hpack/integer_spec.rb +0 -27
- data/spec/hpack/string_spec.rb +0 -19
- data/spec/http_request_spec.rb +0 -62
- data/spec/http_response_spec.rb +0 -12
- data/spec/spec_helper.rb +0 -9
- data/spec/streams_context_spec.rb +0 -79
- data/spec/utils_spec.rb +0 -41
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
require_relative '../spec_helper'
|
|
2
|
-
|
|
3
|
-
RSpec.describe Connection do
|
|
4
|
-
context 'read_http2_magic' do
|
|
5
|
-
let(:io1) do
|
|
6
|
-
StringIO.new("PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n")
|
|
7
|
-
end
|
|
8
|
-
it 'should read' do
|
|
9
|
-
expect(Connection.read_http2_magic(io1)).to eq nil
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
let(:io2) do
|
|
13
|
-
StringIO.new("PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n\x00xff")
|
|
14
|
-
end
|
|
15
|
-
it 'should read' do
|
|
16
|
-
expect(Connection.read_http2_magic(io2)).to eq nil
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
let(:io3) do
|
|
20
|
-
StringIO.new("\x00xffPRI * HTTP/2.0\r\n\r\nSM\r\n\r\n")
|
|
21
|
-
end
|
|
22
|
-
it 'should not read' do
|
|
23
|
-
expect(Connection.read_http2_magic(io3)).to be_kind_of ConnectionError
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
require_relative '../spec_helper'
|
|
2
|
-
|
|
3
|
-
RSpec.describe Connection do
|
|
4
|
-
context 'send' do
|
|
5
|
-
let(:io) do
|
|
6
|
-
StringIO.new
|
|
7
|
-
end
|
|
8
|
-
let(:data_buffer) do
|
|
9
|
-
DataBuffer.new
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
let(:headers1) do
|
|
13
|
-
Frame::Headers.new(true, true, 2, nil, nil, 'this is dummy'.b, nil)
|
|
14
|
-
end
|
|
15
|
-
let(:send_window1) do
|
|
16
|
-
Window.new(65_535)
|
|
17
|
-
end
|
|
18
|
-
let(:streams_ctx1) do
|
|
19
|
-
streams_ctx = StreamsContext.new(do_nothing_proc)
|
|
20
|
-
streams_ctx.new_context(1, 65_535, 65_535)
|
|
21
|
-
streams_ctx.new_context(2, 65_535, 65_535)
|
|
22
|
-
streams_ctx
|
|
23
|
-
end
|
|
24
|
-
it 'should send' do
|
|
25
|
-
streams_ctx1[2].state_transition!(headers1, :recv)
|
|
26
|
-
Connection.send_headers(io, 2, "\x88".b, false, 16_384, streams_ctx1)
|
|
27
|
-
Connection.send_data(io, 2, 'Hello, world!'.b, send_window1, 16_384, streams_ctx1, data_buffer)
|
|
28
|
-
expect(io.string.force_encoding(Encoding::ASCII_8BIT)).to eq "\x00\x00\x01\x01\x04\x00\x00\x00\x02\x88\x00\x00\x0d\x00\x01\x00\x00\x00\x02Hello, world!".b
|
|
29
|
-
expect(send_window1.length).to eq 65_535 - 13
|
|
30
|
-
expect(streams_ctx1[1].send_window.length).to eq 65_535
|
|
31
|
-
expect(streams_ctx1[2].send_window.length).to eq 65_535 - 13
|
|
32
|
-
expect(data_buffer.length).to eq 0
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
let(:headers2) do
|
|
36
|
-
Frame::Headers.new(true, true, 1, nil, nil, 'this is dummy', nil)
|
|
37
|
-
end
|
|
38
|
-
let(:send_window2) do
|
|
39
|
-
Window.new(65_535)
|
|
40
|
-
end
|
|
41
|
-
let(:streams_ctx2) do
|
|
42
|
-
streams_ctx = StreamsContext.new(do_nothing_proc)
|
|
43
|
-
streams_ctx.new_context(1, 65_535, 65_535)
|
|
44
|
-
streams_ctx.new_context(2, 65_535, 65_535)
|
|
45
|
-
streams_ctx
|
|
46
|
-
end
|
|
47
|
-
it 'should send' do
|
|
48
|
-
streams_ctx2[1].state_transition!(headers2, :recv)
|
|
49
|
-
Connection.send_headers(io, 1, "\x88".b, true, 16_384, streams_ctx2)
|
|
50
|
-
expect(io.string.force_encoding(Encoding::ASCII_8BIT)).to eq "\x00\x00\x01\x01\x05\x00\x00\x00\x01\x88".b
|
|
51
|
-
expect(send_window2.length).to eq 65_535
|
|
52
|
-
expect(streams_ctx2[1].send_window.length).to eq 65_535
|
|
53
|
-
expect(streams_ctx2[2].send_window.length).to eq 65_535
|
|
54
|
-
expect(data_buffer.length).to eq 0
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
let(:headers3) do
|
|
58
|
-
Frame::Headers.new(true, true, 2, nil, nil, 'this is dummy', nil)
|
|
59
|
-
end
|
|
60
|
-
let(:send_window3) do
|
|
61
|
-
Window.new(65_535)
|
|
62
|
-
end
|
|
63
|
-
let(:streams_ctx3) do
|
|
64
|
-
streams_ctx = StreamsContext.new(do_nothing_proc)
|
|
65
|
-
streams_ctx.new_context(1, 65_535, 65_535)
|
|
66
|
-
streams_ctx.new_context(2, 65_535, 65_535)
|
|
67
|
-
streams_ctx[2].send_window.consume!(65_535)
|
|
68
|
-
streams_ctx
|
|
69
|
-
end
|
|
70
|
-
it 'should send' do
|
|
71
|
-
streams_ctx3[2].state_transition!(headers3, :recv)
|
|
72
|
-
Connection.send_data(io, 2, 'Hello, world!'.b, send_window3, 16_384, streams_ctx3, data_buffer)
|
|
73
|
-
expect(io.string.force_encoding(Encoding::ASCII_8BIT)).to eq ''.b
|
|
74
|
-
expect(send_window3.length).to eq 65_535
|
|
75
|
-
expect(streams_ctx3[1].send_window.length).to eq 65_535
|
|
76
|
-
expect(streams_ctx3[2].send_window.length).to eq 0
|
|
77
|
-
expect(data_buffer.length).to eq 1
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
let(:headers4) do
|
|
81
|
-
Frame::Headers.new(true, true, 2, nil, nil, 'this is dummy', nil)
|
|
82
|
-
end
|
|
83
|
-
let(:send_window4) do
|
|
84
|
-
send_window = Window.new(65_535)
|
|
85
|
-
send_window.consume!(65_535)
|
|
86
|
-
send_window
|
|
87
|
-
end
|
|
88
|
-
let(:streams_ctx4) do
|
|
89
|
-
streams_ctx = StreamsContext.new(do_nothing_proc)
|
|
90
|
-
streams_ctx.new_context(1, 65_535, 65_535)
|
|
91
|
-
streams_ctx.new_context(2, 65_535, 65_535)
|
|
92
|
-
streams_ctx
|
|
93
|
-
end
|
|
94
|
-
it 'should send' do
|
|
95
|
-
streams_ctx4[2].state_transition!(headers4, :recv)
|
|
96
|
-
Connection.send_data(io, 2, 'Hello, world!'.b, send_window4, 16_384, streams_ctx4, data_buffer)
|
|
97
|
-
expect(io.string.force_encoding(Encoding::ASCII_8BIT)).to eq ''.b
|
|
98
|
-
expect(send_window4.length).to eq 0
|
|
99
|
-
expect(streams_ctx4[1].send_window.length).to eq 65_535
|
|
100
|
-
expect(streams_ctx4[2].send_window.length).to eq 65_535
|
|
101
|
-
expect(data_buffer.length).to eq 1
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
end
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
require_relative '../spec_helper'
|
|
2
|
-
|
|
3
|
-
RSpec.describe Connection do
|
|
4
|
-
context 'transition_stream_state_send' do
|
|
5
|
-
let(:streams_ctx) do
|
|
6
|
-
streams_ctx = StreamsContext.new(do_nothing_proc)
|
|
7
|
-
streams_ctx.new_context(1, 65_535, 65_535)
|
|
8
|
-
streams_ctx.new_context(2, 65_535, 65_535)
|
|
9
|
-
streams_ctx
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
let(:headers) do
|
|
13
|
-
Frame::Headers.new(true, true, 2, nil, nil, 'this is dummy', nil)
|
|
14
|
-
end
|
|
15
|
-
it 'should transition' do
|
|
16
|
-
streams_ctx[2].state_transition!(headers, :recv)
|
|
17
|
-
Connection.transition_stream_state_send(headers, streams_ctx)
|
|
18
|
-
expect(streams_ctx.length).to eq 2
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it 'should transition' do
|
|
22
|
-
streams_ctx[1].state_transition!(headers, :recv)
|
|
23
|
-
streams_ctx[2].state_transition!(headers, :recv)
|
|
24
|
-
streams_ctx.close_all
|
|
25
|
-
expect { streams_ctx[1].tx << nil }.to raise_error Ractor::ClosedError
|
|
26
|
-
expect { streams_ctx[2].tx << nil }.to raise_error Ractor::ClosedError
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
let(:rst_stream) do
|
|
30
|
-
Frame::RstStream.new(2, 0)
|
|
31
|
-
end
|
|
32
|
-
it 'should transition' do
|
|
33
|
-
streams_ctx[2].state_transition!(headers, :recv)
|
|
34
|
-
Connection.transition_stream_state_send(rst_stream, streams_ctx)
|
|
35
|
-
expect { streams_ctx[1].tx << nil }.to_not raise_error
|
|
36
|
-
expect { streams_ctx[2].tx << nil }.to_not raise_error
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
data/spec/data_buffer_spec.rb
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
require_relative 'spec_helper'
|
|
2
|
-
|
|
3
|
-
RSpec.describe DataBuffer do
|
|
4
|
-
context 'take!' do
|
|
5
|
-
let(:data_buffer1) do
|
|
6
|
-
DataBuffer.new
|
|
7
|
-
end
|
|
8
|
-
let(:send_window1) do
|
|
9
|
-
Window.new(65_535)
|
|
10
|
-
end
|
|
11
|
-
let(:streams_ctx1) do
|
|
12
|
-
streams_ctx = StreamsContext.new(do_nothing_proc)
|
|
13
|
-
streams_ctx.new_context(1, 65_535, 65_535)
|
|
14
|
-
streams_ctx.new_context(2, 65_535, 65_535)
|
|
15
|
-
streams_ctx
|
|
16
|
-
end
|
|
17
|
-
it 'should take' do
|
|
18
|
-
expect(data_buffer1.take!(send_window1, streams_ctx1, 16_384).length).to eq 0
|
|
19
|
-
expect(send_window1.length).to eq 65_535
|
|
20
|
-
expect(streams_ctx1[1].send_window.length).to eq 65_535
|
|
21
|
-
expect(streams_ctx1[2].send_window.length).to eq 65_535
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
let(:data_buffer2) do
|
|
25
|
-
data_buffer = DataBuffer.new
|
|
26
|
-
data_buffer.store(1, 'one')
|
|
27
|
-
data_buffer.store(2, 'two')
|
|
28
|
-
data_buffer
|
|
29
|
-
end
|
|
30
|
-
let(:send_window2) do
|
|
31
|
-
Window.new(65_535)
|
|
32
|
-
end
|
|
33
|
-
let(:streams_ctx2) do
|
|
34
|
-
streams_ctx = StreamsContext.new(do_nothing_proc)
|
|
35
|
-
streams_ctx.new_context(1, 65_535, 65_535)
|
|
36
|
-
streams_ctx.new_context(2, 65_535, 65_535)
|
|
37
|
-
streams_ctx
|
|
38
|
-
end
|
|
39
|
-
it 'should take' do
|
|
40
|
-
datas = data_buffer2.take!(send_window2, streams_ctx2, 16_384)
|
|
41
|
-
expect(datas.length).to eq 2
|
|
42
|
-
expect(datas.map(&:stream_id)).to eq [1, 2]
|
|
43
|
-
expect(datas.map(&:data)).to eq %w[one two]
|
|
44
|
-
expect(send_window2.length).to eq 65_535 - 6
|
|
45
|
-
expect(streams_ctx2[1].send_window.length).to eq 65_535 - 3
|
|
46
|
-
expect(streams_ctx2[2].send_window.length).to eq 65_535 - 3
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
let(:data_buffer3) do
|
|
50
|
-
data_buffer = DataBuffer.new
|
|
51
|
-
data_buffer.store(2, 'two')
|
|
52
|
-
data_buffer
|
|
53
|
-
end
|
|
54
|
-
let(:send_window3) do
|
|
55
|
-
Window.new(65_535)
|
|
56
|
-
end
|
|
57
|
-
let(:streams_ctx3) do
|
|
58
|
-
streams_ctx = StreamsContext.new(do_nothing_proc)
|
|
59
|
-
streams_ctx.new_context(1, 65_535, 65_535)
|
|
60
|
-
streams_ctx.new_context(2, 65_535, 65_535)
|
|
61
|
-
streams_ctx
|
|
62
|
-
end
|
|
63
|
-
it 'should take' do
|
|
64
|
-
datas = data_buffer3.take!(send_window3, streams_ctx3, 16_384)
|
|
65
|
-
expect(datas.length).to eq 1
|
|
66
|
-
expect(datas.first.stream_id).to eq 2
|
|
67
|
-
expect(datas.first.data).to eq 'two'
|
|
68
|
-
expect(send_window3.length).to eq 65_535 - 3
|
|
69
|
-
expect(streams_ctx3[1].send_window.length).to eq 65_535
|
|
70
|
-
expect(streams_ctx3[2].send_window.length).to eq 65_535 - 3
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
let(:data_buffer4) do
|
|
74
|
-
data_buffer = DataBuffer.new
|
|
75
|
-
data_buffer.store(1, 'one')
|
|
76
|
-
data_buffer.store(2, 'two')
|
|
77
|
-
data_buffer
|
|
78
|
-
end
|
|
79
|
-
let(:send_window4) do
|
|
80
|
-
Window.new(65_535)
|
|
81
|
-
end
|
|
82
|
-
let(:streams_ctx4) do
|
|
83
|
-
streams_ctx = StreamsContext.new(do_nothing_proc)
|
|
84
|
-
streams_ctx.new_context(1, 65_535, 65_535)
|
|
85
|
-
streams_ctx[1].send_window.consume!(65_535)
|
|
86
|
-
streams_ctx.new_context(2, 65_535, 65_535)
|
|
87
|
-
streams_ctx
|
|
88
|
-
end
|
|
89
|
-
it 'should take' do
|
|
90
|
-
datas = data_buffer4.take!(send_window4, streams_ctx4, 16_384)
|
|
91
|
-
expect(datas.length).to eq 1
|
|
92
|
-
expect(datas.first.stream_id).to eq 2
|
|
93
|
-
expect(datas.first.data).to eq 'two'
|
|
94
|
-
expect(send_window4.length).to eq 65_535 - 3
|
|
95
|
-
expect(streams_ctx4[1].send_window.length).to eq 0
|
|
96
|
-
expect(streams_ctx4[2].send_window.length).to eq 65_535 - 3
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
let(:data_buffer5) do
|
|
100
|
-
data_buffer = DataBuffer.new
|
|
101
|
-
data_buffer.store(1, 'one')
|
|
102
|
-
data_buffer.store(2, 'two')
|
|
103
|
-
data_buffer
|
|
104
|
-
end
|
|
105
|
-
let(:send_window5) do
|
|
106
|
-
send_window = Window.new(65_535)
|
|
107
|
-
send_window.consume!(65_535)
|
|
108
|
-
send_window
|
|
109
|
-
end
|
|
110
|
-
let(:streams_ctx5) do
|
|
111
|
-
streams_ctx = StreamsContext.new(do_nothing_proc)
|
|
112
|
-
streams_ctx.new_context(1, 65_535, 65_535)
|
|
113
|
-
streams_ctx.new_context(2, 65_535, 65_535)
|
|
114
|
-
streams_ctx
|
|
115
|
-
end
|
|
116
|
-
it 'should take' do
|
|
117
|
-
expect(data_buffer5.take!(send_window5, streams_ctx5, 16_384).length).to eq 0
|
|
118
|
-
expect(send_window5.length).to eq 0
|
|
119
|
-
expect(streams_ctx5[1].send_window.length).to eq 65_535
|
|
120
|
-
expect(streams_ctx5[2].send_window.length).to eq 65_535
|
|
121
|
-
end
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
context 'has?' do
|
|
125
|
-
let(:data_buffer6) do
|
|
126
|
-
data_buffer = DataBuffer.new
|
|
127
|
-
data_buffer.store(1, 'one')
|
|
128
|
-
data_buffer
|
|
129
|
-
end
|
|
130
|
-
it 'should take' do
|
|
131
|
-
expect(data_buffer6.has?(1)).to eq true
|
|
132
|
-
expect(data_buffer6.has?(2)).to eq false
|
|
133
|
-
end
|
|
134
|
-
end
|
|
135
|
-
end
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
require_relative '../spec_helper'
|
|
2
|
-
|
|
3
|
-
RSpec.describe Frame::Continuation do
|
|
4
|
-
context do
|
|
5
|
-
let(:continuation1) do
|
|
6
|
-
Frame::Continuation.new(false, 50, '')
|
|
7
|
-
end
|
|
8
|
-
it 'should encode' do
|
|
9
|
-
expect(continuation1.to_binary_s).to eq "\x00\x00\x00\x09\x00\x00\x00\x00\x32".b
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
let(:continuation2) do
|
|
13
|
-
Frame::Continuation.new(false, 50, 'this is dummy')
|
|
14
|
-
end
|
|
15
|
-
it 'should encode' do
|
|
16
|
-
expect(continuation2.to_binary_s).to eq "\x00\x00\x0d\x09\x00\x00\x00\x00\x32\x74\x68\x69\x73\x20\x69\x73\x20\x64\x75\x6d\x6d\x79".b
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
let(:continuation3) do
|
|
20
|
-
Frame::Continuation.read(''.b, 0, 50)
|
|
21
|
-
end
|
|
22
|
-
it 'should decode' do
|
|
23
|
-
expect(continuation3.f_type).to eq FrameType::CONTINUATION
|
|
24
|
-
expect(continuation3.end_headers?).to eq false
|
|
25
|
-
expect(continuation3.stream_id).to eq 50
|
|
26
|
-
expect(continuation3.fragment).to eq ''
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
let(:continuation4) do
|
|
30
|
-
Frame::Continuation.read("\x74\x68\x69\x73\x20\x69\x73\x20\x64\x75\x6d\x6d\x79".b, 9, 50)
|
|
31
|
-
end
|
|
32
|
-
it 'should decode' do
|
|
33
|
-
expect(continuation4.f_type).to eq FrameType::CONTINUATION
|
|
34
|
-
expect(continuation4.end_headers?).to eq false
|
|
35
|
-
expect(continuation4.stream_id).to eq 50
|
|
36
|
-
expect(continuation4.fragment).to eq 'this is dummy'
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
data/spec/frame/data_spec.rb
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
require_relative '../spec_helper'
|
|
2
|
-
|
|
3
|
-
RSpec.describe Frame::Data do
|
|
4
|
-
context do
|
|
5
|
-
let(:data1) do
|
|
6
|
-
Frame::Data.new(false, 2, 'Hello, world!', 'Howdy!')
|
|
7
|
-
end
|
|
8
|
-
it 'should encode' do
|
|
9
|
-
expect(data1.to_binary_s).to eq "\x00\x00\x14\x00\x08\x00\x00\x00\x02\x06\x48\x65\x6c\x6c\x6f\x2c\x20\x77\x6f\x72\x6c\x64\x21\x48\x6f\x77\x64\x79\x21".b
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
let(:data2) do
|
|
13
|
-
Frame::Data.read("\x06\x48\x65\x6c\x6c\x6f\x2c\x20\x77\x6f\x72\x6c\x64\x21\x48\x6f\x77\x64\x79\x21".b, 8, 2)
|
|
14
|
-
end
|
|
15
|
-
it 'should decode' do
|
|
16
|
-
expect(data2.f_type).to eq FrameType::DATA
|
|
17
|
-
expect(data2.end_stream?).to eq false
|
|
18
|
-
expect(data2.stream_id).to eq 2
|
|
19
|
-
expect(data2.data).to eq 'Hello, world!'
|
|
20
|
-
expect(data2.padding).to eq 'Howdy!'
|
|
21
|
-
expect(data2.padded?).to eq true
|
|
22
|
-
expect(data2.length).to eq 20
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
data/spec/frame/goaway_spec.rb
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
require_relative '../spec_helper'
|
|
2
|
-
|
|
3
|
-
RSpec.describe Frame::Goaway do
|
|
4
|
-
context do
|
|
5
|
-
let(:goaway1) do
|
|
6
|
-
Frame::Goaway.new(0, 30, 9, 'hpack is broken')
|
|
7
|
-
end
|
|
8
|
-
it 'should encode' do
|
|
9
|
-
expect(goaway1.to_binary_s).to eq "\x00\x00\x17\x07\x00\x00\x00\x00\x00\x00\x00\x00\x1e\x00\x00\x00\x09\x68\x70\x61\x63\x6b\x20\x69\x73\x20\x62\x72\x6f\x6b\x65\x6e".b
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
let(:goaway2) do
|
|
13
|
-
Frame::Goaway.read("\x00\x00\x00\x1e\x00\x00\x00\x09\x68\x70\x61\x63\x6b\x20\x69\x73\x20\x62\x72\x6f\x6b\x65\x6e".b, 7, 0)
|
|
14
|
-
end
|
|
15
|
-
it 'should decode' do
|
|
16
|
-
expect(goaway2.f_type).to eq FrameType::GOAWAY
|
|
17
|
-
expect(goaway2.stream_id).to eq 0
|
|
18
|
-
expect(goaway2.last_stream_id).to eq 30
|
|
19
|
-
expect(goaway2.error_code).to eq 9
|
|
20
|
-
expect(goaway2.debug).to eq 'hpack is broken'
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
data/spec/frame/headers_spec.rb
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
require_relative '../spec_helper'
|
|
2
|
-
|
|
3
|
-
RSpec.describe Frame::Headers do
|
|
4
|
-
context do
|
|
5
|
-
let(:headers1) do
|
|
6
|
-
Frame::Headers.new(true, false, 1, nil, nil, 'this is dummy', nil)
|
|
7
|
-
end
|
|
8
|
-
it 'should encode' do
|
|
9
|
-
expect(headers1.to_binary_s).to eq "\x00\x00\x0d\x01\x04\x00\x00\x00\x01\x74\x68\x69\x73\x20\x69\x73\x20\x64\x75\x6d\x6d\x79".b
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
let(:headers2) do
|
|
13
|
-
Frame::Headers.new(true, false, 3, 20, 10, 'this is dummy', 'This is padding.')
|
|
14
|
-
end
|
|
15
|
-
it 'should encode' do
|
|
16
|
-
expect(headers2.to_binary_s)
|
|
17
|
-
.to eq "\x00\x00\x23\x01\x2c\x00\x00\x00\x03\x10\x00\x00\x00\x14\x0a\x74\x68\x69\x73\x20\x69\x73\x20\x64\x75\x6d\x6d\x79\x54\x68\x69\x73\x20\x69\x73\x20\x70\x61\x64\x64\x69\x6e\x67\x2e".b
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
let(:headers3) do
|
|
21
|
-
Frame::Headers.read("\x74\x68\x69\x73\x20\x69\x73\x20\x64\x75\x6d\x6d\x79".b, 4, 1)
|
|
22
|
-
end
|
|
23
|
-
it 'should decode' do
|
|
24
|
-
expect(headers3.f_type).to eq FrameType::HEADERS
|
|
25
|
-
expect(headers3.end_headers?).to eq true
|
|
26
|
-
expect(headers3.end_stream?).to eq false
|
|
27
|
-
expect(headers3.stream_id).to eq 1
|
|
28
|
-
expect(headers3.stream_dependency).to eq nil
|
|
29
|
-
expect(headers3.weight).to eq nil
|
|
30
|
-
expect(headers3.fragment).to eq 'this is dummy'
|
|
31
|
-
expect(headers3.padding).to eq nil
|
|
32
|
-
expect(headers3.priority?).to eq false
|
|
33
|
-
expect(headers3.padded?).to eq false
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
let(:headers4) do
|
|
37
|
-
Frame::Headers.read("\x10\x00\x00\x00\x14\x0a\x74\x68\x69\x73\x20\x69\x73\x20\x64\x75\x6d\x6d\x79\x54\x68\x69\x73\x20\x69\x73\x20\x70\x61\x64\x64\x69\x6e\x67\x2e".b, 44, 3)
|
|
38
|
-
end
|
|
39
|
-
it 'should decode' do
|
|
40
|
-
expect(headers4.f_type).to eq FrameType::HEADERS
|
|
41
|
-
expect(headers4.end_headers?).to eq true
|
|
42
|
-
expect(headers4.end_stream?).to eq false
|
|
43
|
-
expect(headers4.stream_id).to eq 3
|
|
44
|
-
expect(headers4.stream_dependency).to eq 20
|
|
45
|
-
expect(headers4.weight).to eq 10
|
|
46
|
-
expect(headers4.fragment).to eq 'this is dummy'
|
|
47
|
-
expect(headers4.padding).to eq 'This is padding.'
|
|
48
|
-
expect(headers4.priority?).to eq true
|
|
49
|
-
expect(headers4.padded?).to eq true
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
data/spec/frame/ping_spec.rb
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
require_relative '../spec_helper'
|
|
2
|
-
|
|
3
|
-
RSpec.describe Frame::Ping do
|
|
4
|
-
context do
|
|
5
|
-
let(:ping1) do
|
|
6
|
-
Frame::Ping.new(false, 0, 'deadbeef')
|
|
7
|
-
end
|
|
8
|
-
it 'should encode' do
|
|
9
|
-
expect(ping1.to_binary_s).to eq "\x00\x00\x08\x06\x00\x00\x00\x00\x00\x64\x65\x61\x64\x62\x65\x65\x66".b
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
let(:ping2) do
|
|
13
|
-
Frame::Ping.read("\x64\x65\x61\x64\x62\x65\x65\x66".b, 0, 0)
|
|
14
|
-
end
|
|
15
|
-
it 'should decode' do
|
|
16
|
-
expect(ping2.f_type).to eq FrameType::PING
|
|
17
|
-
expect(ping2.ack?).to eq false
|
|
18
|
-
expect(ping2.stream_id).to eq 0
|
|
19
|
-
expect(ping2.opaque).to eq 'deadbeef'
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
data/spec/frame/priority_spec.rb
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
require_relative '../spec_helper'
|
|
2
|
-
|
|
3
|
-
RSpec.describe Frame::Priority do
|
|
4
|
-
context do
|
|
5
|
-
let(:priority1) do
|
|
6
|
-
Frame::Priority.new(9, 11, 8)
|
|
7
|
-
end
|
|
8
|
-
it 'should encode' do
|
|
9
|
-
expect(priority1.to_binary_s).to eq "\x00\x00\x05\x02\x00\x00\x00\x00\x09\x00\x00\x00\x0b\x08".b
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
let(:priority2) do
|
|
13
|
-
Frame::Priority.read("\x00\x00\x00\x0b\x08".b, 0, 9)
|
|
14
|
-
end
|
|
15
|
-
it 'should decode' do
|
|
16
|
-
expect(priority2.f_type).to eq FrameType::PRIORITY
|
|
17
|
-
expect(priority2.stream_id).to eq 9
|
|
18
|
-
expect(priority2.stream_dependency).to eq 11
|
|
19
|
-
expect(priority2.weight).to eq 8
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
require_relative '../spec_helper'
|
|
2
|
-
|
|
3
|
-
RSpec.describe Frame::PushPromise do
|
|
4
|
-
context do
|
|
5
|
-
let(:push_promise1) do
|
|
6
|
-
Frame::PushPromise.new(true, 10, 12, 'this is dummy', 'Howdy!')
|
|
7
|
-
end
|
|
8
|
-
it 'should encode' do
|
|
9
|
-
expect(push_promise1.to_binary_s).to eq "\x00\x00\x18\x05\x0c\x00\x00\x00\x0a\x06\x00\x00\x00\x0c\x74\x68\x69\x73\x20\x69\x73\x20\x64\x75\x6d\x6d\x79\x48\x6f\x77\x64\x79\x21".b
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
let(:push_promise2) do
|
|
13
|
-
Frame::PushPromise.read("\x06\x00\x00\x00\x0c\x74\x68\x69\x73\x20\x69\x73\x20\x64\x75\x6d\x6d\x79\x48\x6f\x77\x64\x79\x21".b, 12, 10)
|
|
14
|
-
end
|
|
15
|
-
it 'should decode' do
|
|
16
|
-
expect(push_promise2.f_type).to eq FrameType::PUSH_PROMISE
|
|
17
|
-
expect(push_promise2.padded?).to eq true
|
|
18
|
-
expect(push_promise2.stream_id).to eq 10
|
|
19
|
-
expect(push_promise2.promised_stream_id).to eq 12
|
|
20
|
-
expect(push_promise2.fragment).to eq 'this is dummy'
|
|
21
|
-
expect(push_promise2.padding).to eq 'Howdy!'
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
data/spec/frame/read_spec.rb
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
require_relative '../spec_helper'
|
|
2
|
-
|
|
3
|
-
RSpec.describe Frame do
|
|
4
|
-
context do
|
|
5
|
-
let(:empty) do
|
|
6
|
-
StringIO.new(''.b)
|
|
7
|
-
end
|
|
8
|
-
it 'should not read' do
|
|
9
|
-
expect(Frame.read(empty)).to eq nil
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
let(:invalid_header) do
|
|
13
|
-
StringIO.new("\x12\x34\x56\x00\x00".b)
|
|
14
|
-
end
|
|
15
|
-
it 'should not read' do
|
|
16
|
-
expect(Frame.read(invalid_header)).to be_kind_of ConnectionError
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
let(:unknown) do
|
|
20
|
-
StringIO.new("\x00\x00\x01\x0a\x01\x00\x00\x00\x01\xff".b)
|
|
21
|
-
end
|
|
22
|
-
it 'should read' do
|
|
23
|
-
frame = Frame.read(unknown)
|
|
24
|
-
expect(frame.f_type).to eq 0x0a
|
|
25
|
-
expect(frame.flags).to eq 0x01
|
|
26
|
-
expect(frame.stream_id).to eq 0x01
|
|
27
|
-
expect(frame.payload).to eq "\xff".b
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
require_relative '../spec_helper'
|
|
2
|
-
|
|
3
|
-
RSpec.describe Frame::RstStream do
|
|
4
|
-
context do
|
|
5
|
-
let(:rst_stream1) do
|
|
6
|
-
Frame::RstStream.new(5, 8)
|
|
7
|
-
end
|
|
8
|
-
it 'should encode' do
|
|
9
|
-
expect(rst_stream1.to_binary_s).to eq "\x00\x00\x04\x03\x00\x00\x00\x00\x05\x00\x00\x00\x08".b
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
let(:rst_stream2) do
|
|
13
|
-
Frame::RstStream.read("\x00\x00\x00\x08".b, 0, 5)
|
|
14
|
-
end
|
|
15
|
-
it 'should decode' do
|
|
16
|
-
expect(rst_stream2.f_type).to eq FrameType::RST_STREAM
|
|
17
|
-
expect(rst_stream2.stream_id).to eq 5
|
|
18
|
-
expect(rst_stream2.error_code).to eq 8
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
data/spec/frame/settings_spec.rb
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
require_relative '../spec_helper'
|
|
2
|
-
|
|
3
|
-
RSpec.describe Frame::Settings do
|
|
4
|
-
context do
|
|
5
|
-
let(:settings1) do
|
|
6
|
-
Frame::Settings.new(false, 0, { 1 => 8192, 3 => 5000 })
|
|
7
|
-
end
|
|
8
|
-
it 'should encode' do
|
|
9
|
-
expect(settings1.to_binary_s).to eq "\x00\x00\x0c\x04\x00\x00\x00\x00\x00\x00\x01\x00\x00\x20\x00\x00\x03\x00\x00\x13\x88".b
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
let(:settings2) do
|
|
13
|
-
Frame::Settings.read("\x00\x01\x00\x00\x20\x00\x00\x03\x00\x00\x13\x88".b, 0, 0)
|
|
14
|
-
end
|
|
15
|
-
it 'should decode' do
|
|
16
|
-
expect(settings2.f_type).to eq FrameType::SETTINGS
|
|
17
|
-
expect(settings2.ack?).to eq false
|
|
18
|
-
expect(settings2.stream_id).to eq 0
|
|
19
|
-
expect(settings2.setting[1]).to eq 8192
|
|
20
|
-
expect(settings2.setting[3]).to eq 5000
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
require_relative '../spec_helper'
|
|
2
|
-
|
|
3
|
-
RSpec.describe Frame::WindowUpdate do
|
|
4
|
-
context do
|
|
5
|
-
let(:window_update1) do
|
|
6
|
-
Frame::WindowUpdate.new(50, 1000)
|
|
7
|
-
end
|
|
8
|
-
it 'should encode' do
|
|
9
|
-
expect(window_update1.to_binary_s).to eq "\x00\x00\x04\x08\x00\x00\x00\x00\x32\x00\x00\x03\xe8".b
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
let(:window_update2) do
|
|
13
|
-
Frame::WindowUpdate.read("\x00\x00\x03\xe8".b, 0, 50)
|
|
14
|
-
end
|
|
15
|
-
it 'should decode' do
|
|
16
|
-
expect(window_update2.f_type).to eq FrameType::WINDOW_UPDATE
|
|
17
|
-
expect(window_update2.stream_id).to eq 50
|
|
18
|
-
expect(window_update2.window_size_increment).to eq 1000
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|