protocol-http1 0.35.1 → 0.36.0

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: 2726ec9583e06af47b9b37f5cefb493843bb1a5dff749a145bd117193048aa86
4
- data.tar.gz: f1c9bd6f71750cf67d038c98926048e3927b69f4efc64a49f92374f9d01b0b31
3
+ metadata.gz: 137f467965c9f6d92343158ba1b30189ee672fe8a971d3f30217b3e795ae94e7
4
+ data.tar.gz: 22626362ed6f0579303487ab839324dc4bf5e499f0af5dd5ee5103bd83d1d401
5
5
  SHA512:
6
- metadata.gz: 1d2b40ff72b50573db8975890a1ddd2a3366725407315f16d336aa72153caddd9a7a2d547b05bd12418dafbcc7f8810dde442821e600e4ee13a36c9aae0b7858
7
- data.tar.gz: ca70b6a65753b759d933495a8ca034b6fe3c431d869b6b08bd8ebb9a53488057be2c585c7c7b9d7c880a009d3edd341b973bbe8744ad05b5cd6e5df97e72035a
6
+ metadata.gz: 5f2a0846b2d60f1f6fbeaf9975010b6016dafd12d837b4357cfa0ba5d9bd05bbfac5b8ccc786b32cd3b181549f318e0d066fcea38cde3859d3ad7f85a62349ad
7
+ data.tar.gz: 13b18ef8bfff8bcbaca1c6031c65cf5612d8e75a1e86a3af23e572933b2b1c60290ece5bd82bac8103913142962baf21214abef8089daead1d66ce79115e30c5
checksums.yaml.gz.sig CHANGED
Binary file
@@ -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
  # Copyright, 2023, by Thomas Morgan.
6
6
 
7
7
  require "protocol/http/body/readable"
@@ -137,7 +137,7 @@ module Protocol
137
137
  break if line.empty?
138
138
 
139
139
  if match = line.match(HEADER)
140
- @headers.add(match[1], match[2])
140
+ @headers.add(match[1], match[2], trailer: true)
141
141
  else
142
142
  raise BadHeader, "Could not parse header: #{line.inspect}"
143
143
  end
@@ -350,17 +350,25 @@ module Protocol
350
350
  # Read a line from the connection.
351
351
  #
352
352
  # @returns [String | Nil] the line read, or nil if the connection is closed.
353
- # @raises [EOFError] if the connection is closed.
354
353
  # @raises [LineLengthError] if the line is too long.
354
+ # @raises [ProtocolError] if the line is not terminated properly.
355
355
  def read_line?
356
356
  if line = @stream.gets(CRLF, @maximum_line_length)
357
357
  unless line.chomp!(CRLF)
358
- # This basically means that the request line, response line, header, or chunked length line is too long.
359
- raise LineLengthError, "Line too long!"
358
+ if line.bytesize == @maximum_line_length
359
+ # This basically means that the request line, response line, header, or chunked length line is too long:
360
+ raise LineLengthError, "Line too long!"
361
+ else
362
+ # This means the line was not terminated properly, which is a protocol violation:
363
+ raise ProtocolError, "Line not terminated properly!"
364
+ end
360
365
  end
361
366
  end
362
367
 
363
368
  return line
369
+ # If a connection is shut down abruptly, we treat it as EOF, but only specifically in `read_line?`.
370
+ rescue Errno::ECONNRESET
371
+ return nil
364
372
  end
365
373
 
366
374
  # Read a line from the connection.
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Protocol
7
7
  module HTTP1
8
- VERSION = "0.35.1"
8
+ VERSION = "0.36.0"
9
9
  end
10
10
  end
data/license.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MIT License
2
2
 
3
- Copyright, 2019-2025, by Samuel Williams.
3
+ Copyright, 2019-2026, by Samuel Williams.
4
4
  Copyright, 2019, by Brian Morearty.
5
5
  Copyright, 2020, by Olle Jonsson.
6
6
  Copyright, 2020, by Bruno Sutic.
data/readme.md CHANGED
@@ -9,7 +9,7 @@ Provides a low-level implementation of the HTTP/1 protocol.
9
9
  Add this line to your application's Gemfile:
10
10
 
11
11
  ``` ruby
12
- gem 'protocol-http1'
12
+ gem "protocol-http1"
13
13
  ```
14
14
 
15
15
  And then execute:
@@ -30,6 +30,15 @@ Please see the [project documentation](https://socketry.github.io/protocol-http1
30
30
 
31
31
  Please see the [project releases](https://socketry.github.io/protocol-http1/releases/index) for all releases.
32
32
 
33
+ ### v0.36.0
34
+
35
+ - Indicate trailers from chunked body for better validation by `Protocol::HTTP::Headers`.
36
+
37
+ ### v0.35.2
38
+
39
+ - Tidy up implementation of `read_line?` to handle line length errors and protocol violations more clearly.
40
+ - Improve error handling for unexpected connection closures (`Errno::ECONNRESET`) in `read_line?`.
41
+
33
42
  ### v0.35.0
34
43
 
35
44
  - Add traces provider for `Protocol::HTTP1::Connection`.
@@ -64,14 +73,6 @@ Please see the [project releases](https://socketry.github.io/protocol-http1/rele
64
73
 
65
74
  - Add block/yield interface to `read_request` and `read_response` methods.
66
75
 
67
- ### v0.28.1
68
-
69
- - Fix handling of `nil` lines in HTTP parsing.
70
-
71
- ### v0.28.0
72
-
73
- - Add configurable maximum line length to prevent denial of service attacks.
74
-
75
76
  ## Contributing
76
77
 
77
78
  We welcome contributions to this project.
data/releases.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Releases
2
2
 
3
+ ## v0.36.0
4
+
5
+ - Indicate trailers from chunked body for better validation by `Protocol::HTTP::Headers`.
6
+
7
+ ## v0.35.2
8
+
9
+ - Tidy up implementation of `read_line?` to handle line length errors and protocol violations more clearly.
10
+ - Improve error handling for unexpected connection closures (`Errno::ECONNRESET`) in `read_line?`.
11
+
3
12
  ## v0.35.0
4
13
 
5
14
  - Add traces provider for `Protocol::HTTP1::Connection`.
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protocol-http1
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.35.1
4
+ version: 0.36.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -49,14 +49,14 @@ dependencies:
49
49
  requirements:
50
50
  - - "~>"
51
51
  - !ruby/object:Gem::Version
52
- version: '0.22'
52
+ version: '0.58'
53
53
  type: :runtime
54
54
  prerelease: false
55
55
  version_requirements: !ruby/object:Gem::Requirement
56
56
  requirements:
57
57
  - - "~>"
58
58
  - !ruby/object:Gem::Version
59
- version: '0.22'
59
+ version: '0.58'
60
60
  executables: []
61
61
  extensions: []
62
62
  extra_rdoc_files: []
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  - !ruby/object:Gem::Version
98
98
  version: '0'
99
99
  requirements: []
100
- rubygems_version: 3.6.9
100
+ rubygems_version: 4.0.3
101
101
  specification_version: 4
102
102
  summary: A low level implementation of the HTTP/1 protocol.
103
103
  test_files: []
metadata.gz.sig CHANGED
Binary file