protocol-http 0.22.5 → 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: 18e5cfb137351205caf1e8c38a22b3857b55593d75496784326918f7159e686d
4
- data.tar.gz: a9679ae47a3313b8fcd14dc5ea5a22b93fdf1a08c8d01f03dfdb81ea8ee16338
3
+ metadata.gz: a2d1f5f6a59c2a1971e7d5e6ff1fdcfe73b67ad5046e5404e5daa30e40e39d83
4
+ data.tar.gz: aad5c5263c1086a6164412549f5d549a101b8871453770bcb4e7dc4f34f24044
5
5
  SHA512:
6
- metadata.gz: f3a0305df607f355df9ad6ec5ec3db2442ced0bfd30ef792af8e1823b850a03a1f46069baf21aa52b802a31593ce11ab79fab2225016336872a7d0504b9c59e1
7
- data.tar.gz: ca27f71e4768d5b50590e85f9dabc5003a9daa367494f29eb8ce2e742cb22907a580c1b8f3a11ec0abe946b1cb7c036cddb9eb14c46202fbcce5d3c47a31a028
6
+ metadata.gz: f0ed818d3d25dfba4cbbe6f44d5255b711aa657d3c3b85889d88e807a6fc551488c075bb0257f3c3f87e8855fa4389132bf1a931e0b7b8d3e38382fe48bcd732
7
+ data.tar.gz: 8a715d2bcd6b33c07f03b05bef621a87b75796c32d0a7aec9076125db3cdfb0c580513c6b7b4844fd0696fcaf0eb8f1df0f4542e23e4ea781cbcf140999530fb
@@ -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.5"
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.5
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-07-15 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