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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ae0619e142c0e086b69d661ba9ae444330f52170bec2baff74241c7f49a906ba
4
- data.tar.gz: 6b9b328ea74065aa14d07ba55d7f16bb5890b8df98162991cd17e92050bfaf4d
3
+ metadata.gz: a2d1f5f6a59c2a1971e7d5e6ff1fdcfe73b67ad5046e5404e5daa30e40e39d83
4
+ data.tar.gz: aad5c5263c1086a6164412549f5d549a101b8871453770bcb4e7dc4f34f24044
5
5
  SHA512:
6
- metadata.gz: 216e6bb9c9b9f399c12b4f1e8c49f62ea2d9f2529e16249554159ab09b64d6eb84630235d2ad8c01344881509f9c4920aaa8c0ba5c5e0894d928623a2c43ea0b
7
- data.tar.gz: 3faf9365436e8b233047ee3b5a7c4393de83e31ca06c5b195e1ac7e97751b619bffaebd52c9351e02697fe9669b2f9a32514a8abdc3f0d0df5594a296aaddd39
6
+ metadata.gz: f0ed818d3d25dfba4cbbe6f44d5255b711aa657d3c3b85889d88e807a6fc551488c075bb0257f3c3f87e8855fa4389132bf1a931e0b7b8d3e38382fe48bcd732
7
+ data.tar.gz: 8a715d2bcd6b33c07f03b05bef621a87b75796c32d0a7aec9076125db3cdfb0c580513c6b7b4844fd0696fcaf0eb8f1df0f4542e23e4ea781cbcf140999530fb
@@ -72,8 +72,8 @@ module Protocol
72
72
  directives = self.parse_directives(directives)
73
73
 
74
74
  self.new(
75
- URI.decode(key),
76
- URI.decode(value),
75
+ URL.unescape(key),
76
+ URL.unescape(value),
77
77
  directives,
78
78
  )
79
79
  end
@@ -21,6 +21,7 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  require_relative 'multiple'
24
+ require_relative '../cookie'
24
25
 
25
26
  module Protocol
26
27
  module HTTP
@@ -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!) unless block_given?
113
+ return to_enum(:trailer) unless block_given?
116
114
 
117
115
  if @tail
118
116
  @fields.drop(@tail).each(&block)
@@ -23,13 +23,14 @@
23
23
  module Protocol
24
24
  module HTTP
25
25
  module URL
26
- # Escapes a generic string, using percent encoding.
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 a path
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
- # TODO Ruby 2.6 doesn't require `.each`
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)
@@ -22,6 +22,6 @@
22
22
 
23
23
  module Protocol
24
24
  module HTTP
25
- VERSION = "0.22.3"
25
+ VERSION = "0.22.6"
26
26
  end
27
27
  end
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.3
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: 2021-06-22 00:00:00.000000000 Z
11
+ date: 2022-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler