biryani 0.0.1 → 0.0.3

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.
@@ -6,125 +6,125 @@ RSpec.describe DataBuffer do
6
6
  DataBuffer.new
7
7
  end
8
8
  let(:send_window1) do
9
- Window.new
9
+ Window.new(65_535)
10
10
  end
11
11
  let(:streams_ctx1) do
12
- streams_ctx = StreamsContext.new
13
- streams_ctx.new_context(1, do_nothing_proc)
14
- streams_ctx.new_context(2, do_nothing_proc)
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
15
  streams_ctx
16
16
  end
17
17
  it 'should take' do
18
- expect(data_buffer1.take!(send_window1, streams_ctx1).length).to eq 0
19
- expect(send_window1.length).to eq 2**16 - 1
20
- expect(streams_ctx1[1].send_window.length).to eq 2**16 - 1
21
- expect(streams_ctx1[2].send_window.length).to eq 2**16 - 1
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
22
  end
23
23
 
24
24
  let(:data_buffer2) do
25
25
  data_buffer = DataBuffer.new
26
- data_buffer << Frame::Data.new(false, 1, 'one', nil)
27
- data_buffer << Frame::Data.new(false, 2, 'two', nil)
26
+ data_buffer.store(1, 'one')
27
+ data_buffer.store(2, 'two')
28
28
  data_buffer
29
29
  end
30
30
  let(:send_window2) do
31
- Window.new
31
+ Window.new(65_535)
32
32
  end
33
33
  let(:streams_ctx2) do
34
- streams_ctx = StreamsContext.new
35
- streams_ctx.new_context(1, do_nothing_proc)
36
- streams_ctx.new_context(2, do_nothing_proc)
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
37
  streams_ctx
38
38
  end
39
39
  it 'should take' do
40
- datas = data_buffer2.take!(send_window2, streams_ctx2)
40
+ datas = data_buffer2.take!(send_window2, streams_ctx2, 16_384)
41
41
  expect(datas.length).to eq 2
42
42
  expect(datas.map(&:stream_id)).to eq [1, 2]
43
43
  expect(datas.map(&:data)).to eq %w[one two]
44
- expect(send_window2.length).to eq 2**16 - 7
45
- expect(streams_ctx2[1].send_window.length).to eq 2**16 - 4
46
- expect(streams_ctx2[2].send_window.length).to eq 2**16 - 4
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
47
  end
48
48
 
49
49
  let(:data_buffer3) do
50
50
  data_buffer = DataBuffer.new
51
- data_buffer << Frame::Data.new(false, 2, 'two', nil)
51
+ data_buffer.store(2, 'two')
52
52
  data_buffer
53
53
  end
54
54
  let(:send_window3) do
55
- Window.new
55
+ Window.new(65_535)
56
56
  end
57
57
  let(:streams_ctx3) do
58
- streams_ctx = StreamsContext.new
59
- streams_ctx.new_context(1, do_nothing_proc)
60
- streams_ctx.new_context(2, do_nothing_proc)
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
61
  streams_ctx
62
62
  end
63
63
  it 'should take' do
64
- datas = data_buffer3.take!(send_window3, streams_ctx3)
64
+ datas = data_buffer3.take!(send_window3, streams_ctx3, 16_384)
65
65
  expect(datas.length).to eq 1
66
66
  expect(datas.first.stream_id).to eq 2
67
67
  expect(datas.first.data).to eq 'two'
68
- expect(send_window3.length).to eq 2**16 - 4
69
- expect(streams_ctx3[1].send_window.length).to eq 2**16 - 1
70
- expect(streams_ctx3[2].send_window.length).to eq 2**16 - 4
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
71
  end
72
72
 
73
73
  let(:data_buffer4) do
74
74
  data_buffer = DataBuffer.new
75
- data_buffer << Frame::Data.new(false, 1, 'one', nil)
76
- data_buffer << Frame::Data.new(false, 2, 'two', nil)
75
+ data_buffer.store(1, 'one')
76
+ data_buffer.store(2, 'two')
77
77
  data_buffer
78
78
  end
79
79
  let(:send_window4) do
80
- Window.new
80
+ Window.new(65_535)
81
81
  end
82
82
  let(:streams_ctx4) do
83
- streams_ctx = StreamsContext.new
84
- streams_ctx.new_context(1, do_nothing_proc)
85
- streams_ctx[1].send_window.consume!(2**16 - 1)
86
- streams_ctx.new_context(2, do_nothing_proc)
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
87
  streams_ctx
88
88
  end
89
89
  it 'should take' do
90
- datas = data_buffer4.take!(send_window4, streams_ctx4)
90
+ datas = data_buffer4.take!(send_window4, streams_ctx4, 16_384)
91
91
  expect(datas.length).to eq 1
92
92
  expect(datas.first.stream_id).to eq 2
93
93
  expect(datas.first.data).to eq 'two'
94
- expect(send_window4.length).to eq 2**16 - 4
94
+ expect(send_window4.length).to eq 65_535 - 3
95
95
  expect(streams_ctx4[1].send_window.length).to eq 0
96
- expect(streams_ctx4[2].send_window.length).to eq 2**16 - 4
96
+ expect(streams_ctx4[2].send_window.length).to eq 65_535 - 3
97
97
  end
98
98
 
99
99
  let(:data_buffer5) do
100
100
  data_buffer = DataBuffer.new
101
- data_buffer << Frame::Data.new(false, 1, 'one', nil)
102
- data_buffer << Frame::Data.new(false, 2, 'two', nil)
101
+ data_buffer.store(1, 'one')
102
+ data_buffer.store(2, 'two')
103
103
  data_buffer
104
104
  end
105
105
  let(:send_window5) do
106
- send_window = Window.new
107
- send_window.consume!(2**16 - 1)
106
+ send_window = Window.new(65_535)
107
+ send_window.consume!(65_535)
108
108
  send_window
109
109
  end
110
110
  let(:streams_ctx5) do
111
- streams_ctx = StreamsContext.new
112
- streams_ctx.new_context(1, do_nothing_proc)
113
- streams_ctx.new_context(2, do_nothing_proc)
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
114
  streams_ctx
115
115
  end
116
116
  it 'should take' do
117
- expect(data_buffer5.take!(send_window5, streams_ctx5).length).to eq 0
117
+ expect(data_buffer5.take!(send_window5, streams_ctx5, 16_384).length).to eq 0
118
118
  expect(send_window5.length).to eq 0
119
- expect(streams_ctx5[1].send_window.length).to eq 2**16 - 1
120
- expect(streams_ctx5[2].send_window.length).to eq 2**16 - 1
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
121
  end
122
122
  end
123
123
 
124
124
  context 'has?' do
125
125
  let(:data_buffer6) do
126
126
  data_buffer = DataBuffer.new
127
- data_buffer << Frame::Data.new(false, 1, 'one', nil)
127
+ data_buffer.store(1, 'one')
128
128
  data_buffer
129
129
  end
130
130
  it 'should take' do
@@ -9,8 +9,8 @@ RSpec.describe HPACK::Decoder do
9
9
  it 'should decode' do
10
10
  # https://datatracker.ietf.org/doc/html/rfc7541#appendix-C.3.1
11
11
  expect(decoder.decode([<<HEXDUMP.split.join].pack('H*')
12
- 8286 8441 0f77 7777 2e65 7861 6d70 6c65
13
- 2e63 6f6d
12
+ 8286 8441 0f77 7777 2e65 7861 6d70 6c65
13
+ 2e63 6f6d
14
14
  HEXDUMP
15
15
  )).to eq [
16
16
  [':method', 'GET'],
@@ -20,7 +20,7 @@ HEXDUMP
20
20
  ]
21
21
  # https://datatracker.ietf.org/doc/html/rfc7541#appendix-C.3.2
22
22
  expect(decoder.decode([<<HEXDUMP.split.join].pack('H*')
23
- 8286 84be 5808 6e6f 2d63 6163 6865
23
+ 8286 84be 5808 6e6f 2d63 6163 6865
24
24
  HEXDUMP
25
25
  )).to eq [
26
26
  [':method', 'GET'],
@@ -31,8 +31,8 @@ HEXDUMP
31
31
  ]
32
32
  # https://datatracker.ietf.org/doc/html/rfc7541#appendix-C.3.3
33
33
  expect(decoder.decode([<<HEXDUMP.split.join].pack('H*')
34
- 8287 85bf 400a 6375 7374 6f6d 2d6b 6579
35
- 0c63 7573 746f 6d2d 7661 6c75 65
34
+ 8287 85bf 400a 6375 7374 6f6d 2d6b 6579
35
+ 0c63 7573 746f 6d2d 7661 6c75 65
36
36
  HEXDUMP
37
37
  )).to eq [
38
38
  [':method', 'GET'],
@@ -46,8 +46,8 @@ HEXDUMP
46
46
  it 'should decode' do
47
47
  # https://datatracker.ietf.org/doc/html/rfc7541#appendix-C.4.1
48
48
  expect(decoder.decode([<<HEXDUMP.split.join].pack('H*')
49
- 8286 8441 8cf1 e3c2 e5f2 3a6b a0ab 90f4
50
- ff
49
+ 8286 8441 8cf1 e3c2 e5f2 3a6b a0ab 90f4
50
+ ff
51
51
  HEXDUMP
52
52
  )).to eq [
53
53
  [':method', 'GET'],
@@ -57,7 +57,7 @@ HEXDUMP
57
57
  ]
58
58
  # https://datatracker.ietf.org/doc/html/rfc7541#appendix-C.4.2
59
59
  expect(decoder.decode([<<HEXDUMP.split.join].pack('H*')
60
- 8286 84be 5886 a8eb 1064 9cbf
60
+ 8286 84be 5886 a8eb 1064 9cbf
61
61
  HEXDUMP
62
62
  )).to eq [
63
63
  [':method', 'GET'],
@@ -68,8 +68,8 @@ HEXDUMP
68
68
  ]
69
69
  # https://datatracker.ietf.org/doc/html/rfc7541#appendix-C.4.3
70
70
  expect(decoder.decode([<<HEXDUMP.split.join].pack('H*')
71
- 8287 85bf 4088 25a8 49e9 5ba9 7d7f 8925
72
- a849 e95b b8e8 b4bf
71
+ 8287 85bf 4088 25a8 49e9 5ba9 7d7f 8925
72
+ a849 e95b b8e8 b4bf
73
73
  HEXDUMP
74
74
  )).to eq [
75
75
  [':method', 'GET'],
@@ -83,11 +83,11 @@ HEXDUMP
83
83
  it 'should decode' do
84
84
  # https://datatracker.ietf.org/doc/html/rfc7541#appendix-C.5.1
85
85
  expect(decoder.decode([<<HEXDUMP.split.join].pack('H*')
86
- 4803 3330 3258 0770 7269 7661 7465 611d
87
- 4d6f 6e2c 2032 3120 4f63 7420 3230 3133
88
- 2032 303a 3133 3a32 3120 474d 546e 1768
89
- 7474 7073 3a2f 2f77 7777 2e65 7861 6d70
90
- 6c65 2e63 6f6d
86
+ 4803 3330 3258 0770 7269 7661 7465 611d
87
+ 4d6f 6e2c 2032 3120 4f63 7420 3230 3133
88
+ 2032 303a 3133 3a32 3120 474d 546e 1768
89
+ 7474 7073 3a2f 2f77 7777 2e65 7861 6d70
90
+ 6c65 2e63 6f6d
91
91
  HEXDUMP
92
92
  )).to eq [
93
93
  [':status', '302'],
@@ -97,7 +97,7 @@ HEXDUMP
97
97
  ]
98
98
  # https://datatracker.ietf.org/doc/html/rfc7541#appendix-C.5.2
99
99
  expect(decoder.decode([<<HEXDUMP.split.join].pack('H*')
100
- 4803 3330 37c1 c0bf
100
+ 4803 3330 37c1 c0bf
101
101
  HEXDUMP
102
102
  )).to eq [
103
103
  [':status', '307'],
@@ -107,13 +107,13 @@ HEXDUMP
107
107
  ]
108
108
  # https://datatracker.ietf.org/doc/html/rfc7541#appendix-C.5.3
109
109
  expect(decoder.decode([<<HEXDUMP.split.join].pack('H*')
110
- 88c1 611d 4d6f 6e2c 2032 3120 4f63 7420
111
- 3230 3133 2032 303a 3133 3a32 3220 474d
112
- 54c0 5a04 677a 6970 7738 666f 6f3d 4153
113
- 444a 4b48 514b 425a 584f 5157 454f 5049
114
- 5541 5851 5745 4f49 553b 206d 6178 2d61
115
- 6765 3d33 3630 303b 2076 6572 7369 6f6e
116
- 3d31
110
+ 88c1 611d 4d6f 6e2c 2032 3120 4f63 7420
111
+ 3230 3133 2032 303a 3133 3a32 3220 474d
112
+ 54c0 5a04 677a 6970 7738 666f 6f3d 4153
113
+ 444a 4b48 514b 425a 584f 5157 454f 5049
114
+ 5541 5851 5745 4f49 553b 206d 6178 2d61
115
+ 6765 3d33 3630 303b 2076 6572 7369 6f6e
116
+ 3d31
117
117
  HEXDUMP
118
118
  )).to eq [
119
119
  [':status', '200'],
@@ -128,10 +128,10 @@ HEXDUMP
128
128
  it 'should decode' do
129
129
  # https://datatracker.ietf.org/doc/html/rfc7541#appendix-C.6.1
130
130
  expect(decoder.decode([<<HEXDUMP.split.join].pack('H*')
131
- 4882 6402 5885 aec3 771a 4b61 96d0 7abe
132
- 9410 54d4 44a8 2005 9504 0b81 66e0 82a6
133
- 2d1b ff6e 919d 29ad 1718 63c7 8f0b 97c8
134
- e9ae 82ae 43d3
131
+ 4882 6402 5885 aec3 771a 4b61 96d0 7abe
132
+ 9410 54d4 44a8 2005 9504 0b81 66e0 82a6
133
+ 2d1b ff6e 919d 29ad 1718 63c7 8f0b 97c8
134
+ e9ae 82ae 43d3
135
135
  HEXDUMP
136
136
  )).to eq [
137
137
  [':status', '302'],
@@ -141,7 +141,7 @@ HEXDUMP
141
141
  ]
142
142
  # https://datatracker.ietf.org/doc/html/rfc7541#appendix-C.6.2
143
143
  expect(decoder.decode([<<HEXDUMP.split.join].pack('H*')
144
- 4883 640e ffc1 c0bf
144
+ 4883 640e ffc1 c0bf
145
145
  HEXDUMP
146
146
  )).to eq [
147
147
  [':status', '307'],
@@ -151,11 +151,11 @@ HEXDUMP
151
151
  ]
152
152
  # https://datatracker.ietf.org/doc/html/rfc7541#appendix-C.6.3
153
153
  expect(decoder.decode([<<HEXDUMP.split.join].pack('H*')
154
- 88c1 6196 d07a be94 1054 d444 a820 0595
155
- 040b 8166 e084 a62d 1bff c05a 839b d9ab
156
- 77ad 94e7 821d d7f2 e6c7 b335 dfdf cd5b
157
- 3960 d5af 2708 7f36 72c1 ab27 0fb5 291f
158
- 9587 3160 65c0 03ed 4ee5 b106 3d50 07
154
+ 88c1 6196 d07a be94 1054 d444 a820 0595
155
+ 040b 8166 e084 a62d 1bff c05a 839b d9ab
156
+ 77ad 94e7 821d d7f2 e6c7 b335 dfdf cd5b
157
+ 3960 d5af 2708 7f36 72c1 ab27 0fb5 291f
158
+ 9587 3160 65c0 03ed 4ee5 b106 3d50 07
159
159
  HEXDUMP
160
160
  )).to eq [
161
161
  [':status', '200'],
@@ -14,10 +14,10 @@ RSpec.describe HPACK::Encoder do
14
14
  ['date', 'Mon, 21 Oct 2013 20:13:21 GMT'],
15
15
  ['location', 'https://www.example.com']
16
16
  ])).to eq [<<HEXDUMP.split.join].pack('H*')
17
- 4882 6402 5885 aec3 771a 4b61 96d0 7abe
18
- 9410 54d4 44a8 2005 9504 0b81 66e0 82a6
19
- 2d1b ff6e 919d 29ad 1718 63c7 8f0b 97c8
20
- e9ae 82ae 43d3
17
+ 4882 6402 5885 aec3 771a 4b61 96d0 7abe
18
+ 9410 54d4 44a8 2005 9504 0b81 66e0 82a6
19
+ 2d1b ff6e 919d 29ad 1718 63c7 8f0b 97c8
20
+ e9ae 82ae 43d3
21
21
  HEXDUMP
22
22
  # https://datatracker.ietf.org/doc/html/rfc7541#appendix-C.6.2
23
23
  expect(encoder.encode([
@@ -26,7 +26,7 @@ HEXDUMP
26
26
  ['date', 'Mon, 21 Oct 2013 20:13:21 GMT'],
27
27
  ['location', 'https://www.example.com']
28
28
  ])).to eq [<<HEXDUMP.split.join].pack('H*')
29
- 4883 640e ffc1 c0bf
29
+ 4883 640e ffc1 c0bf
30
30
  HEXDUMP
31
31
  # https://datatracker.ietf.org/doc/html/rfc7541#appendix-C.6.3
32
32
  expect(encoder.encode([
@@ -37,11 +37,11 @@ HEXDUMP
37
37
  ['content-encoding', 'gzip'],
38
38
  ['set-cookie', 'foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1']
39
39
  ])).to eq [<<HEXDUMP.split.join].pack('H*')
40
- 88c1 6196 d07a be94 1054 d444 a820 0595
41
- 040b 8166 e084 a62d 1bff c05a 839b d9ab
42
- 77ad 94e7 821d d7f2 e6c7 b335 dfdf cd5b
43
- 3960 d5af 2708 7f36 72c1 ab27 0fb5 291f
44
- 9587 3160 65c0 03ed 4ee5 b106 3d50 07
40
+ 88c1 6196 d07a be94 1054 d444 a820 0595
41
+ 040b 8166 e084 a62d 1bff c05a 839b d9ab
42
+ 77ad 94e7 821d d7f2 e6c7 b335 dfdf cd5b
43
+ 3960 d5af 2708 7f36 72c1 ab27 0fb5 291f
44
+ 9587 3160 65c0 03ed 4ee5 b106 3d50 07
45
45
  HEXDUMP
46
46
  end
47
47
  end
@@ -7,9 +7,9 @@ RSpec.describe HPACK::Fields do
7
7
  end
8
8
  it 'should decode' do
9
9
  expect(HPACK::Fields.decode([<<HEXDUMP.split.join].pack('H*'),
10
- 8286 8441 8a08 9d5c 0b81 70dc 79e7
11
- 9e40 8721 eaa8 a449 8f57 88ea 52d6
12
- b0e8 3772 ff
10
+ 8286 8441 8a08 9d5c 0b81 70dc 79e7
11
+ 9e40 8721 eaa8 a449 8f57 88ea 52d6
12
+ b0e8 3772 ff
13
13
  HEXDUMP
14
14
  dynamic_table)).to eq [[':method', 'GET'], [':scheme', 'http'], [':path', '/'], [':authority', '127.0.0.1:8888'], ['connection', 'keep-alive']]
15
15
  end
@@ -0,0 +1,79 @@
1
+ require_relative 'spec_helper'
2
+
3
+ RSpec.describe StreamsContext do
4
+ context 'close_all' 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
+ it 'should close' do
12
+ streams_ctx.close_all
13
+ expect { streams_ctx[1].tx << nil }.to raise_error Ractor::ClosedError
14
+ expect { streams_ctx[2].tx << nil }.to raise_error Ractor::ClosedError
15
+ end
16
+ end
17
+
18
+ context 'close_all' do
19
+ let(:streams_ctx) do
20
+ streams_ctx = StreamsContext.new(do_nothing_proc)
21
+ streams_ctx.new_context(1, 65_535, 65_535)
22
+ streams_ctx.new_context(2, 65_535, 65_535)
23
+ streams_ctx
24
+ end
25
+ it 'should close' do
26
+ streams_ctx.close_all
27
+ expect { streams_ctx[1].tx << nil }.to raise_error Ractor::ClosedError
28
+ expect { streams_ctx[2].tx << nil }.to raise_error Ractor::ClosedError
29
+ end
30
+ end
31
+
32
+ context 'remove_closed' do
33
+ let(:streams_ctx1) 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
+ let(:data_buffer1) do
40
+ DataBuffer.new
41
+ end
42
+ it 'should remove' do
43
+ streams_ctx1.remove_closed(data_buffer1)
44
+ expect(streams_ctx1.length).to eq 2
45
+ end
46
+
47
+ let(:streams_ctx2) do
48
+ streams_ctx = StreamsContext.new(do_nothing_proc)
49
+ streams_ctx.new_context(1, 65_535, 65_535)
50
+ streams_ctx.new_context(2, 65_535, 65_535)
51
+ streams_ctx[2].state.close
52
+ streams_ctx
53
+ end
54
+ let(:data_buffer2) do
55
+ DataBuffer.new
56
+ end
57
+ it 'should remove' do
58
+ streams_ctx2.remove_closed(data_buffer2)
59
+ expect(streams_ctx2.length).to eq 2 # remain stream_id
60
+ end
61
+
62
+ let(:streams_ctx3) do
63
+ streams_ctx = StreamsContext.new(do_nothing_proc)
64
+ streams_ctx.new_context(1, 65_535, 65_535)
65
+ streams_ctx.new_context(2, 65_535, 65_535)
66
+ streams_ctx[2].state.close
67
+ streams_ctx
68
+ end
69
+ let(:data_buffer3) do
70
+ data_buffer = DataBuffer.new
71
+ data_buffer.store(2, 'two')
72
+ data_buffer
73
+ end
74
+ it 'should remove' do
75
+ streams_ctx3.remove_closed(data_buffer3)
76
+ expect(streams_ctx3.length).to eq 2
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,41 @@
1
+ require_relative 'spec_helper'
2
+
3
+ RSpec.describe Biryani do
4
+ let(:data) do
5
+ Frame::Data.new(false, 2, 'Hello, world!', 'Howdy!')
6
+ end
7
+ let(:connection_error) do
8
+ ConnectionError.new(ErrorCode::NO_ERROR, 'debug')
9
+ end
10
+ let(:stream_error) do
11
+ StreamError.new(ErrorCode::NO_ERROR, 1, 'debug')
12
+ end
13
+
14
+ context 'err?' do
15
+ it 'should be not error' do
16
+ expect(Biryani.err?(data)).to eq false
17
+ end
18
+
19
+ it 'should be error' do
20
+ expect(Biryani.err?(connection_error)).to be true
21
+ end
22
+
23
+ it 'should be error' do
24
+ expect(Biryani.err?(stream_error)).to be true
25
+ end
26
+ end
27
+
28
+ context 'unwrap' do
29
+ it 'should unwrap' do
30
+ expect(Biryani.unwrap(data, 0x01)).to eq data
31
+ end
32
+
33
+ it 'should unwrap' do
34
+ expect(Biryani.unwrap(connection_error, 0x01)).to be_kind_of Frame::Goaway
35
+ end
36
+
37
+ it 'should unwrap' do
38
+ expect(Biryani.unwrap(stream_error, 0x01)).to be_kind_of Frame::RstStream
39
+ end
40
+ end
41
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: biryani
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - thekuwayama
@@ -75,19 +75,19 @@ files:
75
75
  - lib/biryani/stream.rb
76
76
  - lib/biryani/stream_error.rb
77
77
  - lib/biryani/streams_context.rb
78
+ - lib/biryani/utils.rb
78
79
  - lib/biryani/version.rb
79
80
  - lib/biryani/window.rb
80
- - spec/connection/close_all_streams_spec.rb
81
81
  - spec/connection/handle_connection_window_update_spec.rb
82
+ - spec/connection/handle_data_spec.rb
83
+ - spec/connection/handle_headers_spec.rb
82
84
  - spec/connection/handle_ping_spec.rb
83
85
  - spec/connection/handle_rst_stream_spec.rb
84
86
  - spec/connection/handle_settings_spec.rb
85
87
  - spec/connection/handle_stream_window_update_spec.rb
86
88
  - spec/connection/read_http2_magic_spec.rb
87
- - spec/connection/remove_closed_streams_spec.rb
88
89
  - spec/connection/send_spec.rb
89
90
  - spec/connection/transition_state_send_spec.rb
90
- - spec/connection/unwrap_spec.rb
91
91
  - spec/data_buffer_spec.rb
92
92
  - spec/frame/continuation_spec.rb
93
93
  - spec/frame/data_spec.rb
@@ -109,6 +109,8 @@ files:
109
109
  - spec/hpack/string_spec.rb
110
110
  - spec/http_request_builder_spec.rb
111
111
  - spec/spec_helper.rb
112
+ - spec/streams_context_spec.rb
113
+ - spec/utils_spec.rb
112
114
  homepage: https://github.com/thekuwayama/biryani
113
115
  licenses:
114
116
  - MIT
@@ -131,17 +133,16 @@ rubygems_version: 4.0.3
131
133
  specification_version: 4
132
134
  summary: An HTTP/2 server implemented using Ruby Ractor
133
135
  test_files:
134
- - spec/connection/close_all_streams_spec.rb
135
136
  - spec/connection/handle_connection_window_update_spec.rb
137
+ - spec/connection/handle_data_spec.rb
138
+ - spec/connection/handle_headers_spec.rb
136
139
  - spec/connection/handle_ping_spec.rb
137
140
  - spec/connection/handle_rst_stream_spec.rb
138
141
  - spec/connection/handle_settings_spec.rb
139
142
  - spec/connection/handle_stream_window_update_spec.rb
140
143
  - spec/connection/read_http2_magic_spec.rb
141
- - spec/connection/remove_closed_streams_spec.rb
142
144
  - spec/connection/send_spec.rb
143
145
  - spec/connection/transition_state_send_spec.rb
144
- - spec/connection/unwrap_spec.rb
145
146
  - spec/data_buffer_spec.rb
146
147
  - spec/frame/continuation_spec.rb
147
148
  - spec/frame/data_spec.rb
@@ -163,3 +164,5 @@ test_files:
163
164
  - spec/hpack/string_spec.rb
164
165
  - spec/http_request_builder_spec.rb
165
166
  - spec/spec_helper.rb
167
+ - spec/streams_context_spec.rb
168
+ - spec/utils_spec.rb
@@ -1,17 +0,0 @@
1
- require_relative '../spec_helper'
2
-
3
- RSpec.describe Connection do
4
- context 'close_all_streams' do
5
- let(:streams_ctx) do
6
- streams_ctx = StreamsContext.new
7
- streams_ctx.new_context(1, do_nothing_proc)
8
- streams_ctx.new_context(2, do_nothing_proc)
9
- streams_ctx
10
- end
11
- it 'should close' do
12
- Connection.close_all_streams(streams_ctx)
13
- expect { streams_ctx[1].tx << nil }.to raise_error Ractor::ClosedError
14
- expect { streams_ctx[2].tx << nil }.to raise_error Ractor::ClosedError
15
- end
16
- end
17
- end
@@ -1,51 +0,0 @@
1
- require_relative '../spec_helper'
2
-
3
- RSpec.describe Connection do
4
- context 'remove_closed_streams' do
5
- let(:streams_ctx1) do
6
- streams_ctx = StreamsContext.new
7
- streams_ctx.new_context(1, do_nothing_proc)
8
- streams_ctx.new_context(2, do_nothing_proc)
9
- streams_ctx
10
- end
11
- let(:data_buffer1) do
12
- DataBuffer.new
13
- end
14
- it 'should close' do
15
- Connection.remove_closed_streams(streams_ctx1, data_buffer1)
16
- expect(streams_ctx1.length).to eq 2
17
- end
18
-
19
- let(:streams_ctx2) do
20
- streams_ctx = StreamsContext.new
21
- streams_ctx.new_context(1, do_nothing_proc)
22
- streams_ctx.new_context(2, do_nothing_proc)
23
- streams_ctx[2].state.close
24
- streams_ctx
25
- end
26
- let(:data_buffer2) do
27
- DataBuffer.new
28
- end
29
- it 'should close' do
30
- Connection.remove_closed_streams(streams_ctx2, data_buffer2)
31
- expect(streams_ctx2.length).to eq 2 # remain stream_id
32
- end
33
-
34
- let(:streams_ctx3) do
35
- streams_ctx = StreamsContext.new
36
- streams_ctx.new_context(1, do_nothing_proc)
37
- streams_ctx.new_context(2, do_nothing_proc)
38
- streams_ctx[2].state.close
39
- streams_ctx
40
- end
41
- let(:data_buffer3) do
42
- data_buffer = DataBuffer.new
43
- data_buffer << Frame::Data.new(false, 2, 'two', nil)
44
- data_buffer
45
- end
46
- it 'should close' do
47
- Connection.remove_closed_streams(streams_ctx3, data_buffer3)
48
- expect(streams_ctx3.length).to eq 2
49
- end
50
- end
51
- end
@@ -1,28 +0,0 @@
1
- require_relative '../spec_helper'
2
-
3
- RSpec.describe Connection do
4
- context 'unwrap' do
5
- let(:data) do
6
- Frame::Data.new(false, 2, 'Hello, world!', 'Howdy!')
7
- end
8
- it 'should ensure' do
9
- expect(Connection.unwrap(data, 0x01)).to eq data
10
- end
11
-
12
- let(:connection_error) do
13
- ConnectionError.new(ErrorCode::NO_ERROR, 'debug')
14
- end
15
- it 'should ensure' do
16
- frame = Connection.unwrap(connection_error, 0x01)
17
- expect(frame).to be_kind_of Frame::Goaway
18
- end
19
-
20
- let(:stream_error) do
21
- StreamError.new(ErrorCode::NO_ERROR, 0x01, 'debug')
22
- end
23
- it 'should ensure' do
24
- frame = Connection.unwrap(stream_error, 0x01)
25
- expect(frame).to be_kind_of Frame::RstStream
26
- end
27
- end
28
- end