protocol-http1 0.27.0 → 0.28.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: 88bedd2de9b6357ee48174d2a984d5f8cdc391311b0ac13cbd21c4e398d2076b
4
- data.tar.gz: 4e631b85f63d21cd5dc4e93a49b014301d4faf42c8f0c04bc4341045a34cffe7
3
+ metadata.gz: fc8ca6665c69c40a8b356d22ba8657b0891f83136e82b16ce61ff5e26a24c50f
4
+ data.tar.gz: ebd6f58a3ed6caf1eb95c8d38e89ad85df3d9b3eb177bc89192a3ffe0710eda0
5
5
  SHA512:
6
- metadata.gz: 751ca8414f97b9e6a35daf7350e6e5afb5d59bb3c6be1d740aa78c57a838111c49757b0da43f2875899b6b94d050fc0d163dd4a9d449f2f8450a6b219b7a07fc
7
- data.tar.gz: 879adf7b92618c4707459c5498f1a8c5567a01c73c466c371f32488820f54b85b17ab92e1259434bf64d4e7b48dcc92d2a6e70eca273a90094ed87773a22c315
6
+ metadata.gz: 8612d1fd87cdd97d558410b1c85275944d9c11d51b7a3455aba22c53527e33a12890a62a055bb7c721e25e88064c1fbd9547db26287b8a890ac7baa1c3a2b45e
7
+ data.tar.gz: 50a8e5a03a1433c33d4cbc97dea073826741d89f68311f67de166aa85ce4be7a643828c059339fde50ebf147894f33974fdebd906dd2ed2860d30591f4b18a74
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
+ line = @stream.gets(CRLF, @maximum_line_length)
290
+
291
+ unless line.chomp!(CRLF)
292
+ # This basically means that the request line, response line, header, or chunked length line is too long.
293
+ raise LineLengthError, "Line too long!"
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.0"
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.0
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