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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b7732a1022ca5c6c097c2b575ef214e7118d2646
4
- data.tar.gz: 6d9def6bbeb440c2070edb5bd3cc38313cd360fe
3
+ metadata.gz: df6b5bd32b2217bebfb3205cfab1bd78f2a5456d
4
+ data.tar.gz: eb9d683a528819195bf81d4480549b2d8ac7bab6
5
5
  SHA512:
6
- metadata.gz: c166616d45fdf27d87514770287e409dcdc97a5f0e821fe4da970fd99b3487cbbe7b2679d99e055d3b04474eb92bf27cd8655509d5facc55315a351b1a1d2246
7
- data.tar.gz: a6888d5a873081b38bd2245f7c6c1be6cf456b5a39b7adc595b8b693fcac31fc50f3bd876c6293f93c76ec37cdb924aa846562eff71215d5e4af60bf282e452f
6
+ metadata.gz: 686e87ef8beeedd1f3ac1371845b759687231ba62e3bab532d3d15d65febc179bc19f44d4a025708ecc62e2f0e7dd0689cfbbeef19e47c8ee52df9d050066228
7
+ data.tar.gz: 41b003cfeb4a127efcf9d4709167db3ff40934a175a08bd19d23a3874d6dd7e615f99ab967c5b85b521e54a4cdbfce33b4087c6ddde7eebd0d0fc11d18a4d551
@@ -4,7 +4,8 @@ rvm:
4
4
  - 2.1
5
5
  - 2.2
6
6
  - 2.3.0
7
- - jruby-9.0.0.0
7
+ - 2.4.0
8
+ - jruby-9.1.8.0
8
9
  - jruby-head
9
10
  - rbx-2
10
11
  matrix:
@@ -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
- if frame[:type] == :priority
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
@@ -52,9 +52,11 @@ module HTTP2
52
52
  sent = frame_size
53
53
  end
54
54
 
55
- frames = encode ? encode(frame) : [frame]
56
- frames.each { |f| emit(:frame, f) }
57
- @remote_window -= sent
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
 
@@ -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
- @local_window += frame[:increment]
139
- emit(:frame, frame)
135
+ manage_state(frame) do
136
+ @local_window += frame[:increment]
137
+ emit(:frame, frame)
138
+ end
140
139
  else
141
- emit(:frame, frame)
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
@@ -1,3 +1,3 @@
1
1
  module HTTP2
2
- VERSION = '0.8.3'.freeze
2
+ VERSION = '0.8.4'.freeze
3
3
  end
@@ -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.3
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: 2016-12-27 00:00:00.000000000 Z
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.5.1
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: