protocol-http 0.22.3 → 0.22.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/protocol/http/cookie.rb +2 -2
- data/lib/protocol/http/header/cookie.rb +1 -0
- data/lib/protocol/http/headers.rb +1 -3
- data/lib/protocol/http/url.rb +9 -5
- data/lib/protocol/http/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2d1f5f6a59c2a1971e7d5e6ff1fdcfe73b67ad5046e5404e5daa30e40e39d83
|
4
|
+
data.tar.gz: aad5c5263c1086a6164412549f5d549a101b8871453770bcb4e7dc4f34f24044
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0ed818d3d25dfba4cbbe6f44d5255b711aa657d3c3b85889d88e807a6fc551488c075bb0257f3c3f87e8855fa4389132bf1a931e0b7b8d3e38382fe48bcd732
|
7
|
+
data.tar.gz: 8a715d2bcd6b33c07f03b05bef621a87b75796c32d0a7aec9076125db3cdfb0c580513c6b7b4844fd0696fcaf0eb8f1df0f4542e23e4ea781cbcf140999530fb
|
data/lib/protocol/http/cookie.rb
CHANGED
@@ -108,11 +108,9 @@ module Protocol
|
|
108
108
|
|
109
109
|
# Record the current headers, and prepare to receive trailer.
|
110
110
|
def trailer!(&block)
|
111
|
-
return nil unless self.include?(TRAILER)
|
112
|
-
|
113
111
|
@tail ||= @fields.size
|
114
112
|
|
115
|
-
return to_enum(:trailer
|
113
|
+
return to_enum(:trailer) unless block_given?
|
116
114
|
|
117
115
|
if @tail
|
118
116
|
@fields.drop(@tail).each(&block)
|
data/lib/protocol/http/url.rb
CHANGED
@@ -23,13 +23,14 @@
|
|
23
23
|
module Protocol
|
24
24
|
module HTTP
|
25
25
|
module URL
|
26
|
-
# Escapes a
|
26
|
+
# Escapes a string using percent encoding.
|
27
27
|
def self.escape(string, encoding = string.encoding)
|
28
28
|
string.b.gsub(/([^a-zA-Z0-9_.\-]+)/) do |m|
|
29
29
|
'%' + m.unpack('H2' * m.bytesize).join('%').upcase
|
30
30
|
end.force_encoding(encoding)
|
31
31
|
end
|
32
32
|
|
33
|
+
# Unescapes a percent encoded string.
|
33
34
|
def self.unescape(string, encoding = string.encoding)
|
34
35
|
string.b.gsub(/%(\h\h)/) do |hex|
|
35
36
|
Integer(hex, 16).chr
|
@@ -39,7 +40,7 @@ module Protocol
|
|
39
40
|
# According to https://tools.ietf.org/html/rfc3986#section-3.3, we escape non-pchar.
|
40
41
|
NON_PCHAR = /([^a-zA-Z0-9_\-\.~!$&'()*+,;=:@\/]+)/.freeze
|
41
42
|
|
42
|
-
# Escapes
|
43
|
+
# Escapes non-path characters using percent encoding.
|
43
44
|
def self.escape_path(path)
|
44
45
|
encoding = path.encoding
|
45
46
|
path.b.gsub(NON_PCHAR) do |m|
|
@@ -47,7 +48,7 @@ module Protocol
|
|
47
48
|
end.force_encoding(encoding)
|
48
49
|
end
|
49
50
|
|
50
|
-
# Encodes a hash or array into a query string
|
51
|
+
# Encodes a hash or array into a query string.
|
51
52
|
def self.encode(value, prefix = nil)
|
52
53
|
case value
|
53
54
|
when Array
|
@@ -67,9 +68,12 @@ module Protocol
|
|
67
68
|
end
|
68
69
|
end
|
69
70
|
|
71
|
+
# Scan a string for URL-encoded key/value pairs.
|
72
|
+
# @yields {|key, value| ...}
|
73
|
+
# @parameter key [String] The unescaped key.
|
74
|
+
# @parameter value [String] The unescaped key.
|
70
75
|
def self.scan(string)
|
71
|
-
|
72
|
-
string.split('&').each do |assignment|
|
76
|
+
string.split('&') do |assignment|
|
73
77
|
key, value = assignment.split('=', 2)
|
74
78
|
|
75
79
|
yield unescape(key), unescape(value)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: protocol-http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.22.
|
4
|
+
version: 0.22.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|