http-2 0.8.1 → 0.8.2

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: 5e4d8a543b24380552462863450caaa90dcc5d1f
4
- data.tar.gz: 5948ffc6c3aa27f7d81bd86cd0ef62ad163e412f
3
+ metadata.gz: 90034b82f924807e4b3cb874fceae2d8fde0c74d
4
+ data.tar.gz: afe0a06580910045bd50d8920f1aaf2e7f5a9a01
5
5
  SHA512:
6
- metadata.gz: 32a27c2213a6c8b18b56f752495a938d65260c63644be63af58fd0aaf133795bf9e2748d23fe8b8c49bf96500e30a551ac0001001a1fe46a2082f06d8420dcc8
7
- data.tar.gz: 2fdc75f407ecb70fb601a04d9c8fe5b76e23bebafc495e48bf2a1e3d96ada6d1784ed29a9c352cfa04027ebd5dace72779fc009b1cd0f87366cfab035c72f66a
6
+ metadata.gz: 5a272a1d3f656e7a94888d027b81cd42a462b05d3d2c94525d39d91f6d327a13a79dbfdd63f275237ca7fbf46d95694f682305e279e2803b9616922f1dbe7bcf
7
+ data.tar.gz: de83deb546e98b3819904aae7b9d66024ee49f72c363c071829461ced9e3c4641529404bb17e5631c6274f90f7fdb89574315d6153e45dc17298c060bd0b6674
data/Gemfile CHANGED
@@ -5,7 +5,6 @@ gem 'yard'
5
5
 
6
6
  group :test do
7
7
  gem 'activesupport'
8
- gem 'autotest-growl'
9
8
  gem 'autotest-standalone'
10
9
  gem 'coveralls', require: false
11
10
  gem 'pry'
@@ -142,6 +142,13 @@ module HTTP2
142
142
  @state = :closed
143
143
  end
144
144
 
145
+ # Sends a WINDOW_UPDATE frame to the peer.
146
+ #
147
+ # @param increment [Integer]
148
+ def window_update(increment)
149
+ send(type: :window_update, stream: 0, increment: increment)
150
+ end
151
+
145
152
  # Sends a connection SETTINGS frame to the peer.
146
153
  # The values are reflected when the corresponding ACK is received.
147
154
  #
@@ -628,6 +635,7 @@ module HTTP2
628
635
  stream.once(:close) { @active_stream_count -= 1 }
629
636
  stream.on(:promise, &method(:promise)) if self.is_a? Server
630
637
  stream.on(:frame, &method(:send))
638
+ stream.on(:window_update, &method(:window_update))
631
639
 
632
640
  @streams[id] = stream
633
641
  end
@@ -97,8 +97,14 @@ module HTTP2
97
97
 
98
98
  case frame[:type]
99
99
  when :data
100
- @local_window -= frame[:payload].size
100
+ window_size = frame[:payload].bytesize
101
+ window_size += frame[:padding] || 0
102
+ @local_window -= window_size
101
103
  emit(:data, frame[:payload]) unless frame[:ignore]
104
+
105
+ # Automatically send WINDOW_UPDATE,
106
+ # assuming that emit(:data) can now receive next data
107
+ window_update(window_size) if window_size > 0
102
108
  when :headers, :push_promise
103
109
  emit(:headers, frame[:payload]) unless frame[:ignore]
104
110
  when :priority
@@ -205,6 +211,17 @@ module HTTP2
205
211
  send(type: :rst_stream, error: :refused_stream)
206
212
  end
207
213
 
214
+ # Sends a WINDOW_UPDATE frame to the peer.
215
+ #
216
+ # @param increment [Integer]
217
+ def window_update(increment)
218
+ # always emit connection-level WINDOW_UPDATE
219
+ emit(:window_update, increment)
220
+ # emit stream-level WINDOW_UPDATE unless stream is closed
221
+ return if @state == :closed || @state == :remote_closed
222
+ send(type: :window_update, increment: increment)
223
+ end
224
+
208
225
  private
209
226
 
210
227
  # HTTP 2.0 Stream States
@@ -1,3 +1,3 @@
1
1
  module HTTP2
2
- VERSION = '0.8.1'.freeze
2
+ VERSION = '0.8.2'.freeze
3
3
  end
@@ -577,5 +577,13 @@ RSpec.describe HTTP2::Connection do
577
577
 
578
578
  @conn.goaway(:internal_error, 'payload')
579
579
  end
580
+ it '.window_update should emit WINDOW_UPDATE frames' do
581
+ expect(@conn).to receive(:send) do |frame|
582
+ expect(frame[:type]).to eq :window_update
583
+ expect(frame[:increment]).to eq 20
584
+ expect(frame[:stream]).to eq 0
585
+ end
586
+ @conn.window_update(20)
587
+ end
580
588
  end
581
589
  end
@@ -573,6 +573,21 @@ RSpec.describe HTTP2::Stream do
573
573
  expect(s1.buffered_amount).to eq 0
574
574
  expect(s1.remote_window).to eq 900
575
575
  end
576
+
577
+ it 'should keep track of incoming flow control' do
578
+ data = DATA.deep_dup
579
+ datalen = data[:payload].bytesize
580
+ expect(@stream).to receive(:send) do |frame|
581
+ expect(frame[:type]).to eq :window_update
582
+ expect(frame[:increment]).to eq datalen
583
+ end
584
+ expect(@client).to receive(:send) do |frame|
585
+ expect(frame[:type]).to eq :window_update
586
+ expect(frame[:increment]).to eq datalen
587
+ end
588
+ @stream.receive HEADERS.deep_dup
589
+ @stream.receive data
590
+ end
576
591
  end
577
592
 
578
593
  context 'client API' do
@@ -660,6 +675,14 @@ RSpec.describe HTTP2::Stream do
660
675
 
661
676
  @stream.refuse
662
677
  end
678
+
679
+ it '.window_update should emit WINDOW_UPDATE frames' do
680
+ expect(@stream).to receive(:send) do |frame|
681
+ expect(frame[:type]).to eq :window_update
682
+ expect(frame[:increment]).to eq 20
683
+ end
684
+ @stream.window_update(20)
685
+ end
663
686
  end
664
687
 
665
688
  context 'server API' do
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.1
4
+ version: 0.8.2
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-04-10 00:00:00.000000000 Z
12
+ date: 2016-05-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler