protocol-http 0.62.2 → 0.63.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/http/body/deflate.rb +4 -1
- data/lib/protocol/http/body/stream.rb +4 -1
- data/lib/protocol/http/header/accept_charset.rb +8 -0
- data/lib/protocol/http/header/accept_encoding.rb +8 -0
- data/lib/protocol/http/header/accept_language.rb +8 -0
- data/lib/protocol/http/header/te.rb +10 -1
- data/lib/protocol/http/methods.rb +4 -0
- data/lib/protocol/http/request.rb +17 -1
- data/lib/protocol/http/version.rb +1 -1
- data/readme.md +4 -5
- data/releases.md +4 -0
- data.tar.gz.sig +0 -0
- metadata +2 -2
- 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: 12be9d363df2ffd17498996e847c26fd84e807b7602d16592fc12ee27365bf30
|
|
4
|
+
data.tar.gz: 9c39629fe635e04e829a831eaf7f886f8c99e267426e55e139bee65a138798b2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 737b7089fbf76a2a985af0e4f95f1c81d2dda4f86608ef269841e9a1c12c70199612856b8a406627520cd092f85cd9c652351b582cd15d13c81901b2e6a3a419
|
|
7
|
+
data.tar.gz: 2c33f92c8cb86b4aad6bd962798aea79741e3389fc2741f4eb27982e659500281a559e25e4e3cec08d0407932da25411fed00f2a993bb76e70182490fe2888be
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
|
@@ -110,7 +110,10 @@ module Protocol
|
|
|
110
110
|
#
|
|
111
111
|
# @returns [String | Nil] the compressed chunk or `nil` if the stream is closed.
|
|
112
112
|
def read
|
|
113
|
-
|
|
113
|
+
if @stream.finished?
|
|
114
|
+
# Once the stream is finished, there is no more compressed output to produce:
|
|
115
|
+
return nil
|
|
116
|
+
end
|
|
114
117
|
|
|
115
118
|
# The stream might have been closed while waiting for the chunk to come in.
|
|
116
119
|
while chunk = super
|
|
@@ -200,7 +200,10 @@ module Protocol
|
|
|
200
200
|
split_offset = pattern.bytesize - 1
|
|
201
201
|
|
|
202
202
|
@buffer ||= read_next
|
|
203
|
-
|
|
203
|
+
if @buffer.nil?
|
|
204
|
+
# Without any buffered input, there is nothing to search for:
|
|
205
|
+
return nil
|
|
206
|
+
end
|
|
204
207
|
|
|
205
208
|
until index = @buffer.index(pattern, offset)
|
|
206
209
|
offset = @buffer.bytesize - split_offset
|
|
@@ -17,11 +17,19 @@ module Protocol
|
|
|
17
17
|
# https://tools.ietf.org/html/rfc7231#section-5.3.3
|
|
18
18
|
CHARSET = /\A(?<name>#{TOKEN})(;q=(?<q>#{QVALUE}))?\z/
|
|
19
19
|
|
|
20
|
+
# A parsed character set entry with an optional quality factor.
|
|
20
21
|
Charset = Struct.new(:name, :q) do
|
|
22
|
+
# The quality factor for this character set.
|
|
23
|
+
#
|
|
24
|
+
# @returns [Float] the parsed quality factor, defaulting to `1.0`.
|
|
21
25
|
def quality_factor
|
|
22
26
|
(q || 1.0).to_f
|
|
23
27
|
end
|
|
24
28
|
|
|
29
|
+
# Compare character sets by descending quality factor.
|
|
30
|
+
#
|
|
31
|
+
# @parameter other [Charset] the other character set to compare.
|
|
32
|
+
# @returns [Integer] the comparison result.
|
|
25
33
|
def <=> other
|
|
26
34
|
other.quality_factor <=> self.quality_factor
|
|
27
35
|
end
|
|
@@ -20,11 +20,19 @@ module Protocol
|
|
|
20
20
|
# https://tools.ietf.org/html/rfc7231#section-5.3.4
|
|
21
21
|
ENCODING = /\A(?<name>#{TOKEN})(;q=(?<q>#{QVALUE}))?\z/
|
|
22
22
|
|
|
23
|
+
# A parsed content encoding entry with an optional quality factor.
|
|
23
24
|
Encoding = Struct.new(:name, :q) do
|
|
25
|
+
# The quality factor for this encoding.
|
|
26
|
+
#
|
|
27
|
+
# @returns [Float] the parsed quality factor, defaulting to `1.0`.
|
|
24
28
|
def quality_factor
|
|
25
29
|
(q || 1.0).to_f
|
|
26
30
|
end
|
|
27
31
|
|
|
32
|
+
# Compare encodings by descending quality factor.
|
|
33
|
+
#
|
|
34
|
+
# @parameter other [Encoding] the other encoding to compare.
|
|
35
|
+
# @returns [Integer] the comparison result.
|
|
28
36
|
def <=> other
|
|
29
37
|
other.quality_factor <=> self.quality_factor
|
|
30
38
|
end
|
|
@@ -23,11 +23,19 @@ module Protocol
|
|
|
23
23
|
# https://greenbytes.de/tech/webdav/rfc7231.html#quality.values
|
|
24
24
|
LANGUAGE = /\A(?<name>#{NAME})(\s*;\s*q=(?<q>#{QVALUE}))?\z/
|
|
25
25
|
|
|
26
|
+
# A parsed language entry with an optional quality factor.
|
|
26
27
|
Language = Struct.new(:name, :q) do
|
|
28
|
+
# The quality factor for this language.
|
|
29
|
+
#
|
|
30
|
+
# @returns [Float] the parsed quality factor, defaulting to `1.0`.
|
|
27
31
|
def quality_factor
|
|
28
32
|
(q || 1.0).to_f
|
|
29
33
|
end
|
|
30
34
|
|
|
35
|
+
# Compare languages by descending quality factor.
|
|
36
|
+
#
|
|
37
|
+
# @parameter other [Language] the other language to compare.
|
|
38
|
+
# @returns [Integer] the comparison result.
|
|
31
39
|
def <=> other
|
|
32
40
|
other.quality_factor <=> self.quality_factor
|
|
33
41
|
end
|
|
@@ -45,14 +45,24 @@ module Protocol
|
|
|
45
45
|
|
|
46
46
|
# A single transfer coding entry with optional quality factor
|
|
47
47
|
TransferCoding = Struct.new(:name, :q) do
|
|
48
|
+
# The quality factor for this transfer coding.
|
|
49
|
+
#
|
|
50
|
+
# @returns [Float] the parsed quality factor, defaulting to `1.0`.
|
|
48
51
|
def quality_factor
|
|
49
52
|
(q || 1.0).to_f
|
|
50
53
|
end
|
|
51
54
|
|
|
55
|
+
# Compare transfer codings by descending quality factor.
|
|
56
|
+
#
|
|
57
|
+
# @parameter other [TransferCoding] the other transfer coding to compare.
|
|
58
|
+
# @returns [Integer] the comparison result.
|
|
52
59
|
def <=> other
|
|
53
60
|
other.quality_factor <=> self.quality_factor
|
|
54
61
|
end
|
|
55
62
|
|
|
63
|
+
# Convert the transfer coding entry to a header value.
|
|
64
|
+
#
|
|
65
|
+
# @returns [String] the formatted transfer coding with quality factor when present.
|
|
56
66
|
def to_s
|
|
57
67
|
if q && q != 1.0
|
|
58
68
|
"#{name};q=#{q}"
|
|
@@ -143,4 +153,3 @@ module Protocol
|
|
|
143
153
|
end
|
|
144
154
|
end
|
|
145
155
|
end
|
|
146
|
-
|
|
@@ -18,6 +18,7 @@ module Protocol
|
|
|
18
18
|
# | OPTIONS | Optional | Yes | Yes | Yes | No |
|
|
19
19
|
# | TRACE | No | Yes | Yes | Yes | No |
|
|
20
20
|
# | PATCH | Yes | Yes | No | No | No |
|
|
21
|
+
# | QUERY | Yes | Yes | Yes | Yes | Yes |
|
|
21
22
|
#
|
|
22
23
|
# These methods are defined in this module using lower case names. They are for convenience only and you should not overload those methods.
|
|
23
24
|
#
|
|
@@ -50,6 +51,9 @@ module Protocol
|
|
|
50
51
|
# The PATCH method applies partial modifications to a resource.
|
|
51
52
|
PATCH = "PATCH"
|
|
52
53
|
|
|
54
|
+
# The QUERY method performs a read-only, idempotent query using a request body.
|
|
55
|
+
QUERY = "QUERY"
|
|
56
|
+
|
|
53
57
|
# Check if the given name is a valid HTTP method, according to this module.
|
|
54
58
|
#
|
|
55
59
|
# Note that this method only knows about the methods defined in this module, however there are many other methods defined in different specifications.
|
|
@@ -134,7 +134,23 @@ module Protocol
|
|
|
134
134
|
|
|
135
135
|
# Whether the request can be replayed without side-effects.
|
|
136
136
|
def idempotent?
|
|
137
|
-
|
|
137
|
+
# QUERY requests are idempotent, even if they have a body:
|
|
138
|
+
if @method == Methods::QUERY
|
|
139
|
+
return true
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# POST requests are not idempotent, even if they have no body:
|
|
143
|
+
if @method == Methods::POST
|
|
144
|
+
return false
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
# All other requests are idempotent if they have no body:
|
|
148
|
+
if @body.nil? || @body.empty?
|
|
149
|
+
return true
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
# Otherwise, we don't know if the request is idempotent or not, so we assume it is not:
|
|
153
|
+
return false
|
|
138
154
|
end
|
|
139
155
|
|
|
140
156
|
# Convert the request to a hash, suitable for serialization.
|
data/readme.md
CHANGED
|
@@ -30,6 +30,10 @@ Please see the [project documentation](https://socketry.github.io/protocol-http/
|
|
|
30
30
|
|
|
31
31
|
Please see the [project releases](https://socketry.github.io/protocol-http/releases/index) for all releases.
|
|
32
32
|
|
|
33
|
+
### v0.63.0
|
|
34
|
+
|
|
35
|
+
- Add support for the HTTP `QUERY` method.
|
|
36
|
+
|
|
33
37
|
### v0.62.1
|
|
34
38
|
|
|
35
39
|
- Fix handling of `Stream#read(0)`, it must return a mutable string (or clear the given buffer).
|
|
@@ -80,11 +84,6 @@ Please see the [project releases](https://socketry.github.io/protocol-http/relea
|
|
|
80
84
|
- `Protocol::HTTP::URL` -\> `Protocol::URL::Encoding`.
|
|
81
85
|
- `Protocol::HTTP::Reference` -\> `Protocol::URL::Reference`.
|
|
82
86
|
|
|
83
|
-
### v0.54.0
|
|
84
|
-
|
|
85
|
-
- Introduce rich support for `Header::Digest`, `Header::ServerTiming`, `Header::TE`, `Header::Trailer` and `Header::TransferEncoding`.
|
|
86
|
-
- [Improved HTTP Trailer Security](https://socketry.github.io/protocol-http/releases/index#improved-http-trailer-security)
|
|
87
|
-
|
|
88
87
|
## See Also
|
|
89
88
|
|
|
90
89
|
- [protocol-http1](https://github.com/socketry/protocol-http1) — HTTP/1 client/server implementation using this
|
data/releases.md
CHANGED
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: protocol-http
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.63.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Williams
|
|
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
135
135
|
- !ruby/object:Gem::Version
|
|
136
136
|
version: '0'
|
|
137
137
|
requirements: []
|
|
138
|
-
rubygems_version: 4.0.
|
|
138
|
+
rubygems_version: 4.0.10
|
|
139
139
|
specification_version: 4
|
|
140
140
|
summary: Provides abstractions to handle HTTP protocols.
|
|
141
141
|
test_files: []
|
metadata.gz.sig
CHANGED
|
Binary file
|