protocol-http1 0.35.0 → 0.35.2

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: 500ff3e2663d7ee34b6ed02dfd6caf64c99f408ac7acd65661234e26017e3241
4
- data.tar.gz: de10d389495f6c4fe89ef1c38e0bb317add069b97b8812aac5575940434ae669
3
+ metadata.gz: 4bf3ffc440b97d40277fdf64e1962d31edb93d808fc6a3059234af3b8be6e9c0
4
+ data.tar.gz: 9495d1bf263831872363193cbe2dab89775c57d503eacbb74bd83dffe7863f8e
5
5
  SHA512:
6
- metadata.gz: 22d49079e478fe57d97c5f8a6f3002e14f9f77a7257731b7fb71af72c9faee4e15ea0415612d4d7fe78efcb0f287a6fb35f6776dda874cf0165d70991a7b73db
7
- data.tar.gz: 67cb62c06915622f623194bd43ec0944dc707feb98ac27fdf1ac98010a8f5e11fe5be05ea87b294226fccba0af97dc80a9183c2c7b9664f937c95fd2cfb8e431
6
+ metadata.gz: 549410520376936764b4c55653bcc2bc30fd770fa63c3befeb634d6e909be02ce94dd8a11c0823a46a9de106fb6d3fce03eeacc03066e0a100aa797328641f80
7
+ data.tar.gz: f0d72eb0d29c2e9d97fe725e53da409c5dbd0352df6575d44a27bab6a4d55fef929eb8a72adc0d484cb471479b383f425541881996c229f31ab2703b055ebb94
checksums.yaml.gz.sig CHANGED
Binary file
@@ -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.0"
8
+ VERSION = "0.35.2"
9
9
  end
10
10
  end
data/readme.md CHANGED
@@ -30,6 +30,11 @@ 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.35.2
34
+
35
+ - Tidy up implementation of `read_line?` to handle line length errors and protocol violations more clearly.
36
+ - Improve error handling for unexpected connection closures (`Errno::ECONNRESET`) in `read_line?`.
37
+
33
38
  ### v0.35.0
34
39
 
35
40
  - Add traces provider for `Protocol::HTTP1::Connection`.
@@ -68,10 +73,6 @@ Please see the [project releases](https://socketry.github.io/protocol-http1/rele
68
73
 
69
74
  - Fix handling of `nil` lines in HTTP parsing.
70
75
 
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,10 @@
1
1
  # Releases
2
2
 
3
+ ## v0.35.2
4
+
5
+ - Tidy up implementation of `read_line?` to handle line length errors and protocol violations more clearly.
6
+ - Improve error handling for unexpected connection closures (`Errno::ECONNRESET`) in `read_line?`.
7
+
3
8
  ## v0.35.0
4
9
 
5
10
  - 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.0
4
+ version: 0.35.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
Binary file