qeweney 0.8.1 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/Gemfile.lock +1 -1
- data/lib/qeweney/request_info.rb +11 -8
- data/lib/qeweney/routing.rb +1 -1
- data/lib/qeweney/version.rb +1 -1
- data/test/test_request_info.rb +19 -0
- data/test/test_routing.rb +1 -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: e7607c9eba1cc73f966e3da34d266c40aa0dec6d9294da905b49f3b3efc628ff
|
4
|
+
data.tar.gz: 16c15a7655cab3ed23437ed6f1f12d63df3676d63145cfb75a0505de1b8b5f3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ce90ffad9f012d33ebaf6a48100ad684151b1b62be47004fdc8d991e6e755755c15ce945a602d607d1124db962e7a49921e369d9c9dadb059c776ae7c94c175
|
7
|
+
data.tar.gz: 0b950d98a942954ae7c824c3a475eaaeb9752a6d7a854fbebd383a02afde1d703ddf530538900d5f79ba61eddc1ab8220a0e2b9e95c488be225170d62d7de296
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
## 0.9.1 2021-06-14
|
2
|
+
|
3
|
+
- Fix reading host from `:authority` header
|
4
|
+
|
5
|
+
## 0.9.0 2021-05-14
|
6
|
+
|
7
|
+
- Fix query parsing for fields with empty value
|
8
|
+
|
9
|
+
## 0.8.4 2021-03-23
|
10
|
+
|
11
|
+
- Rename and fix `#parse_query` to deal with no-value query parts
|
12
|
+
|
13
|
+
## 0.8.3 2021-03-22
|
14
|
+
|
15
|
+
- Streamline routing behaviour in sub routes (an explicit default sub route is
|
16
|
+
now required if no sub route matches)
|
17
|
+
|
18
|
+
## 0.8.2 2021-03-17
|
19
|
+
|
20
|
+
- Fix form parsing when charset is specified
|
21
|
+
|
1
22
|
## 0.8.1 2021-03-10
|
2
23
|
|
3
24
|
- Add `Request#transfer_counts`, `Request#total_transfer`
|
data/Gemfile.lock
CHANGED
data/lib/qeweney/request_info.rb
CHANGED
@@ -6,8 +6,9 @@ require 'escape_utils'
|
|
6
6
|
module Qeweney
|
7
7
|
module RequestInfoMethods
|
8
8
|
def host
|
9
|
-
@headers['host']
|
9
|
+
@headers['host'] || @headers[':authority']
|
10
10
|
end
|
11
|
+
alias_method :authority, :host
|
11
12
|
|
12
13
|
def connection
|
13
14
|
@headers['connection']
|
@@ -52,14 +53,16 @@ module Qeweney
|
|
52
53
|
def query
|
53
54
|
return @query if @query
|
54
55
|
|
55
|
-
@query = (q = uri.query) ?
|
56
|
+
@query = (q = uri.query) ? parse_query(q) : {}
|
56
57
|
end
|
57
58
|
|
58
|
-
|
59
|
+
QUERY_KV_REGEXP = /([^=]+)(?:=(.*))?/
|
60
|
+
|
61
|
+
def parse_query(query)
|
59
62
|
query.split('&').each_with_object({}) do |kv, h|
|
60
|
-
k, v = kv.
|
61
|
-
|
62
|
-
h[k.to_sym] = URI.decode_www_form_component(v)
|
63
|
+
k, v = kv.match(QUERY_KV_REGEXP)[1..2]
|
64
|
+
# k, v = kv.split('=')
|
65
|
+
h[k.to_sym] = v ? URI.decode_www_form_component(v) : true
|
63
66
|
end
|
64
67
|
end
|
65
68
|
|
@@ -102,10 +105,10 @@ module Qeweney
|
|
102
105
|
module RequestInfoClassMethods
|
103
106
|
def parse_form_data(body, headers)
|
104
107
|
case (content_type = headers['content-type'])
|
105
|
-
when
|
108
|
+
when /^multipart\/form\-data; boundary=([^\s]+)/
|
106
109
|
boundary = "--#{Regexp.last_match(1)}"
|
107
110
|
parse_multipart_form_data(body, boundary)
|
108
|
-
when
|
111
|
+
when /^application\/x-www-form-urlencoded/
|
109
112
|
parse_urlencoded_form_data(body)
|
110
113
|
else
|
111
114
|
raise "Unsupported form data content type: #{content_type}"
|
data/lib/qeweney/routing.rb
CHANGED
data/lib/qeweney/version.rb
CHANGED
data/test/test_request_info.rb
CHANGED
@@ -13,12 +13,31 @@ class RequestInfoTest < MiniTest::Test
|
|
13
13
|
assert_equal({ a: '1', b: '2', c: '3/4' }, r.query)
|
14
14
|
end
|
15
15
|
|
16
|
+
def test_query
|
17
|
+
r = Qeweney.mock(':path' => '/GponForm/diag_Form?images/')
|
18
|
+
assert_equal '/GponForm/diag_Form', r.path
|
19
|
+
assert_equal({:'images/' => true}, r.query)
|
20
|
+
|
21
|
+
r = Qeweney.mock(':path' => '/?a=1&b=2')
|
22
|
+
assert_equal '/', r.path
|
23
|
+
assert_equal({a: '1', b: '2'}, r.query)
|
24
|
+
|
25
|
+
r = Qeweney.mock(':path' => '/?l=a&t=&x=42')
|
26
|
+
assert_equal({l: 'a', t: '', x: '42'}, r.query)
|
27
|
+
end
|
28
|
+
|
16
29
|
def test_host
|
17
30
|
r = Qeweney.mock(':path' => '/')
|
18
31
|
assert_nil r.host
|
32
|
+
assert_nil r.authority
|
19
33
|
|
20
34
|
r = Qeweney.mock('host' => 'my.example.com')
|
21
35
|
assert_equal 'my.example.com', r.host
|
36
|
+
assert_equal 'my.example.com', r.authority
|
37
|
+
|
38
|
+
r = Qeweney.mock(':authority' => 'my.foo.com')
|
39
|
+
assert_equal 'my.foo.com', r.host
|
40
|
+
assert_equal 'my.foo.com', r.authority
|
22
41
|
end
|
23
42
|
|
24
43
|
def test_full_uri
|
data/test/test_routing.rb
CHANGED
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.
|
4
|
+
version: 0.9.1
|
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-
|
11
|
+
date: 2021-06-14 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.1.4
|
140
140
|
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: Qeweney - cross library HTTP request / response API
|