protocol-http2 0.17.0 → 0.19.0

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: 20ea1a9636c45a186fe714ec65ae7160bca6d76b2629416bce0b42940e35a8d6
4
- data.tar.gz: 2197763799c0b2e70b24b0f95b10e1eeef2831a540346d65ca71334bdc83615e
3
+ metadata.gz: 6fa9a1478ba8829d9e4416cd5507ca611d5e502eb242b1d873d44d1d60a40850
4
+ data.tar.gz: 4c560c928f9027108f5cf6b4fd135ce2a7043815cf8c4e2077fd5d20865e26be
5
5
  SHA512:
6
- metadata.gz: 9d853eadb2b0bdac2940bf4338c6afd2376e2857c1516d9306736792122ff0a8409ac906e77e16c5c465e85f018365c184a03de6f6d7631181ecde6322328f71
7
- data.tar.gz: f989baa4230ebc3d511ee5a49836e3c794b7a6eba01e309b33471fe73effc4354c4e0929bc86a770f19663585e8d252942b184d4cda8d85d779e28babc0be5e5
6
+ metadata.gz: 95f413d65bbde12d848f7cbe342274d7e914aca16c1a60d2f3193b91e670ae0553233fe3ae1ef4699d87984c711311c7247daac0990bb44ab0f8d3aa44d4f604
7
+ data.tar.gz: 5abe10dc681f35b42a123e69b4fca512d8f0e43b5741d9ab4987c336efa508e6981f2370357fa384c22bbaed8ab5d7725257dc2816823b29926de2c2e7d68d6a
checksums.yaml.gz.sig CHANGED
Binary file
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2024, by Samuel Williams.
5
5
 
6
- require_relative 'connection'
6
+ require_relative "connection"
7
7
 
8
8
  module Protocol
9
9
  module HTTP2
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2024, by Samuel Williams.
5
5
  # Copyright, 2023, by Marco Concetto Rudilosso.
6
6
 
7
- require_relative 'framer'
8
- require_relative 'dependency'
9
- require_relative 'flow_controlled'
7
+ require_relative "framer"
8
+ require_relative "dependency"
9
+ require_relative "flow_controlled"
10
10
 
11
- require 'protocol/hpack'
11
+ require "protocol/hpack"
12
12
 
13
13
  module Protocol
14
14
  module HTTP2
@@ -62,8 +62,9 @@ module Protocol
62
62
  @remote_settings.maximum_frame_size
63
63
  end
64
64
 
65
+ # The maximum number of concurrent streams that this connection can initiate:
65
66
  def maximum_concurrent_streams
66
- @local_settings.maximum_concurrent_streams
67
+ @remote_settings.maximum_concurrent_streams
67
68
  end
68
69
 
69
70
  attr :framer
@@ -214,16 +215,20 @@ module Protocol
214
215
  def write_frame(frame)
215
216
  synchronize do
216
217
  @framer.write_frame(frame)
217
- @framer.flush
218
218
  end
219
+
220
+ # The IO is already synchronized, and we don't want additional contention.
221
+ @framer.flush
219
222
  end
220
223
 
221
224
  def write_frames
222
225
  if @framer
223
226
  synchronize do
224
227
  yield @framer
225
- @framer.flush
226
228
  end
229
+
230
+ # See above note.
231
+ @framer.flush
227
232
  else
228
233
  raise EOFError, "Connection closed!"
229
234
  end
@@ -385,7 +390,8 @@ module Protocol
385
390
  raise ProtocolError, "Invalid stream id: #{stream_id} <= #{@remote_stream_id}!"
386
391
  end
387
392
 
388
- if @streams.size < self.maximum_concurrent_streams
393
+ # We need to validate that we have less streams than the specified maximum:
394
+ if @streams.size < @local_settings.maximum_concurrent_streams
389
395
  stream = accept_stream(stream_id)
390
396
  @remote_stream_id = stream_id
391
397
 
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2024, by Samuel Williams.
5
5
 
6
- require_relative 'frame'
6
+ require_relative "frame"
7
7
 
8
8
  module Protocol
9
9
  module HTTP2
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2024, by Samuel Williams.
5
5
 
6
- require_relative 'frame'
7
- require_relative 'padded'
6
+ require_relative "frame"
7
+ require_relative "padded"
8
8
 
9
9
  module Protocol
10
10
  module HTTP2
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2024, by Samuel Williams.
5
5
 
6
- require 'protocol/http/error'
6
+ require "protocol/http/error"
7
7
 
8
8
  module Protocol
9
9
  module HTTP2
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2024, by Samuel Williams.
5
5
  # Copyright, 2019, by Yuta Iwama.
6
6
 
7
- require_relative 'window_update_frame'
7
+ require_relative "window_update_frame"
8
8
 
9
9
  module Protocol
10
10
  module HTTP2
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2024, by Samuel Williams.
5
5
  # Copyright, 2019, by Yuta Iwama.
6
6
 
7
- require_relative 'error'
7
+ require_relative "error"
8
8
 
9
9
  module Protocol
10
10
  module HTTP2
@@ -106,7 +106,7 @@ module Protocol
106
106
  @stream_id.zero?
107
107
  end
108
108
 
109
- HEADER_FORMAT = 'CnCCN'.freeze
109
+ HEADER_FORMAT = "CnCCN".freeze
110
110
  STREAM_ID_MASK = 0x7fffffff
111
111
 
112
112
  # Generates common 9-byte frame header.
@@ -1,20 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2024, by Samuel Williams.
5
5
 
6
- require_relative 'error'
6
+ require_relative "error"
7
7
 
8
- require_relative 'data_frame'
9
- require_relative 'headers_frame'
10
- require_relative 'priority_frame'
11
- require_relative 'reset_stream_frame'
12
- require_relative 'settings_frame'
13
- require_relative 'push_promise_frame'
14
- require_relative 'ping_frame'
15
- require_relative 'goaway_frame'
16
- require_relative 'window_update_frame'
17
- require_relative 'continuation_frame'
8
+ require_relative "data_frame"
9
+ require_relative "headers_frame"
10
+ require_relative "priority_frame"
11
+ require_relative "reset_stream_frame"
12
+ require_relative "settings_frame"
13
+ require_relative "push_promise_frame"
14
+ require_relative "ping_frame"
15
+ require_relative "goaway_frame"
16
+ require_relative "window_update_frame"
17
+ require_relative "continuation_frame"
18
18
 
19
19
  module Protocol
20
20
  module HTTP2
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2024, by Samuel Williams.
5
5
 
6
- require_relative 'frame'
6
+ require_relative "frame"
7
7
 
8
8
  module Protocol
9
9
  module HTTP2
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2024, by Samuel Williams.
5
5
 
6
- require_relative 'frame'
7
- require_relative 'padded'
8
- require_relative 'continuation_frame'
9
- require_relative 'priority_frame'
6
+ require_relative "frame"
7
+ require_relative "padded"
8
+ require_relative "continuation_frame"
9
+ require_relative "priority_frame"
10
10
 
11
11
  module Protocol
12
12
  module HTTP2
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2024, by Samuel Williams.
5
5
 
6
- require_relative 'frame'
6
+ require_relative "frame"
7
7
 
8
8
  module Protocol
9
9
  module HTTP2
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2024, by Samuel Williams.
5
5
 
6
- require_relative 'frame'
6
+ require_relative "frame"
7
7
 
8
8
  module Protocol
9
9
  module HTTP2
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2024, by Samuel Williams.
5
5
 
6
- require_relative 'frame'
6
+ require_relative "frame"
7
7
 
8
8
  module Protocol
9
9
  module HTTP2
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2024, by Samuel Williams.
5
5
 
6
- require_relative 'frame'
7
- require_relative 'padded'
8
- require_relative 'continuation_frame'
6
+ require_relative "frame"
7
+ require_relative "padded"
8
+ require_relative "continuation_frame"
9
9
 
10
10
  module Protocol
11
11
  module HTTP2
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2024, by Samuel Williams.
5
5
 
6
- require_relative 'frame'
6
+ require_relative "frame"
7
7
 
8
8
  module Protocol
9
9
  module HTTP2
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2024, by Samuel Williams.
5
5
 
6
- require_relative 'connection'
6
+ require_relative "connection"
7
7
 
8
8
  module Protocol
9
9
  module HTTP2
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2024, by Samuel Williams.
5
5
 
6
- require_relative 'ping_frame'
6
+ require_relative "ping_frame"
7
7
 
8
8
  module Protocol
9
9
  module HTTP2
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2024, by Samuel Williams.
5
5
 
6
- require_relative 'connection'
7
- require_relative 'dependency'
6
+ require_relative "connection"
7
+ require_relative "dependency"
8
8
 
9
9
  module Protocol
10
10
  module HTTP2
11
- # A single HTTP 2.0 connection can multiplex multiple streams in parallel:
11
+ # A single HTTP/2 connection can multiplex multiple streams in parallel:
12
12
  # multiple requests and responses can be in flight simultaneously and stream
13
13
  # data can be interleaved and prioritized.
14
14
  #
@@ -18,42 +18,44 @@ module Protocol
18
18
  # diagram below) and provide your application logic to handle request
19
19
  # and response processing.
20
20
  #
21
- # +--------+
22
- # send PP | | recv PP
23
- # ,--------| idle |--------.
24
- # / | | \
25
- # v +--------+ v
26
- # +----------+ | +----------+
27
- # | | | send H / | |
28
- # ,------| reserved | | recv H | reserved |------.
29
- # | | (local) | | | (remote) | |
30
- # | +----------+ v +----------+ |
31
- # | | +--------+ | |
32
- # | | recv ES | | send ES | |
33
- # | send H | ,-------| open |-------. | recv H |
34
- # | | / | | \ | |
35
- # | v v +--------+ v v |
36
- # | +----------+ | +----------+ |
37
- # | | half | | | half | |
38
- # | | closed | | send R / | closed | |
39
- # | | (remote) | | recv R | (local) | |
40
- # | +----------+ | +----------+ |
41
- # | | | | |
42
- # | | send ES / | recv ES / | |
43
- # | | send R / v send R / | |
44
- # | | recv R +--------+ recv R | |
45
- # | send R / `----------->| |<-----------' send R / |
46
- # | recv R | closed | recv R |
47
- # `----------------------->| |<----------------------'
48
- # +--------+
49
- #
50
- # send: endpoint sends this frame
51
- # recv: endpoint receives this frame
52
- #
53
- # H: HEADERS frame (with implied CONTINUATIONs)
54
- # PP: PUSH_PROMISE frame (with implied CONTINUATIONs)
55
- # ES: END_STREAM flag
56
- # R: RST_STREAM frame
21
+ # ```
22
+ # ┌────────┐
23
+ # send PP │ │ recv PP
24
+ # ┌──────────┤ idle ├──────────┐
25
+ # │ │
26
+ # └───┬────┘ ▼
27
+ # ┌──────────┐ │ ┌──────────┐
28
+ # │ │ send H / │ │
29
+ # ┌──────┼ reserved │ recv H │ reserved ├──────┐
30
+ # │ (local) │ │ (remote) │
31
+ # │ └───┬──────┘ ▼ └──────┬───┘ │
32
+ # │ ┌────────┐ │
33
+ # │ │ recv ES │ │ send ES │ │
34
+ # │ send H │ ┌─────────┤ open ├─────────┐ │ recv H │
35
+ # │ │
36
+ # ▼ ▼ └───┬────┘ ▼ ▼ │
37
+ # ┌──────────┐ ┌──────────┐
38
+ # │ half │ │ │ half │
39
+ # │ closed │ send R / │ closed │
40
+ # │ (remote) │ │ recv R │ (local) │
41
+ # │ └────┬─────┘ │ └─────┬────┘ │
42
+ # │ │ │
43
+ # send ES / recv ES /
44
+ # send R / ▼ send R / │
45
+ # │ │ recv R ┌────────┐ recv R │ │
46
+ # send R / └───────────►│ │◄───────────┘ send R / │
47
+ # │ recv R │ closed │ recv R │
48
+ # └───────────────────────►│ │◄───────────────────────┘
49
+ # └────────┘
50
+ # ```
51
+ #
52
+ # - `send`: endpoint sends this frame
53
+ # - `recv`: endpoint receives this frame
54
+ #
55
+ # - H: HEADERS frame (with implied CONTINUATIONs)
56
+ # - PP: PUSH_PROMISE frame (with implied CONTINUATIONs)
57
+ # - ES: END_STREAM flag
58
+ # - R: RST_STREAM frame
57
59
  #
58
60
  # State transition methods use a trailing "!".
59
61
  class Stream
@@ -219,10 +221,6 @@ module Protocol
219
221
  end
220
222
  end
221
223
 
222
- # The stream has been opened.
223
- def opened(error = nil)
224
- end
225
-
226
224
  def open!
227
225
  if @state == :idle
228
226
  @state = :open
@@ -230,8 +228,6 @@ module Protocol
230
228
  raise ProtocolError, "Cannot open stream in state: #{@state}"
231
229
  end
232
230
 
233
- self.opened
234
-
235
231
  return self
236
232
  end
237
233
 
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2024, by Samuel Williams.
5
5
 
6
6
  module Protocol
7
7
  module HTTP2
8
- VERSION = "0.17.0"
8
+ VERSION = "0.19.0"
9
9
  end
10
10
  end
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2024, by Samuel Williams.
5
5
 
6
- require_relative 'frame'
6
+ require_relative "frame"
7
7
 
8
8
  module Protocol
9
9
  module HTTP2
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2024, by Samuel Williams.
5
5
 
6
- require_relative 'http2/version'
7
- require_relative 'http2/connection'
6
+ require_relative "http2/version"
7
+ require_relative "http2/connection"
data/readme.md CHANGED
@@ -99,8 +99,8 @@ We welcome contributions to this project.
99
99
 
100
100
  ### Developer Certificate of Origin
101
101
 
102
- This project uses the [Developer Certificate of Origin](https://developercertificate.org/). All contributors to this project must agree to this document to have their contributions accepted.
102
+ In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed.
103
103
 
104
- ### Contributor Covenant
104
+ ### Community Guidelines
105
105
 
106
- This project is governed by the [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and participants agree to abide by its terms.
106
+ This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protocol-http2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0
4
+ version: 0.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -40,7 +40,7 @@ cert_chain:
40
40
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
41
41
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
42
42
  -----END CERTIFICATE-----
43
- date: 2024-04-21 00:00:00.000000000 Z
43
+ date: 2024-09-24 00:00:00.000000000 Z
44
44
  dependencies:
45
45
  - !ruby/object:Gem::Dependency
46
46
  name: protocol-hpack
@@ -103,7 +103,9 @@ files:
103
103
  homepage: https://github.com/socketry/protocol-http2
104
104
  licenses:
105
105
  - MIT
106
- metadata: {}
106
+ metadata:
107
+ documentation_uri: https://socketry.github.io/protocol-http2/
108
+ source_code_uri: https://github.com/socketry/protocol-http2.git
107
109
  post_install_message:
108
110
  rdoc_options: []
109
111
  require_paths:
@@ -112,14 +114,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
114
  requirements:
113
115
  - - ">="
114
116
  - !ruby/object:Gem::Version
115
- version: '3.0'
117
+ version: '3.1'
116
118
  required_rubygems_version: !ruby/object:Gem::Requirement
117
119
  requirements:
118
120
  - - ">="
119
121
  - !ruby/object:Gem::Version
120
122
  version: '0'
121
123
  requirements: []
122
- rubygems_version: 3.5.3
124
+ rubygems_version: 3.5.11
123
125
  signing_key:
124
126
  specification_version: 4
125
127
  summary: A low level implementation of the HTTP/2 protocol.
metadata.gz.sig CHANGED
Binary file