protocol-http2 0.8.1 → 0.8.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/stream.rb +40 -20
- data/lib/protocol/http2/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 802763909c7326fe42e70a217a13a31828760c673868b3b7fbcd2e99174e0423
|
4
|
+
data.tar.gz: 314093df7a84ae72929af8a1ae25d1b6f8363c1b94ee132196ad6e076b03e0f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09d0303e8166c468719bad98aa6d4d2f61d412317ef05f8c55d72a5814f7980b36a5d9f61ee85d7a003eada87d864bac81ad28d1a244e2ed95d431c20225c09a'
|
7
|
+
data.tar.gz: 046fe8e2b1d1f3a85013ebf188975d004a229491fc7ea93c9a46f18c68fb53be1d7876564f42663d292e88bd204d1aa81820724e732bb784b106e526a0b060d1
|
@@ -182,7 +182,7 @@ module Protocol
|
|
182
182
|
stream.add_child(self)
|
183
183
|
end
|
184
184
|
|
185
|
-
def
|
185
|
+
def process_priority priority
|
186
186
|
dependent_id = priority.stream_dependency
|
187
187
|
|
188
188
|
if dependent_id == @id
|
@@ -250,7 +250,7 @@ module Protocol
|
|
250
250
|
if frame.end_stream?
|
251
251
|
@state = :half_closed_local
|
252
252
|
else
|
253
|
-
|
253
|
+
open!
|
254
254
|
end
|
255
255
|
elsif @state == :reserved_local
|
256
256
|
frame = write_headers(*args)
|
@@ -308,6 +308,12 @@ module Protocol
|
|
308
308
|
end
|
309
309
|
end
|
310
310
|
|
311
|
+
def open!
|
312
|
+
@state = :open
|
313
|
+
|
314
|
+
return self
|
315
|
+
end
|
316
|
+
|
311
317
|
# Transition the stream into the closed state.
|
312
318
|
# @param error_code [Integer] the error code if the stream was closed due to a stream reset.
|
313
319
|
def close!(error_code = nil)
|
@@ -318,6 +324,8 @@ module Protocol
|
|
318
324
|
end
|
319
325
|
|
320
326
|
self.close(error)
|
327
|
+
|
328
|
+
return self
|
321
329
|
end
|
322
330
|
|
323
331
|
def send_reset_stream(error_code = 0)
|
@@ -333,23 +341,27 @@ module Protocol
|
|
333
341
|
end
|
334
342
|
end
|
335
343
|
|
336
|
-
|
344
|
+
protected def process_headers(frame)
|
337
345
|
# Receiving request headers:
|
338
346
|
priority, data = frame.unpack
|
339
347
|
|
340
348
|
if priority
|
341
|
-
self.
|
349
|
+
self.process_priority(priority)
|
342
350
|
end
|
343
351
|
|
344
352
|
@connection.decode_headers(data)
|
345
353
|
end
|
346
354
|
|
355
|
+
protected def ignore_headers(frame)
|
356
|
+
# Async.logger.warn(self) {"Received headers in state: #{@state}!"}
|
357
|
+
end
|
358
|
+
|
347
359
|
def receive_headers(frame)
|
348
360
|
if @state == :idle
|
349
361
|
if frame.end_stream?
|
350
362
|
@state = :half_closed_remote
|
351
363
|
else
|
352
|
-
|
364
|
+
open!
|
353
365
|
end
|
354
366
|
|
355
367
|
return process_headers(frame)
|
@@ -369,8 +381,9 @@ module Protocol
|
|
369
381
|
end
|
370
382
|
|
371
383
|
return process_headers(frame)
|
384
|
+
elsif self.closed?
|
385
|
+
ignore_headers(frame)
|
372
386
|
else
|
373
|
-
Async.logger.warn(self) {"Received headers in state: #{@state}!"}
|
374
387
|
self.send_reset_stream(Error::STREAM_CLOSED)
|
375
388
|
end
|
376
389
|
end
|
@@ -380,6 +393,10 @@ module Protocol
|
|
380
393
|
frame.unpack
|
381
394
|
end
|
382
395
|
|
396
|
+
def ignore_data(frame)
|
397
|
+
# Async.logger.warn(self) {"Received headers in state: #{@state}!"}
|
398
|
+
end
|
399
|
+
|
383
400
|
# DATA frames are subject to flow control and can only be sent when a stream is in the "open" or "half-closed (remote)" state. The entire DATA frame payload is included in flow control, including the Pad Length and Padding fields if present. If a DATA frame is received whose stream is not in "open" or "half-closed (local)" state, the recipient MUST respond with a stream error of type STREAM_CLOSED.
|
384
401
|
def receive_data(frame)
|
385
402
|
if @state == :open
|
@@ -398,9 +415,10 @@ module Protocol
|
|
398
415
|
if frame.end_stream?
|
399
416
|
close!
|
400
417
|
end
|
418
|
+
elsif self.closed?
|
419
|
+
ignore_data(frame)
|
401
420
|
else
|
402
421
|
# If a DATA frame is received whose stream is not in "open" or "half-closed (local)" state, the recipient MUST respond with a stream error (Section 5.4.2) of type STREAM_CLOSED.
|
403
|
-
Async.logger.warn(self) {"Received data in state: #{@state}!"}
|
404
422
|
self.send_reset_stream(Error::STREAM_CLOSED)
|
405
423
|
end
|
406
424
|
end
|
@@ -408,7 +426,7 @@ module Protocol
|
|
408
426
|
# Change the priority of the stream both locally and remotely.
|
409
427
|
def priority= priority
|
410
428
|
send_priority(priority)
|
411
|
-
|
429
|
+
process_priority(priority)
|
412
430
|
end
|
413
431
|
|
414
432
|
# The current local priority of the stream.
|
@@ -421,23 +439,25 @@ module Protocol
|
|
421
439
|
end
|
422
440
|
|
423
441
|
def receive_priority(frame)
|
424
|
-
self.
|
442
|
+
self.process_priority(frame.unpack)
|
443
|
+
end
|
444
|
+
|
445
|
+
def ignore_reset_stream(frame)
|
446
|
+
# Async.logger.warn(self) {"Received reset stream (#{error_code}) in state: #{@state}!"}
|
425
447
|
end
|
426
448
|
|
427
449
|
def receive_reset_stream(frame)
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
450
|
+
if @state == :idle
|
451
|
+
# 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.
|
452
|
+
raise ProtocolError, "Cannot receive reset stream in state: #{@state}!"
|
453
|
+
elsif self.closed?
|
454
|
+
ignore_reset_stream(frame)
|
455
|
+
else
|
456
|
+
error_code = frame.unpack
|
457
|
+
|
458
|
+
close!(error_code)
|
436
459
|
|
437
460
|
return error_code
|
438
|
-
else
|
439
|
-
# 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.
|
440
|
-
raise ProtocolError, "Cannot receive reset stream (#{error_code}) in state: #{@state}!"
|
441
461
|
end
|
442
462
|
end
|
443
463
|
|