protocol-http2 0.11.1 → 0.11.2
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.
- checksums.yaml +4 -4
- data/lib/protocol/http2/client.rb +8 -0
- data/lib/protocol/http2/connection.rb +39 -3
- data/lib/protocol/http2/flow_control.rb +1 -1
- data/lib/protocol/http2/framer.rb +1 -1
- data/lib/protocol/http2/server.rb +8 -0
- data/lib/protocol/http2/stream.rb +1 -7
- data/lib/protocol/http2/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 680080c7a69a5ed1afb2520f43a7e6335b0470cb972aa91cab6be7a3c2358240
|
4
|
+
data.tar.gz: f7b3bad2356b04793de349d2c299fb64e855f243120a186dd2dc01906052e08a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 042dd35ecdf9b6b81fa4dcdd3e788346cc0389eec765783c587bc7cebdf74a7204dfc31ef8e2bbe644e5a417ea29dae4fb4f4134aac6c37ef7bb374d0229d3a3
|
7
|
+
data.tar.gz: 45397ddea195960f4a1c253d5cac0028e17b2bfa3fbff6a9aa157f2244bbc5894d610346b98a4a0affe0921d0c627bc3d5db0c438c0a2bec792ea993365da870
|
@@ -41,6 +41,7 @@ module Protocol
|
|
41
41
|
@dependencies = {0 => @dependency}
|
42
42
|
|
43
43
|
@framer = framer
|
44
|
+
# The next stream id to use:
|
44
45
|
@local_stream_id = local_stream_id
|
45
46
|
@remote_stream_id = 0
|
46
47
|
|
@@ -420,9 +421,42 @@ module Protocol
|
|
420
421
|
raise ProtocolError, "Unable to receive push promise!"
|
421
422
|
end
|
422
423
|
|
424
|
+
def client_stream_id?(id)
|
425
|
+
id.odd?
|
426
|
+
end
|
427
|
+
|
428
|
+
def server_stream_id?(id)
|
429
|
+
id.even?
|
430
|
+
end
|
431
|
+
|
432
|
+
def closed_stream_id?(id)
|
433
|
+
if id.zero?
|
434
|
+
# The connection "stream id" can never be closed:
|
435
|
+
false
|
436
|
+
elsif id.even?
|
437
|
+
# Server-initiated streams are even.
|
438
|
+
if @local_stream_id.even?
|
439
|
+
id < @local_stream_id
|
440
|
+
else
|
441
|
+
id < @remote_stream_id
|
442
|
+
end
|
443
|
+
elsif id.odd?
|
444
|
+
# Client-initiated streams are odd.
|
445
|
+
if @local_stream_id.odd?
|
446
|
+
id < @local_stream_id
|
447
|
+
else
|
448
|
+
id < @remote_stream_id
|
449
|
+
end
|
450
|
+
end
|
451
|
+
end
|
452
|
+
|
423
453
|
def receive_reset_stream(frame)
|
424
|
-
if
|
454
|
+
if frame.connection?
|
455
|
+
raise ProtocolError, "Cannot reset connection!"
|
456
|
+
elsif stream = @streams[frame.stream_id]
|
425
457
|
stream.receive_reset_stream(frame)
|
458
|
+
elsif closed_stream_id?(frame.stream_id)
|
459
|
+
# Ignore.
|
426
460
|
else
|
427
461
|
raise StreamClosed, "Cannot reset stream #{frame.stream_id}"
|
428
462
|
end
|
@@ -439,8 +473,10 @@ module Protocol
|
|
439
473
|
rescue ProtocolError => error
|
440
474
|
stream.send_reset_stream(error.code)
|
441
475
|
end
|
442
|
-
elsif frame.stream_id
|
443
|
-
#
|
476
|
+
elsif closed_stream_id?(frame.stream_id)
|
477
|
+
# Ignore.
|
478
|
+
else
|
479
|
+
# Receiving any frame other than HEADERS or PRIORITY on a stream in this state (idle) MUST be treated as a connection error of type PROTOCOL_ERROR.
|
444
480
|
raise ProtocolError, "Cannot update window of idle stream #{frame.stream_id}"
|
445
481
|
end
|
446
482
|
end
|
@@ -84,7 +84,7 @@ module Protocol
|
|
84
84
|
def receive_window_update(frame)
|
85
85
|
amount = frame.unpack
|
86
86
|
|
87
|
-
#
|
87
|
+
# Async.logger.info(self) {"expanding remote_window=#{@remote_window} by #{amount}"}
|
88
88
|
|
89
89
|
if amount != 0
|
90
90
|
@remote_window.expand(amount)
|
@@ -103,7 +103,7 @@ module Protocol
|
|
103
103
|
# Async.logger.debug(self, name: "write") {frame.inspect}
|
104
104
|
|
105
105
|
frame.write(@stream)
|
106
|
-
|
106
|
+
|
107
107
|
# Don't call @stream.flush here because it can cause significant contention if there is a semaphore around this method.
|
108
108
|
# @stream.flush
|
109
109
|
|
@@ -130,7 +130,6 @@ module Protocol
|
|
130
130
|
|
131
131
|
# The stream is being closed because the connection is being closed.
|
132
132
|
def close(error = nil)
|
133
|
-
@connection.delete(@id)
|
134
133
|
end
|
135
134
|
|
136
135
|
def maximum_frame_size
|
@@ -247,6 +246,7 @@ module Protocol
|
|
247
246
|
# @param error_code [Integer] the error code if the stream was closed due to a stream reset.
|
248
247
|
def close!(error_code = nil)
|
249
248
|
@state = :closed
|
249
|
+
@connection.delete(@id)
|
250
250
|
|
251
251
|
if error_code
|
252
252
|
error = StreamError.new("Stream closed!", error_code)
|
@@ -352,16 +352,10 @@ module Protocol
|
|
352
352
|
end
|
353
353
|
end
|
354
354
|
|
355
|
-
def ignore_reset_stream(frame)
|
356
|
-
# Async.logger.warn(self) {"Received reset stream (#{error_code}) in state: #{@state}!"}
|
357
|
-
end
|
358
|
-
|
359
355
|
def receive_reset_stream(frame)
|
360
356
|
if @state == :idle
|
361
357
|
# If a RST_STREAM frame identifying an idle stream is received, the recipient MUST treat this as a connection error (Section 5.4.1) of type PROTOCOL_ERROR.
|
362
358
|
raise ProtocolError, "Cannot receive reset stream in state: #{@state}!"
|
363
|
-
elsif self.closed?
|
364
|
-
ignore_reset_stream(frame)
|
365
359
|
else
|
366
360
|
error_code = frame.unpack
|
367
361
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: protocol-http2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: protocol-hpack
|
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
153
|
- !ruby/object:Gem::Version
|
154
154
|
version: '0'
|
155
155
|
requirements: []
|
156
|
-
rubygems_version: 3.
|
156
|
+
rubygems_version: 3.1.2
|
157
157
|
signing_key:
|
158
158
|
specification_version: 4
|
159
159
|
summary: A low level implementation of the HTTP/2 protocol.
|