http-protocol 0.6.0 → 0.6.1

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
  SHA256:
3
- metadata.gz: 9327c9adf284058c58e7e426b736ff72e3752fecd81197fe6b924a1c6df5c283
4
- data.tar.gz: a34c59791a0aaa73fa92ac2414142ce3b0fc8fcb0eeaffc681b470dd81a239ee
3
+ metadata.gz: 06c19174884cf3035af9e9f8ae64625b8973238ee4c0e6ae8b55a5d1a5d7392c
4
+ data.tar.gz: 0b82b044493d1c712d920f08932062d731abc1b204ed79c557ece5aaf340e9a6
5
5
  SHA512:
6
- metadata.gz: eaac214ab838e2e1a96a86ccd4756af6a7213b79157f738c43cbdaf2754e36b2dd08e04da675d49cd3f1d199db5bcfa9e468381e48ac8155508b920ef48e3e88
7
- data.tar.gz: 8f1dc78539df7034795ba5d407213d3905f354878bf3758e4261b0ac7cbc61b88c6338c924ac4abd23462266e2d8e94e56b5fe26b6cb93d0dbbcd1fa97db6b03
6
+ metadata.gz: bddc90de39bfc55f4ee72d44701e248828342a7a171d80d874e1df5ea94944544030b4edbfb3f9017cdfbf6df0564fc0b219dabe6969bee9b02cdb1d221aa5d6
7
+ data.tar.gz: f1981cbbce0573ac3de49212193ab7cdabc32ec3e865396caac80a6c5cd6728fbcfae64418e1ea4b972e24b2f861c8011244c6d7a8d1f4e7628898a2e03b67f6
@@ -111,6 +111,7 @@ module HTTP
111
111
  def read_frame
112
112
  frame = @framer.read_frame(@local_settings.maximum_frame_size)
113
113
  # puts "#{self.class} #{@state} read_frame: class=#{frame.class} flags=#{frame.flags} length=#{frame.length}"
114
+ # puts "Windows: local_window=#{@local_window.inspect}; remote_window=#{@remote_window.inspect}"
114
115
 
115
116
  yield frame if block_given?
116
117
 
@@ -171,6 +172,7 @@ module HTTP
171
172
 
172
173
  def update_local_settings(changes)
173
174
  capacity = @local_settings.initial_window_size
175
+
174
176
  @streams.each_value do |stream|
175
177
  stream.local_window.capacity = capacity
176
178
  end
@@ -178,6 +180,7 @@ module HTTP
178
180
 
179
181
  def update_remote_settings(changes)
180
182
  capacity = @remote_settings.initial_window_size
183
+
181
184
  @streams.each_value do |stream|
182
185
  stream.remote_window.capacity = capacity
183
186
  end
@@ -210,9 +213,6 @@ module HTTP
210
213
  end
211
214
 
212
215
  def open!
213
- @local_window.capacity = self.local_settings.initial_window_size
214
- @remote_window.capacity = self.remote_settings.initial_window_size
215
-
216
216
  @state = :open
217
217
 
218
218
  return self
@@ -66,12 +66,13 @@ module HTTP
66
66
 
67
67
  write_frame(frame)
68
68
 
69
- @local_window.used -= window_increment
69
+ @local_window.expand(window_increment)
70
70
  end
71
71
 
72
72
  def receive_window_update(frame)
73
73
  was_full = @remote_window.full?
74
74
 
75
+ # puts "expand remote_window=#{@remote_window} by #{frame.unpack}"
75
76
  @remote_window.expand(frame.unpack)
76
77
 
77
78
  self.window_updated if was_full
@@ -83,8 +83,8 @@ module HTTP
83
83
  @state = :idle
84
84
 
85
85
  @priority = nil
86
- @local_window = connection.local_window.dup
87
- @remote_window = connection.remote_window.dup
86
+ @local_window = Window.new(connection.local_settings.initial_window_size)
87
+ @remote_window = Window.new(connection.remote_settings.initial_window_size)
88
88
 
89
89
  @headers = nil
90
90
  @data = nil
@@ -22,7 +22,12 @@ module HTTP
22
22
  module Protocol
23
23
  module HTTP2
24
24
  class Window
25
- def initialize(capacity)
25
+ # @param capacity [Integer] The initial window size, typically from the settings.
26
+ def initialize(capacity = 0xFFFF)
27
+ # This is the main field required:
28
+ @available = capacity
29
+
30
+ # These two fields are primarily used for efficiently sending window updates:
26
31
  @used = 0
27
32
  @capacity = capacity
28
33
 
@@ -35,34 +40,40 @@ module HTTP
35
40
 
36
41
  # The window is completely full?
37
42
  def full?
38
- @used == @capacity
43
+ @available.zero?
39
44
  end
40
45
 
41
- attr_accessor :used
42
- attr_accessor :capacity
46
+ attr :used
47
+ attr :capacity
48
+
49
+ # When the value of SETTINGS_INITIAL_WINDOW_SIZE changes, a receiver MUST adjust the size of all stream flow-control windows that it maintains by the difference between the new value and the old value.
50
+ def capacity= value
51
+ difference = value - @capacity
52
+ @available += difference
53
+ end
43
54
 
44
55
  def consume(amount)
56
+ @available -= amount
45
57
  @used += amount
46
58
  end
47
59
 
48
- def available
49
- @capacity - @used
50
- end
60
+ attr :available
51
61
 
52
62
  def available?
53
- available > 0
63
+ @available > 0
54
64
  end
55
65
 
56
66
  def expand(amount)
67
+ @available += amount
57
68
  @used -= amount
58
69
  end
59
70
 
60
71
  def limited?
61
- @used > (@capacity / 2)
72
+ @available < (@capacity / 2)
62
73
  end
63
74
 
64
75
  def to_s
65
- "\#<Window #{@used}/#{@capacity}>"
76
+ "\#<Window used=#{@used} available=#{@available} capacity=#{@capacity}>"
66
77
  end
67
78
  end
68
79
 
@@ -20,6 +20,6 @@
20
20
 
21
21
  module HTTP
22
22
  module Protocol
23
- VERSION = "0.6.0"
23
+ VERSION = "0.6.1"
24
24
  end
25
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http-protocol
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-02 00:00:00.000000000 Z
11
+ date: 2018-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http-hpack