http-2 0.8.3 → 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -1
- data/lib/http/2/connection.rb +16 -3
- data/lib/http/2/flow_buffer.rb +5 -3
- data/lib/http/2/stream.rb +14 -8
- data/lib/http/2/version.rb +1 -1
- data/spec/stream_spec.rb +24 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df6b5bd32b2217bebfb3205cfab1bd78f2a5456d
|
4
|
+
data.tar.gz: eb9d683a528819195bf81d4480549b2d8ac7bab6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 686e87ef8beeedd1f3ac1371845b759687231ba62e3bab532d3d15d65febc179bc19f44d4a025708ecc62e2f0e7dd0689cfbbeef19e47c8ee52df9d050066228
|
7
|
+
data.tar.gz: 41b003cfeb4a127efcf9d4709167db3ff40934a175a08bd19d23a3874d6dd7e615f99ab967c5b85b521e54a4cdbfce33b4087c6ddde7eebd0d0fc11d18a4d551
|
data/.travis.yml
CHANGED
data/lib/http/2/connection.rb
CHANGED
@@ -313,11 +313,12 @@ module HTTP2
|
|
313
313
|
if (stream = @streams[frame[:stream]])
|
314
314
|
stream << frame
|
315
315
|
else
|
316
|
+
case frame[:type]
|
316
317
|
# The PRIORITY frame can be sent for a stream in the "idle" or
|
317
318
|
# "closed" state. This allows for the reprioritization of a
|
318
319
|
# group of dependent streams by altering the priority of an
|
319
320
|
# unused or closed parent stream.
|
320
|
-
|
321
|
+
when :priority
|
321
322
|
stream = activate_stream(
|
322
323
|
id: frame[:stream],
|
323
324
|
weight: frame[:weight] || DEFAULT_WEIGHT,
|
@@ -327,6 +328,14 @@ module HTTP2
|
|
327
328
|
|
328
329
|
emit(:stream, stream)
|
329
330
|
stream << frame
|
331
|
+
|
332
|
+
# WINDOW_UPDATE can be sent by a peer that has sent a frame
|
333
|
+
# bearing the END_STREAM flag. This means that a receiver could
|
334
|
+
# receive a WINDOW_UPDATE frame on a "half-closed (remote)" or
|
335
|
+
# "closed" stream. A receiver MUST NOT treat this as an error
|
336
|
+
# (see Section 5.1).
|
337
|
+
when :window_update
|
338
|
+
process_window_update(frame)
|
330
339
|
else
|
331
340
|
# An endpoint that receives an unexpected stream identifier
|
332
341
|
# MUST respond with a connection error of type PROTOCOL_ERROR.
|
@@ -549,9 +558,9 @@ module HTTP2
|
|
549
558
|
# Setting header table size might cause some headers evicted
|
550
559
|
case side
|
551
560
|
when :local
|
552
|
-
@decompressor.table_size = v
|
553
|
-
when :remote
|
554
561
|
@compressor.table_size = v
|
562
|
+
when :remote
|
563
|
+
@decompressor.table_size = v
|
555
564
|
end
|
556
565
|
|
557
566
|
when :settings_enable_push
|
@@ -680,5 +689,9 @@ module HTTP2
|
|
680
689
|
backtrace = (e && e.backtrace) || []
|
681
690
|
fail Error.const_get(klass), msg, backtrace
|
682
691
|
end
|
692
|
+
|
693
|
+
def manage_state(_)
|
694
|
+
yield
|
695
|
+
end
|
683
696
|
end
|
684
697
|
end
|
data/lib/http/2/flow_buffer.rb
CHANGED
@@ -52,9 +52,11 @@ module HTTP2
|
|
52
52
|
sent = frame_size
|
53
53
|
end
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
55
|
+
manage_state(frame) do
|
56
|
+
frames = encode ? encode(frame) : [frame]
|
57
|
+
frames.each { |f| emit(:frame, f) }
|
58
|
+
@remote_window -= sent
|
59
|
+
end
|
58
60
|
end
|
59
61
|
end
|
60
62
|
|
data/lib/http/2/stream.rb
CHANGED
@@ -125,9 +125,6 @@ module HTTP2
|
|
125
125
|
#
|
126
126
|
# @param frame [Hash]
|
127
127
|
def send(frame)
|
128
|
-
transition(frame, true)
|
129
|
-
frame[:stream] ||= @id
|
130
|
-
|
131
128
|
process_priority(frame) if frame[:type] == :priority
|
132
129
|
|
133
130
|
case frame[:type]
|
@@ -135,13 +132,15 @@ module HTTP2
|
|
135
132
|
# @remote_window is maintained in send_data
|
136
133
|
send_data(frame)
|
137
134
|
when :window_update
|
138
|
-
|
139
|
-
|
135
|
+
manage_state(frame) do
|
136
|
+
@local_window += frame[:increment]
|
137
|
+
emit(:frame, frame)
|
138
|
+
end
|
140
139
|
else
|
141
|
-
|
140
|
+
manage_state(frame) do
|
141
|
+
emit(:frame, frame)
|
142
|
+
end
|
142
143
|
end
|
143
|
-
|
144
|
-
complete_transition(frame)
|
145
144
|
end
|
146
145
|
|
147
146
|
# Sends a HEADERS frame containing HTTP response headers.
|
@@ -603,5 +602,12 @@ module HTTP2
|
|
603
602
|
klass = error.to_s.split('_').map(&:capitalize).join
|
604
603
|
fail Error.const_get(klass), msg
|
605
604
|
end
|
605
|
+
|
606
|
+
def manage_state(frame)
|
607
|
+
transition(frame, true)
|
608
|
+
frame[:stream] ||= @id
|
609
|
+
yield
|
610
|
+
complete_transition(frame)
|
611
|
+
end
|
606
612
|
end
|
607
613
|
end
|
data/lib/http/2/version.rb
CHANGED
data/spec/stream_spec.rb
CHANGED
@@ -378,6 +378,30 @@ RSpec.describe HTTP2::Stream do
|
|
378
378
|
end
|
379
379
|
end
|
380
380
|
|
381
|
+
it 'should not transition to closed if END_STREAM flag is sent when overflowing window' do
|
382
|
+
@stream.on(:close) { fail 'should not have closed' }
|
383
|
+
data = { type: :data, flags: [], stream: @stream.id }
|
384
|
+
4.times do
|
385
|
+
data = data.merge(flags: [:end_stream]) if @stream.remote_window < 16_384
|
386
|
+
@stream.send data.merge(payload: 'x' * 16_384)
|
387
|
+
end
|
388
|
+
end
|
389
|
+
|
390
|
+
it 'should transition to closed when send buffer is emptied' do
|
391
|
+
o = Object.new
|
392
|
+
expect(o).to receive(:tap).once
|
393
|
+
@stream.on(:close) do
|
394
|
+
expect(@stream.buffered_amount).to eq 0
|
395
|
+
o.tap
|
396
|
+
end
|
397
|
+
data = { type: :data, flags: [], stream: @stream.id }
|
398
|
+
4.times do
|
399
|
+
data = data.merge(flags: [:end_stream]) if @stream.remote_window < 16_384
|
400
|
+
@stream.send data.merge(payload: 'x' * 16_384)
|
401
|
+
end
|
402
|
+
@client << Framer.new.generate(type: :window_update, stream: @stream.id, increment: 16_384)
|
403
|
+
end
|
404
|
+
|
381
405
|
it 'should transition to closed if RST_STREAM is sent' do
|
382
406
|
@stream.close
|
383
407
|
expect(@stream.state).to eq :closed
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http-2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya Grigorik
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-05-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
104
|
version: '0'
|
105
105
|
requirements: []
|
106
106
|
rubyforge_project:
|
107
|
-
rubygems_version: 2.
|
107
|
+
rubygems_version: 2.6.11
|
108
108
|
signing_key:
|
109
109
|
specification_version: 4
|
110
110
|
summary: Pure-ruby HTTP 2.0 protocol implementation
|
@@ -124,4 +124,3 @@ test_files:
|
|
124
124
|
- spec/stream_spec.rb
|
125
125
|
- spec/support/deep_dup.rb
|
126
126
|
- spec/support/duplicable.rb
|
127
|
-
has_rdoc:
|