protocol-http2 0.25.0 → 0.26.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b8f43f3f03b10cd9477abc3b46090c9e8902eda24994ee6b7ded6d5ee801895d
4
- data.tar.gz: f72cb844993482f485cbb713e4c71d08cb1a9b83bef2d9551f9db7e754d7a34b
3
+ metadata.gz: 88d933bf4cd35251d305cd05fa6654acfbeee446982af751bd221e976dff2313
4
+ data.tar.gz: e78f3a10d74fccfd63d098af1910c0b846b093aeb446860da5105e306410b401
5
5
  SHA512:
6
- metadata.gz: c6b7113982c91dcd97920ce8c44330093c3cd90f2d1623928333e5c5ebbf09358b678452cda940f0645da5a1bbe7f1a1b6dc155344913cdee1dafd14b33f2f75
7
- data.tar.gz: bdae54364a9e64218bb10c20112ffc6b3511098b68c305a06c8789ecabcfe1d62d2954ba1bee0451fea5014313f1d7e0c782dd49127986c632b87b9890195902
6
+ metadata.gz: e2a037ad5d8c96c9c8dc6f2352a7ebdeaf3b0b52354c408e965cb689439eb5d94ec2dc9e1d4ef27903c5334c1310a852d6896cc9f52d9f60d917d92e230ffae1
7
+ data.tar.gz: 5472ccf116f877b341d5793f7166656c924d6c6c8ca0a8080c86856834109ddc8bd0993a41e080f50d80cbaeffb9453c50731dbc96a97007ea1e7434d83d1f39
checksums.yaml.gz.sig CHANGED
Binary file
@@ -238,7 +238,7 @@ module Protocol
238
238
  self.close!
239
239
 
240
240
  # Streams above the last stream ID were not processed by the remote peer and are safe to retry (RFC 9113 §6.8).
241
- error = ::Protocol::HTTP::RequestRefusedError.new("GOAWAY: request not processed.")
241
+ error = ::Protocol::HTTP::RefusedError.new("GOAWAY: request not processed.")
242
242
 
243
243
  @streams.each_value do |stream|
244
244
  if stream.id > @remote_stream_id
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2025, by Samuel Williams.
4
+ # Copyright, 2019-2026, by Samuel Williams.
5
5
 
6
6
  require "protocol/http/error"
7
7
 
@@ -50,6 +50,33 @@ module Protocol
50
50
 
51
51
  # The endpoint requires that HTTP/1.1 be used instead of HTTP/2.
52
52
  HTTP_1_1_REQUIRED = 0xD
53
+
54
+ MESSAGES = {
55
+ NO_ERROR => "No error.",
56
+ PROTOCOL_ERROR => "Protocol error!",
57
+ INTERNAL_ERROR => "Internal error!",
58
+ FLOW_CONTROL_ERROR => "Flow control error!",
59
+ SETTINGS_TIMEOUT => "Settings timeout!",
60
+ STREAM_CLOSED => "Stream closed!",
61
+ FRAME_SIZE_ERROR => "Frame size error!",
62
+ REFUSED_STREAM => "Stream refused.",
63
+ CANCEL => "Stream cancelled.",
64
+ COMPRESSION_ERROR => "Compression error!",
65
+ CONNECT_ERROR => "Connect error!",
66
+ ENHANCE_YOUR_CALM => "Enhance your calm!",
67
+ INADEQUATE_SECURITY => "Inadequate security!",
68
+ HTTP_1_1_REQUIRED => "HTTP/1.1 required.",
69
+ }
70
+
71
+ # Get the message for a given HTTP/2 error code.
72
+ # @parameter code [Integer] The HTTP/2 error code.
73
+ # @returns [String] The error message.
74
+ def self.message_for(code)
75
+ return MESSAGES.fetch(code) do
76
+ # Unknown error codes are allowed by the protocol, but don't have a static message.
77
+ "Unknown code: #{code}!"
78
+ end
79
+ end
53
80
  end
54
81
 
55
82
  # Raised if connection header is missing or invalid indicating that
@@ -62,6 +89,13 @@ module Protocol
62
89
  # which signals termination of the current connection. You *cannot*
63
90
  # recover from this exception, or any exceptions subclassed from it.
64
91
  class ProtocolError < Error
92
+ # Build a protocol error for a given HTTP/2 error code.
93
+ # @parameter code [Integer] The HTTP/2 error code.
94
+ # @returns [ProtocolError] The protocol error.
95
+ def self.for(code)
96
+ return self.new(Error.message_for(code), code)
97
+ end
98
+
65
99
  # Initialize a protocol error with message and error code.
66
100
  # @parameter message [String] The error message.
67
101
  # @parameter code [Integer] The HTTP/2 error code.
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2025, by Samuel Williams.
4
+ # Copyright, 2019-2026, by Samuel Williams.
5
5
 
6
6
  require_relative "connection"
7
7
 
@@ -250,7 +250,11 @@ module Protocol
250
250
  @connection.delete(@id)
251
251
 
252
252
  if error_code
253
- error = StreamError.new("Stream closed!", error_code)
253
+ if error_code == REFUSED_STREAM
254
+ error = ::Protocol::HTTP::RefusedError.new("Stream refused.")
255
+ else
256
+ error = StreamError.for(error_code)
257
+ end
254
258
  end
255
259
 
256
260
  self.closed(error)
@@ -7,6 +7,6 @@
7
7
  module Protocol
8
8
  # @namespace
9
9
  module HTTP2
10
- VERSION = "0.25.0"
10
+ VERSION = "0.26.1"
11
11
  end
12
12
  end
data/readme.md CHANGED
@@ -14,6 +14,14 @@ Please see the [project documentation](https://socketry.github.io/protocol-http2
14
14
 
15
15
  Please see the [project releases](https://socketry.github.io/protocol-http2/releases/index) for all releases.
16
16
 
17
+ ### v0.26.1
18
+
19
+ - Improve `StreamError` messages for HTTP/2 stream reset error codes.
20
+
21
+ ### v0.26.0
22
+
23
+ - On RST\_STREAM with REFUSED\_STREAM, close the stream with `Protocol::HTTP::RefusedError` instead of `StreamError`.
24
+
17
25
  ### v0.25.0
18
26
 
19
27
  - On GOAWAY, proactively close unprocessed streams (ID above `last_stream_id`) with `Protocol::HTTP::RequestRefusedError`, enabling safe retry of non-idempotent requests.
@@ -51,16 +59,6 @@ Please see the [project releases](https://socketry.github.io/protocol-http2/rele
51
59
 
52
60
  - Reduced the number of window update frames sent to improve network efficiency.
53
61
 
54
- ### v0.19.3
55
-
56
- - Improved window update frame handling and performance optimizations.
57
- - Better implementation of `Window#inspect` for debugging.
58
-
59
- ### v0.19.2
60
-
61
- - Added traces to framer for better debugging and monitoring capabilities.
62
- - Minor fixes to logging output.
63
-
64
62
  ## See Also
65
63
 
66
64
  - [Async::HTTP](https://github.com/socketry/async-http) - A high-level HTTP client and server implementation.
data/releases.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Releases
2
2
 
3
+ ## v0.26.1
4
+
5
+ - Improve `StreamError` messages for HTTP/2 stream reset error codes.
6
+
7
+ ## v0.26.0
8
+
9
+ - On RST\_STREAM with REFUSED\_STREAM, close the stream with `Protocol::HTTP::RefusedError` instead of `StreamError`.
10
+
3
11
  ## v0.25.0
4
12
 
5
13
  - On GOAWAY, proactively close unprocessed streams (ID above `last_stream_id`) with `Protocol::HTTP::RequestRefusedError`, enabling safe retry of non-idempotent requests.
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.25.0
4
+ version: 0.26.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -62,14 +62,14 @@ dependencies:
62
62
  requirements:
63
63
  - - "~>"
64
64
  - !ruby/object:Gem::Version
65
- version: '0.61'
65
+ version: '0.62'
66
66
  type: :runtime
67
67
  prerelease: false
68
68
  version_requirements: !ruby/object:Gem::Requirement
69
69
  requirements:
70
70
  - - "~>"
71
71
  - !ruby/object:Gem::Version
72
- version: '0.61'
72
+ version: '0.62'
73
73
  executables: []
74
74
  extensions: []
75
75
  extra_rdoc_files: []
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  requirements: []
126
- rubygems_version: 4.0.6
126
+ rubygems_version: 4.0.10
127
127
  specification_version: 4
128
128
  summary: A low level implementation of the HTTP/2 protocol.
129
129
  test_files: []
metadata.gz.sig CHANGED
Binary file