qeweney 0.7.3 → 0.7.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/lib/qeweney/request_info.rb +20 -0
- data/lib/qeweney/version.rb +1 -1
- data/test/test_request_info.rb +22 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7beaa70b4d37af5b9bb46aa06bcd78e6d9353eada5715e28d22bc8b5fac61a4
|
4
|
+
data.tar.gz: 030c6f1fb05fde6ae12c2bb61844c98b9e821b4f7e21f1e7d51fa934814bc3b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82b3104f93f3ac826f2c4319fb4c9c324efbb490983af4b8035f402fcb04c13f8f8f28dd2443764dcff26e9d7e33f0eb071c3ec0005acefd4fe27cbd13d314e4
|
7
|
+
data.tar.gz: 9629ed95b4b7397fc8c15ef1b10b8948d31fc047e913c5aab9b7450eaa4ff31cbf7dde4b027870757eb02c0d72e00d8f766c57871aca9fc6948a75ed90adb769
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/qeweney/request_info.rb
CHANGED
@@ -37,6 +37,10 @@ module Qeweney
|
|
37
37
|
@uri ||= URI.parse(@headers[':path'] || '')
|
38
38
|
end
|
39
39
|
|
40
|
+
def full_uri
|
41
|
+
@full_uri = "#{scheme}://#{host}#{uri}"
|
42
|
+
end
|
43
|
+
|
40
44
|
def path
|
41
45
|
@path ||= uri.path
|
42
46
|
end
|
@@ -74,6 +78,22 @@ module Qeweney
|
|
74
78
|
|
75
79
|
encoding.split(',').map { |i| i.strip }
|
76
80
|
end
|
81
|
+
|
82
|
+
def cookies
|
83
|
+
@cookies ||= parse_cookies(headers['cookie'])
|
84
|
+
end
|
85
|
+
|
86
|
+
COOKIE_RE = /^([^=]+)=(.*)$/.freeze
|
87
|
+
SEMICOLON = ';'
|
88
|
+
|
89
|
+
def parse_cookies(cookies)
|
90
|
+
cookies.split(SEMICOLON).each_with_object({}) do |c, h|
|
91
|
+
raise BadRequestError, 'Invalid cookie format' unless c.strip =~ COOKIE_RE
|
92
|
+
|
93
|
+
key, value = Regexp.last_match[1..2]
|
94
|
+
h[key] = EscapeUtils.unescape_uri(value)
|
95
|
+
end
|
96
|
+
end
|
77
97
|
end
|
78
98
|
|
79
99
|
module RequestInfoClassMethods
|
data/lib/qeweney/version.rb
CHANGED
data/test/test_request_info.rb
CHANGED
@@ -20,4 +20,26 @@ class RequestInfoTest < MiniTest::Test
|
|
20
20
|
r = Qeweney.mock('host' => 'my.example.com')
|
21
21
|
assert_equal 'my.example.com', r.host
|
22
22
|
end
|
23
|
+
|
24
|
+
def test_full_uri
|
25
|
+
r = Qeweney.mock(
|
26
|
+
':scheme' => 'https',
|
27
|
+
'host' => 'foo.bar',
|
28
|
+
':path' => '/hey?a=b&c=d'
|
29
|
+
)
|
30
|
+
|
31
|
+
assert_equal 'https://foo.bar/hey?a=b&c=d', r.full_uri
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_cookies
|
35
|
+
r = Qeweney.mock(
|
36
|
+
'cookie' => 'uaid=a%2Fb; lastLocus=settings; signin_ref=/'
|
37
|
+
)
|
38
|
+
|
39
|
+
assert_equal({
|
40
|
+
'uaid' => 'a/b',
|
41
|
+
'lastLocus' => 'settings',
|
42
|
+
'signin_ref' => '/'
|
43
|
+
}, r.cookies)
|
44
|
+
end
|
23
45
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qeweney
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sharon Rosner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: escape_utils
|
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
136
|
- !ruby/object:Gem::Version
|
137
137
|
version: '0'
|
138
138
|
requirements: []
|
139
|
-
rubygems_version: 3.
|
139
|
+
rubygems_version: 3.0.8
|
140
140
|
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: Qeweney - cross library HTTP request / response API
|