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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/protocol/http1/body/chunked.rb +2 -2
- data/lib/protocol/http1/connection.rb +11 -3
- data/lib/protocol/http1/version.rb +1 -1
- data/license.md +1 -1
- data/readme.md +10 -9
- data/releases.md +9 -0
- data.tar.gz.sig +0 -0
- metadata +4 -4
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 137f467965c9f6d92343158ba1b30189ee672fe8a971d3f30217b3e795ae94e7
|
|
4
|
+
data.tar.gz: 22626362ed6f0579303487ab839324dc4bf5e499f0af5dd5ee5103bd83d1d401
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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-
|
|
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
|
-
|
|
359
|
-
|
|
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.
|
data/license.md
CHANGED
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
|
|
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.
|
|
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.
|
|
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.
|
|
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:
|
|
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
|