http-2 1.1.0 → 1.1.1
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/http/2/connection.rb +3 -2
- data/lib/http/2/framer.rb +12 -2
- data/lib/http/2/stream.rb +45 -56
- data/lib/http/2/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c3e5ca05eb466a1e2f6c0895ccd5827987cfb8bf8ddbefeeb74210e0e6e3e97
|
4
|
+
data.tar.gz: 8589dab8b8c89aefc5067206219ebcac9bffbc185da25d89a5f6dccc11aafcd8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d66c154674cdd29924c0c169ce60c8eeda6ba833b435b2db74b787e86bab101a7f9748f4fb632ecbecf32aaa216fdf1cd9e8d73c333cd501f454b52d0628c6fe
|
7
|
+
data.tar.gz: 68f86eca1a92474fd7802502af0883595b52afe42c49c975ea6952e79a523c59508ad5213d18f77f9a50a4539deb6200013407b001f81dcdb5560639ef030242
|
data/lib/http/2/connection.rb
CHANGED
@@ -403,8 +403,9 @@ module HTTP2
|
|
403
403
|
# endpoints MAY choose to treat frames that arrive a significant
|
404
404
|
# time after sending END_STREAM as a connection error.
|
405
405
|
when :rst_stream
|
406
|
-
|
407
|
-
|
406
|
+
unless @streams_recently_closed.key?(stream_id)
|
407
|
+
connection_error(:protocol_error, msg: "sent window update on idle stream")
|
408
|
+
end
|
408
409
|
else
|
409
410
|
# An endpoint that receives an unexpected stream identifier
|
410
411
|
# MUST respond with a connection error of type PROTOCOL_ERROR.
|
data/lib/http/2/framer.rb
CHANGED
@@ -148,9 +148,12 @@ module HTTP2
|
|
148
148
|
|
149
149
|
header = buffer
|
150
150
|
|
151
|
+
# make sure the buffer is binary and unfrozen
|
151
152
|
if buffer.frozen?
|
152
153
|
header = String.new("", encoding: Encoding::BINARY, capacity: buffer.bytesize + 9) # header length
|
153
|
-
header
|
154
|
+
append_str(header, buffer)
|
155
|
+
else
|
156
|
+
header.force_encoding(Encoding::BINARY)
|
154
157
|
end
|
155
158
|
|
156
159
|
pack([
|
@@ -268,7 +271,7 @@ module HTTP2
|
|
268
271
|
append_str(bytes, frame[:payload])
|
269
272
|
|
270
273
|
when :ping
|
271
|
-
bytes = frame[:payload]
|
274
|
+
bytes = frame[:payload].b
|
272
275
|
raise CompressionError, "Invalid payload size (#{bytes.size} != 8 bytes)" if bytes.bytesize != 8
|
273
276
|
|
274
277
|
length = 8
|
@@ -342,6 +345,13 @@ module HTTP2
|
|
342
345
|
raise CompressionError, "Invalid padding #{padlen}"
|
343
346
|
end
|
344
347
|
|
348
|
+
# make sure the buffer is binary and unfrozen
|
349
|
+
if bytes.frozen?
|
350
|
+
bytes = bytes.b
|
351
|
+
else
|
352
|
+
bytes.force_encoding(Encoding::BINARY)
|
353
|
+
end
|
354
|
+
|
345
355
|
length += padlen
|
346
356
|
pack([padlen -= 1], UINT8, buffer: bytes, offset: 0)
|
347
357
|
frame[:flags] += [:padded]
|
data/lib/http/2/stream.rb
CHANGED
@@ -197,21 +197,18 @@ module HTTP2
|
|
197
197
|
#
|
198
198
|
# @param frame [Hash]
|
199
199
|
def send(frame)
|
200
|
-
process_priority(frame) if frame[:type] == :priority
|
201
|
-
|
202
200
|
case frame[:type]
|
203
201
|
when :data
|
204
|
-
#
|
205
|
-
send_data(frame)
|
202
|
+
# stream state management is maintained in send_data
|
203
|
+
return send_data(frame)
|
206
204
|
when :window_update
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
end
|
205
|
+
@local_window += frame[:increment]
|
206
|
+
when :priority
|
207
|
+
process_priority(frame)
|
208
|
+
end
|
209
|
+
|
210
|
+
manage_state(frame) do
|
211
|
+
emit(:frame, frame)
|
215
212
|
end
|
216
213
|
end
|
217
214
|
|
@@ -384,7 +381,7 @@ module HTTP2
|
|
384
381
|
else
|
385
382
|
event(:open)
|
386
383
|
end
|
387
|
-
when :priority
|
384
|
+
when :priority
|
388
385
|
else stream_error(:protocol_error)
|
389
386
|
end
|
390
387
|
end
|
@@ -405,19 +402,20 @@ module HTTP2
|
|
405
402
|
# WINDOW_UPDATE on a stream in this state MUST be treated as a
|
406
403
|
# connection error (Section 5.4.1) of type PROTOCOL_ERROR.
|
407
404
|
when :reserved_local
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
405
|
+
if sending
|
406
|
+
case frame[:type]
|
407
|
+
when :headers then event(:half_closed_remote)
|
408
|
+
when :rst_stream then event(:local_rst)
|
409
|
+
when :priority
|
410
|
+
else stream_error
|
411
|
+
end
|
412
|
+
else
|
413
|
+
case frame[:type]
|
414
|
+
when :rst_stream then event(:remote_rst)
|
415
|
+
when :priority, :window_update
|
416
|
+
else stream_error
|
417
|
+
end
|
418
|
+
end
|
421
419
|
|
422
420
|
# A stream in the "reserved (remote)" state has been reserved by a
|
423
421
|
# remote peer.
|
@@ -434,19 +432,20 @@ module HTTP2
|
|
434
432
|
# PRIORITY on a stream in this state MUST be treated as a connection
|
435
433
|
# error (Section 5.4.1) of type PROTOCOL_ERROR.
|
436
434
|
when :reserved_remote
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
435
|
+
if sending
|
436
|
+
case frame[:type]
|
437
|
+
when :rst_stream then event(:local_rst)
|
438
|
+
when :priority, :window_update
|
439
|
+
else stream_error
|
440
|
+
end
|
441
|
+
else
|
442
|
+
case frame[:type]
|
443
|
+
when :headers then event(:half_closed_local)
|
444
|
+
when :rst_stream then event(:remote_rst)
|
445
|
+
when :priority
|
446
|
+
else stream_error
|
447
|
+
end
|
448
|
+
end
|
450
449
|
|
451
450
|
# A stream in the "open" state may be used by both peers to send
|
452
451
|
# frames of any type. In this state, sending peers observe
|
@@ -465,12 +464,14 @@ module HTTP2
|
|
465
464
|
when :data, :headers, :continuation
|
466
465
|
event(:half_closed_local) if end_stream?(frame)
|
467
466
|
when :rst_stream then event(:local_rst)
|
467
|
+
when :priority
|
468
468
|
end
|
469
469
|
else
|
470
470
|
case frame[:type]
|
471
471
|
when :data, :headers, :continuation
|
472
472
|
event(:half_closed_remote) if end_stream?(frame)
|
473
473
|
when :rst_stream then event(:remote_rst)
|
474
|
+
when :priority
|
474
475
|
end
|
475
476
|
end
|
476
477
|
|
@@ -490,10 +491,7 @@ module HTTP2
|
|
490
491
|
case frame[:type]
|
491
492
|
when :rst_stream
|
492
493
|
event(:local_rst)
|
493
|
-
when :priority
|
494
|
-
process_priority(frame)
|
495
|
-
when :window_update
|
496
|
-
# nop here
|
494
|
+
when :priority, :window_update
|
497
495
|
else
|
498
496
|
stream_error
|
499
497
|
end
|
@@ -502,10 +500,7 @@ module HTTP2
|
|
502
500
|
when :data, :headers, :continuation
|
503
501
|
event(:remote_closed) if end_stream?(frame)
|
504
502
|
when :rst_stream then event(:remote_rst)
|
505
|
-
when :priority
|
506
|
-
process_priority(frame)
|
507
|
-
when :window_update
|
508
|
-
# nop here
|
503
|
+
when :priority, :window_update
|
509
504
|
end
|
510
505
|
end
|
511
506
|
|
@@ -534,9 +529,7 @@ module HTTP2
|
|
534
529
|
else
|
535
530
|
case frame[:type]
|
536
531
|
when :rst_stream then event(:remote_rst)
|
537
|
-
when :priority
|
538
|
-
process_priority(frame)
|
539
|
-
when :window_update
|
532
|
+
when :priority, :window_update
|
540
533
|
# nop
|
541
534
|
else
|
542
535
|
stream_error(:stream_closed)
|
@@ -584,19 +577,15 @@ module HTTP2
|
|
584
577
|
when :closed
|
585
578
|
if sending
|
586
579
|
case frame[:type]
|
587
|
-
when :rst_stream
|
588
|
-
when :priority
|
589
|
-
process_priority(frame)
|
580
|
+
when :rst_stream, :priority
|
590
581
|
else
|
591
582
|
stream_error(:stream_closed) unless frame[:type] == :rst_stream
|
592
583
|
end
|
593
|
-
elsif frame[:type] == :priority
|
594
|
-
process_priority(frame)
|
595
584
|
else
|
596
585
|
case @closed
|
597
586
|
when :remote_rst, :remote_closed
|
598
587
|
case frame[:type]
|
599
|
-
when :rst_stream, :window_update # nop here
|
588
|
+
when :priority, :rst_stream, :window_update # nop here
|
600
589
|
else
|
601
590
|
stream_error(:stream_closed)
|
602
591
|
end
|
data/lib/http/2/version.rb
CHANGED
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: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tiago Cardoso
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
- Kaoru Maeda
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2025-04-
|
12
|
+
date: 2025-04-16 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Pure-ruby HTTP 2.0 protocol implementation
|
15
15
|
email:
|