protocol-http1 0.27.0 → 0.28.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: 88bedd2de9b6357ee48174d2a984d5f8cdc391311b0ac13cbd21c4e398d2076b
4
- data.tar.gz: 4e631b85f63d21cd5dc4e93a49b014301d4faf42c8f0c04bc4341045a34cffe7
3
+ metadata.gz: 418429eead441a575d5129d78ec4eaa2806e354219b44f8be723ba263ed6dff4
4
+ data.tar.gz: 2306e29dfe8ecf2344fc0b3672be0b4bbab681139e81b3b7f710821aba858ee2
5
5
  SHA512:
6
- metadata.gz: 751ca8414f97b9e6a35daf7350e6e5afb5d59bb3c6be1d740aa78c57a838111c49757b0da43f2875899b6b94d050fc0d163dd4a9d449f2f8450a6b219b7a07fc
7
- data.tar.gz: 879adf7b92618c4707459c5498f1a8c5567a01c73c466c371f32488820f54b85b17ab92e1259434bf64d4e7b48dcc92d2a6e70eca273a90094ed87773a22c315
6
+ metadata.gz: f30451ee6eb024628fd4edb09b688206b4fb956080b11bd83ca1c243eb66a50473e03b710ff19cd1a94e1c34a3197bd3b584566694b5a3d9171c5d4b3de773f0
7
+ data.tar.gz: b89b24a8163a31f91d801472d3fc44f207dd909ad66c9caeffbd737c674e8905cdc93ac328db2aeca049896011ad093532e87fa608fe01672c645e55b6689f34
checksums.yaml.gz.sig CHANGED
Binary file
@@ -45,18 +45,22 @@ module Protocol
45
45
  VALID_FIELD_NAME = /\A#{FIELD_NAME}\z/.freeze
46
46
  VALID_FIELD_VALUE = /\A#{FIELD_VALUE}\z/.freeze
47
47
 
48
+ DEFAULT_MAXIMUM_LINE_LENGTH = 8192
49
+
48
50
  class Connection
49
51
  CRLF = "\r\n"
50
52
  HTTP10 = "HTTP/1.0"
51
53
  HTTP11 = "HTTP/1.1"
52
54
 
53
- def initialize(stream, persistent: true, state: :idle)
55
+ def initialize(stream, persistent: true, state: :idle, maximum_line_length: DEFAULT_MAXIMUM_LINE_LENGTH)
54
56
  @stream = stream
55
57
 
56
58
  @persistent = persistent
57
59
  @state = state
58
60
 
59
61
  @count = 0
62
+
63
+ @maximum_line_length = maximum_line_length
60
64
  end
61
65
 
62
66
  attr :stream
@@ -282,7 +286,14 @@ module Protocol
282
286
  end
283
287
 
284
288
  def read_line?
285
- @stream.gets(CRLF, chomp: true)
289
+ if line = @stream.gets(CRLF, @maximum_line_length)
290
+ unless line.chomp!(CRLF)
291
+ # This basically means that the request line, response line, header, or chunked length line is too long.
292
+ raise LineLengthError, "Line too long!"
293
+ end
294
+ end
295
+
296
+ return line
286
297
  end
287
298
 
288
299
  def read_line
@@ -14,6 +14,9 @@ module Protocol
14
14
  class ProtocolError < Error
15
15
  end
16
16
 
17
+ class LineLengthError < Error
18
+ end
19
+
17
20
  # The request was not able to be parsed correctly, or failed some kind of validation.
18
21
  class BadRequest < Error
19
22
  end
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Protocol
7
7
  module HTTP1
8
- VERSION = "0.27.0"
8
+ VERSION = "0.28.1"
9
9
  end
10
10
  end
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.27.0
4
+ version: 0.28.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -42,7 +42,7 @@ cert_chain:
42
42
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
43
43
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
44
44
  -----END CERTIFICATE-----
45
- date: 2024-09-24 00:00:00.000000000 Z
45
+ date: 2024-10-15 00:00:00.000000000 Z
46
46
  dependencies:
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: protocol-http
metadata.gz.sig CHANGED
Binary file