protocol-http1 0.41.0 → 0.41.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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/protocol/http1/connection.rb +46 -16
- data/lib/protocol/http1/version.rb +1 -1
- data/readme.md +4 -2
- data.tar.gz.sig +0 -0
- metadata +24 -28
- 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: 0df45b5ae5b698e1b6ecb3d1e37e88315f0f8e3511dbf0052149ddcc00de2e93
|
|
4
|
+
data.tar.gz: 8b75994439528fc421eab75b6642166de4f5248a3b51548face0ca24e199f451
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 33ece8b67fa985ea00095b7cc2d990db997e7bec63b95f8e488abd29f8a232b6308c2c976acaa9759a26181652b019b5f4bbe1205f3e8b69e25574b47a1bc3ea
|
|
7
|
+
data.tar.gz: cda5a75e61108eccc561267225588669c4049beca9d2b90fbfd0afda9787d48cae8f56afb4bcecbb8e7e79a16d266eb946faba156aef006b00c1c894c6373b3e
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
|
@@ -33,6 +33,7 @@ module Protocol
|
|
|
33
33
|
|
|
34
34
|
# HTTP/1.x request line parser:
|
|
35
35
|
TOKEN = /[!#$%&'*+\-\.\^_`|~0-9a-zA-Z]+/.freeze
|
|
36
|
+
VALID_METHOD = /\A#{TOKEN}\z/.freeze
|
|
36
37
|
REQUEST_LINE = /\A(#{TOKEN}) ([^\s]+) (HTTP\/\d.\d)\z/.freeze
|
|
37
38
|
|
|
38
39
|
# HTTP/1.x header parser:
|
|
@@ -185,7 +186,8 @@ module Protocol
|
|
|
185
186
|
|
|
186
187
|
# Write the appropriate header for connection upgrade.
|
|
187
188
|
def write_upgrade_header(upgrade)
|
|
188
|
-
|
|
189
|
+
write_header(CONNECTION, "upgrade")
|
|
190
|
+
write_header(UPGRADE, upgrade)
|
|
189
191
|
end
|
|
190
192
|
|
|
191
193
|
# Indicates whether the connection has been hijacked meaning its IO has been handed over and is not usable anymore.
|
|
@@ -253,6 +255,8 @@ module Protocol
|
|
|
253
255
|
#
|
|
254
256
|
# Transitions to the open state.
|
|
255
257
|
#
|
|
258
|
+
# Requires the method to be an HTTP token and rejects CR, LF, and NUL bytes in the authority and target before writing any request bytes.
|
|
259
|
+
#
|
|
256
260
|
# @parameter authority [String] the authority of the request.
|
|
257
261
|
# @parameter method [String] the HTTP method.
|
|
258
262
|
# @parameter target [String] the request target.
|
|
@@ -260,6 +264,23 @@ module Protocol
|
|
|
260
264
|
# @parameter headers [Hash] the HTTP headers.
|
|
261
265
|
# @raises [RefusedError] if the request was not processed.
|
|
262
266
|
def write_request(authority, method, target, version, headers)
|
|
267
|
+
method = method.to_s
|
|
268
|
+
unless method.b.match?(VALID_METHOD)
|
|
269
|
+
raise InvalidRequest, "Invalid request method: #{method.inspect}"
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
target = target.to_s
|
|
273
|
+
unless target.b.match?(VALID_FIELD_VALUE)
|
|
274
|
+
raise InvalidRequest, "Invalid request target: #{target.inspect}"
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
if authority
|
|
278
|
+
authority = authority.to_s
|
|
279
|
+
unless authority.b.match?(VALID_FIELD_VALUE)
|
|
280
|
+
raise InvalidRequest, "Invalid request authority: #{authority.inspect}"
|
|
281
|
+
end
|
|
282
|
+
end
|
|
283
|
+
|
|
263
284
|
open!
|
|
264
285
|
|
|
265
286
|
write_stream("#{method} #{target} #{version}\r\n")
|
|
@@ -311,27 +332,36 @@ module Protocol
|
|
|
311
332
|
flush_stream
|
|
312
333
|
end
|
|
313
334
|
|
|
335
|
+
# Write a header to the connection, rejecting CR, LF, and NUL in its value.
|
|
336
|
+
#
|
|
337
|
+
# @parameter name [String] the header name.
|
|
338
|
+
# @parameter value [String] the header value.
|
|
339
|
+
# @raises [BadHeader] if the header name or value is invalid.
|
|
340
|
+
def write_header(name, value)
|
|
341
|
+
# Convert it to a string:
|
|
342
|
+
name = name.to_s
|
|
343
|
+
value = value.to_s
|
|
344
|
+
|
|
345
|
+
# Validate it:
|
|
346
|
+
unless name.match?(VALID_FIELD_NAME)
|
|
347
|
+
raise BadHeader, "Invalid header name: #{name.inspect}"
|
|
348
|
+
end
|
|
349
|
+
|
|
350
|
+
unless value.match?(VALID_FIELD_VALUE)
|
|
351
|
+
raise BadHeader, "Invalid header value for #{name}: #{value.inspect}"
|
|
352
|
+
end
|
|
353
|
+
|
|
354
|
+
# Write it:
|
|
355
|
+
write_stream("#{name}: #{value}\r\n")
|
|
356
|
+
end
|
|
357
|
+
|
|
314
358
|
# Write headers to the connection.
|
|
315
359
|
#
|
|
316
360
|
# @parameter headers [Hash] the headers to write.
|
|
317
361
|
# @raises [BadHeader] if the header name or value is invalid.
|
|
318
362
|
def write_headers(headers)
|
|
319
363
|
headers.each do |name, value|
|
|
320
|
-
|
|
321
|
-
name = name.to_s
|
|
322
|
-
value = value.to_s
|
|
323
|
-
|
|
324
|
-
# Validate it:
|
|
325
|
-
unless name.match?(VALID_FIELD_NAME)
|
|
326
|
-
raise BadHeader, "Invalid header name: #{name.inspect}"
|
|
327
|
-
end
|
|
328
|
-
|
|
329
|
-
unless value.match?(VALID_FIELD_VALUE)
|
|
330
|
-
raise BadHeader, "Invalid header value for #{name}: #{value.inspect}"
|
|
331
|
-
end
|
|
332
|
-
|
|
333
|
-
# Write it:
|
|
334
|
-
write_stream("#{name}: #{value}\r\n")
|
|
364
|
+
write_header(name, value)
|
|
335
365
|
end
|
|
336
366
|
end
|
|
337
367
|
|
data/readme.md
CHANGED
|
@@ -91,12 +91,14 @@ bundle exec sus
|
|
|
91
91
|
|
|
92
92
|
### Making Releases
|
|
93
93
|
|
|
94
|
-
To
|
|
94
|
+
To prepare a release branch and open a pull request from an up-to-date `main`:
|
|
95
95
|
|
|
96
96
|
``` shell
|
|
97
|
-
bundle exec bake gem:release:patch # or minor or major
|
|
97
|
+
bundle exec bake gem:github:release:patch # or minor or major
|
|
98
98
|
```
|
|
99
99
|
|
|
100
|
+
See [bake-gem-github](https://github.com/socketry/bake-gem-github) for setup, remote releases, and recovery.
|
|
101
|
+
|
|
100
102
|
### Developer Certificate of Origin
|
|
101
103
|
|
|
102
104
|
In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed.
|
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.41.
|
|
4
|
+
version: 0.41.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Williams
|
|
@@ -14,32 +14,28 @@ bindir: bin
|
|
|
14
14
|
cert_chain:
|
|
15
15
|
- |
|
|
16
16
|
-----BEGIN CERTIFICATE-----
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
JkxfQWC+jBVeG9ZtPhQgZpfhvh+6hMhraUYRQ6XGyvBqEUe+yo6DKIT3MtGE2+CP
|
|
40
|
-
eX9i9ZWBydWb8/rvmwmX2kkcBbX0hZS1rcR593hGc61JR6lvkGYQ2MYskBveyaxt
|
|
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NVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU
|
|
30
|
+
SuMc0x24Xshtaa8SQVkBr2Z5WzIwDQYJKoZIhvcNAQELBQADggGBABI62ey5lDWm
|
|
31
|
+
j8jsTQaNBMBb7LbKS3XkBwyL1UNGEwlicp399rJDeuNgVSHqBCZ/nE4yleNjgW9Y
|
|
32
|
+
N6DKdxXCvXmFUoHvUINeAvThHxmlEGhSfXl1x55xHEig0rEP4jgdjnYdQI4fqeOM
|
|
33
|
+
zIDN0F3ruArke4Y62SQgWVN7vspdAA41hBIRl1vsvs0KWG8DIVQ8cmR+TG6zjOmK
|
|
34
|
+
iUiUZGNPnStV1O1xW83c+Ba4Am0krP6/forxDPhRvTehqkVYvMdPfYcICNb5IM58
|
|
35
|
+
5vaYvuj5AtfZuZWN0F/0KtSphhNC17rh6h8QmuYdMJ1clvlrkiEaO1UjPVwjgtxC
|
|
36
|
+
x/ARh5X6q0/YTXl4r7EfSJEeqW7qhgu9EUj3mGIPHYdX0Dqih/NgK20F3GvQtTfB
|
|
37
|
+
7sse0duKBHXONYVwKAsceUVvqtCfyF608bCilCkbhw3QaInRj+BkRQKJ5Tuj2PZR
|
|
38
|
+
76a/hwaV2wWn5RtAFBaUQzQdo/xTqJ7IkwaFjOZe/QyvyoRjCK9Rdg==
|
|
43
39
|
-----END CERTIFICATE-----
|
|
44
40
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
45
41
|
dependencies:
|
|
@@ -96,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
96
92
|
- !ruby/object:Gem::Version
|
|
97
93
|
version: '0'
|
|
98
94
|
requirements: []
|
|
99
|
-
rubygems_version: 4.0.
|
|
95
|
+
rubygems_version: 4.0.21
|
|
100
96
|
specification_version: 4
|
|
101
97
|
summary: A low level implementation of the HTTP/1 protocol.
|
|
102
98
|
test_files: []
|
metadata.gz.sig
CHANGED
|
Binary file
|