protocol-http 0.19.0 → 0.20.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
- data/lib/protocol/http/cookie.rb +1 -1
- data/lib/protocol/http/header/authorization.rb +15 -13
- data/lib/protocol/http/header/etag.rb +0 -2
- data/lib/protocol/http/headers.rb +6 -2
- data/lib/protocol/http/methods.rb +1 -1
- data/lib/protocol/http/reference.rb +1 -3
- 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: 155e5d73168b2ff9c429d2677150ae8a30e87ee8fb25a582ac30671f8e015ad2
|
|
4
|
+
data.tar.gz: c3ae63c177fc673100717c5f2c81bbde8e8a3192de7d010e903593f82d68f2e4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '08db581bcc0840a176039b99f8a9bb31c9db02fb9476ef318c26db8b37d73626754d929efd3cddc70446c5dbecb1708d8bb0347c873a0328b79fe6a0faf6fcdb'
|
|
7
|
+
data.tar.gz: 64a7ff013c2e459c594f9c87dcd19d0056d9492136b9c97121d411ebafd74cfe47feacc76842863af7e40d9c38a877ef143e6d0253cf052a63648091f829f8d0
|
data/lib/protocol/http/cookie.rb
CHANGED
|
@@ -26,21 +26,23 @@ module Protocol
|
|
|
26
26
|
module HTTP
|
|
27
27
|
module Header
|
|
28
28
|
# Used for basic authorization.
|
|
29
|
-
#
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
def encoded
|
|
39
|
-
"#{@username}:#{@password}"
|
|
29
|
+
#
|
|
30
|
+
# ~~~ ruby
|
|
31
|
+
# headers.add('authorization', Authorization.basic("my_username", "my_password"))
|
|
32
|
+
# ~~~
|
|
33
|
+
class Authorization < String
|
|
34
|
+
# Splits the header and
|
|
35
|
+
# @return [Tuple(String, String)]
|
|
36
|
+
def credentials
|
|
37
|
+
self.split(/\s+/, 2)
|
|
40
38
|
end
|
|
41
39
|
|
|
42
|
-
def
|
|
43
|
-
|
|
40
|
+
def self.basic(username, password)
|
|
41
|
+
encoded = "#{username}:#{password}"
|
|
42
|
+
|
|
43
|
+
self.new(
|
|
44
|
+
"Basic #{Base64.strict_encode64(encoded)}"
|
|
45
|
+
)
|
|
44
46
|
end
|
|
45
47
|
end
|
|
46
48
|
end
|
|
@@ -28,6 +28,7 @@ require_relative 'header/cache_control'
|
|
|
28
28
|
require_relative 'header/etag'
|
|
29
29
|
require_relative 'header/etags'
|
|
30
30
|
require_relative 'header/vary'
|
|
31
|
+
require_relative 'header/authorization'
|
|
31
32
|
|
|
32
33
|
module Protocol
|
|
33
34
|
module HTTP
|
|
@@ -170,6 +171,7 @@ module Protocol
|
|
|
170
171
|
end
|
|
171
172
|
|
|
172
173
|
# Add the specified header key value pair.
|
|
174
|
+
#
|
|
173
175
|
# @param key [String] the header key.
|
|
174
176
|
# @param value [String] the header value to assign.
|
|
175
177
|
def add(key, value)
|
|
@@ -216,8 +218,6 @@ module Protocol
|
|
|
216
218
|
'user-agent' => false,
|
|
217
219
|
'referer' => false,
|
|
218
220
|
'host' => false,
|
|
219
|
-
'authorization' => false,
|
|
220
|
-
'proxy-authorization' => false,
|
|
221
221
|
'if-modified-since' => false,
|
|
222
222
|
'if-unmodified-since' => false,
|
|
223
223
|
'from' => false,
|
|
@@ -233,6 +233,10 @@ module Protocol
|
|
|
233
233
|
'via' => Split,
|
|
234
234
|
'x-forwarded-for' => Split,
|
|
235
235
|
|
|
236
|
+
# Authorization headers:
|
|
237
|
+
'authorization' => Header::Authorization,
|
|
238
|
+
'proxy-authorization' => Header::Authorization,
|
|
239
|
+
|
|
236
240
|
# Cache validations:
|
|
237
241
|
'etag' => Header::ETag,
|
|
238
242
|
'if-match' => Header::ETags,
|
|
@@ -53,7 +53,7 @@ module Protocol
|
|
|
53
53
|
self.each do |name, value|
|
|
54
54
|
define_method(name.downcase) do |location, headers = nil, body = nil|
|
|
55
55
|
self.call(
|
|
56
|
-
Request[value, location.
|
|
56
|
+
Request[value, location.to_s, Headers[headers], body]
|
|
57
57
|
)
|
|
58
58
|
end
|
|
59
59
|
end
|
|
@@ -110,12 +110,10 @@ module Protocol
|
|
|
110
110
|
return buffer
|
|
111
111
|
end
|
|
112
112
|
|
|
113
|
-
def
|
|
113
|
+
def to_s
|
|
114
114
|
append(String.new)
|
|
115
115
|
end
|
|
116
116
|
|
|
117
|
-
alias to_s to_str
|
|
118
|
-
|
|
119
117
|
# Merges two references as specified by RFC2396, similar to `URI.join`.
|
|
120
118
|
def + other
|
|
121
119
|
other = self.class[other]
|
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.
|
|
4
|
+
version: 0.20.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Williams
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-05-
|
|
11
|
+
date: 2020-05-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: covered
|