http-2-next 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/http/2/next/connection.rb +3 -12
- data/lib/http/2/next/stream.rb +18 -3
- data/lib/http/2/next/version.rb +1 -1
- data/sig/connection.rbs +1 -3
- data/sig/stream.rbs +14 -0
- 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: 772dfd651b9130358e1de248ead9c68729e482dfdd518973a2d4b61d787d7807
|
4
|
+
data.tar.gz: 59dca4e2a1319dc7363b00e3d52ee7889354f0b0bb114fe49bfc7cd47cbcb1e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb2dce4d9d3f663929771b3141b616030de65f1004e28acee1e01a7d4aa306daba51a839fb9c2e68337d056311369bfb6f1b3bb7dae3cf755a9510839185bef8
|
7
|
+
data.tar.gz: 5c3e377005030768e6056e9cab0076a5e1165ef0aa4433c4920db2cbd29fed171867da9f4b6da5e2c7b64da340bc24f65e01397c90cc7f160ae520f563dbc132
|
@@ -71,10 +71,7 @@ module HTTP2Next
|
|
71
71
|
|
72
72
|
# Number of active streams between client and server (reserved streams
|
73
73
|
# are not counted towards the stream limit).
|
74
|
-
|
75
|
-
|
76
|
-
# Max number of streams that can be in-transit in this connection.
|
77
|
-
attr_writer :max_streams
|
74
|
+
attr_accessor :active_stream_count
|
78
75
|
|
79
76
|
# Initializes new connection object.
|
80
77
|
#
|
@@ -86,7 +83,6 @@ module HTTP2Next
|
|
86
83
|
@decompressor = Header::Decompressor.new(settings)
|
87
84
|
|
88
85
|
@active_stream_count = 0
|
89
|
-
@max_streams = nil
|
90
86
|
@last_activated_stream = 0
|
91
87
|
@last_stream_id = 0
|
92
88
|
@streams = {}
|
@@ -120,8 +116,7 @@ module HTTP2Next
|
|
120
116
|
# @param parent [Stream]
|
121
117
|
def new_stream(**args)
|
122
118
|
raise ConnectionClosed if @state == :closed
|
123
|
-
|
124
|
-
raise StreamLimitExceeded if @active_stream_count >= (@max_streams || @remote_settings[:settings_max_concurrent_streams])
|
119
|
+
raise StreamLimitExceeded if @active_stream_count >= @remote_settings[:settings_max_concurrent_streams]
|
125
120
|
|
126
121
|
connection_error(:protocol_error, msg: "id is smaller than previous") if @stream_id < @last_activated_stream
|
127
122
|
|
@@ -727,14 +722,10 @@ module HTTP2Next
|
|
727
722
|
def activate_stream(id:, **args)
|
728
723
|
connection_error(msg: "Stream ID already exists") if @streams.key?(id)
|
729
724
|
|
730
|
-
raise StreamLimitExceeded if @active_stream_count >=
|
725
|
+
raise StreamLimitExceeded if @active_stream_count >= @local_settings[:settings_max_concurrent_streams]
|
731
726
|
|
732
727
|
stream = Stream.new(connection: self, id: id, **args)
|
733
728
|
|
734
|
-
# Streams that are in the "open" state, or either of the "half closed"
|
735
|
-
# states count toward the maximum number of streams that an endpoint is
|
736
|
-
# permitted to open.
|
737
|
-
stream.once(:active) { @active_stream_count += 1 }
|
738
729
|
stream.once(:close) do
|
739
730
|
# Store a reference to the closed stream, such that we can respond
|
740
731
|
# to any in-flight frames while close is registered on both sides.
|
data/lib/http/2/next/stream.rb
CHANGED
@@ -91,6 +91,7 @@ module HTTP2Next
|
|
91
91
|
@_method = @_content_length = @_status_code = nil
|
92
92
|
@_waiting_on_trailers = false
|
93
93
|
@received_data = false
|
94
|
+
@activated = false
|
94
95
|
|
95
96
|
on(:window) { |v| @remote_window = v }
|
96
97
|
on(:local_window) { |v| @local_window_max_size = @local_window = v }
|
@@ -605,7 +606,7 @@ module HTTP2Next
|
|
605
606
|
case newstate
|
606
607
|
when :open
|
607
608
|
@state = newstate
|
608
|
-
|
609
|
+
activate_stream_in_conn
|
609
610
|
|
610
611
|
when :reserved_local, :reserved_remote
|
611
612
|
@state = newstate
|
@@ -613,7 +614,7 @@ module HTTP2Next
|
|
613
614
|
|
614
615
|
when :half_closed_local, :half_closed_remote
|
615
616
|
@closed = newstate
|
616
|
-
|
617
|
+
activate_stream_in_conn unless @state == :open
|
617
618
|
@state = :half_closing
|
618
619
|
|
619
620
|
when :local_closed, :remote_closed, :local_rst, :remote_rst
|
@@ -624,11 +625,25 @@ module HTTP2Next
|
|
624
625
|
@state
|
625
626
|
end
|
626
627
|
|
628
|
+
# Streams that are in the "open" state, or either of the "half closed"
|
629
|
+
# states count toward the maximum number of streams that an endpoint is
|
630
|
+
# permitted to open.
|
631
|
+
def activate_stream_in_conn
|
632
|
+
@connection.active_stream_count += 1
|
633
|
+
@activated = true
|
634
|
+
emit(:active)
|
635
|
+
end
|
636
|
+
|
637
|
+
def close_stream_in_conn(*args)
|
638
|
+
@connection.active_stream_count -= 1 if @activated
|
639
|
+
emit(:close, *args)
|
640
|
+
end
|
641
|
+
|
627
642
|
def complete_transition(frame)
|
628
643
|
case @state
|
629
644
|
when :closing
|
630
645
|
@state = :closed
|
631
|
-
|
646
|
+
close_stream_in_conn(frame[:error])
|
632
647
|
when :half_closing
|
633
648
|
@state = @closed
|
634
649
|
emit(:half_close)
|
data/lib/http/2/next/version.rb
CHANGED
data/sig/connection.rbs
CHANGED
@@ -17,9 +17,7 @@ module HTTP2Next
|
|
17
17
|
attr_reader local_settings: settings_hash
|
18
18
|
attr_reader pending_settings: settings_ary
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
attr_writer max_streams: Integer?
|
20
|
+
attr_accessor active_stream_count: Integer
|
23
21
|
|
24
22
|
@stream_id: Integer
|
25
23
|
@active_stream_count: Integer
|
data/sig/stream.rbs
CHANGED
@@ -12,6 +12,16 @@ module HTTP2Next
|
|
12
12
|
attr_reader local_window: Integer
|
13
13
|
attr_reader closed: Symbol?
|
14
14
|
|
15
|
+
@connection: Connection
|
16
|
+
@local_window_max_size: Integer
|
17
|
+
@error: bool
|
18
|
+
@_method: String?
|
19
|
+
@_content_length: Integer?
|
20
|
+
@_status_code: Integer?
|
21
|
+
@_waiting_on_trailers: bool
|
22
|
+
@received_data: bool
|
23
|
+
@activated: bool
|
24
|
+
|
15
25
|
alias window local_window
|
16
26
|
|
17
27
|
def closed?: () -> bool
|
@@ -61,6 +71,10 @@ module HTTP2Next
|
|
61
71
|
|
62
72
|
def event: (Symbol newstate) -> void
|
63
73
|
|
74
|
+
def activate_stream_in_conn: () -> void
|
75
|
+
|
76
|
+
def close_stream_in_conn: (*untyped) -> void
|
77
|
+
|
64
78
|
def complete_transition: (frame) -> void
|
65
79
|
|
66
80
|
def process_priority: ({weight: Integer, dependency: Integer, exclusive: bool}) -> void
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http-2-next
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tiago Cardoso
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2023-10-
|
13
|
+
date: 2023-10-13 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description: Pure-ruby HTTP 2.0 protocol implementation
|
16
16
|
email:
|