qeweney 0.8 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -0
- data/Gemfile.lock +1 -1
- data/lib/qeweney/request.rb +9 -1
- data/lib/qeweney/request_info.rb +9 -7
- data/lib/qeweney/routing.rb +1 -1
- data/lib/qeweney/version.rb +1 -1
- data/test/test_request_info.rb +13 -0
- data/test/test_routing.rb +1 -0
- 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: 1fbf7ec4eb0c73fef2003190fd086c46fff0edc74ab4544c5a36b7d6fcce4041
|
4
|
+
data.tar.gz: 328254edf151b4ce1acc201438b315eb6569c96868b84b9160a2ed0ff0636870
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31ba2523f8ef5dd0155eaba082967b1a2ee97bea5f40b319c3b3110e9cb549032909a95c9a5147161ed2613a9c3f8688d81496286684876c614f0b185629232b
|
7
|
+
data.tar.gz: 2d2b4a3b7a30b6a6ec5fa83c95e2b19a37bad50ab195af011ca52f504f597069d4d3ef0a60e6553a99132baac506fe6e0be570532392557be207923125f47577
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
## 0.9.0 2021-05-14
|
2
|
+
|
3
|
+
- Fix query parsing for fields with empty value
|
4
|
+
|
5
|
+
## 0.8.4 2021-03-23
|
6
|
+
|
7
|
+
- Rename and fix `#parse_query` to deal with no-value query parts
|
8
|
+
|
9
|
+
## 0.8.3 2021-03-22
|
10
|
+
|
11
|
+
- Streamline routing behaviour in sub routes (an explicit default sub route is
|
12
|
+
now required if no sub route matches)
|
13
|
+
|
14
|
+
## 0.8.2 2021-03-17
|
15
|
+
|
16
|
+
- Fix form parsing when charset is specified
|
17
|
+
|
18
|
+
## 0.8.1 2021-03-10
|
19
|
+
|
20
|
+
- Add `Request#transfer_counts`, `Request#total_transfer`
|
21
|
+
- Fix `Request#rx_incr`
|
22
|
+
|
1
23
|
## 0.8 2021-03-10
|
2
24
|
|
3
25
|
- Pass request as first argument to all adapter methods
|
data/Gemfile.lock
CHANGED
data/lib/qeweney/request.rb
CHANGED
@@ -106,11 +106,19 @@ module Qeweney
|
|
106
106
|
end
|
107
107
|
|
108
108
|
def rx_incr(count)
|
109
|
-
headers[':rx'] ? headers['
|
109
|
+
headers[':rx'] ? headers[':rx'] += count : headers[':rx'] = count
|
110
110
|
end
|
111
111
|
|
112
112
|
def tx_incr(count)
|
113
113
|
headers[':tx'] ? headers[':tx'] += count : headers[':tx'] = count
|
114
114
|
end
|
115
|
+
|
116
|
+
def transfer_counts
|
117
|
+
[headers[':rx'], headers[':tx']]
|
118
|
+
end
|
119
|
+
|
120
|
+
def total_transfer
|
121
|
+
(headers[':rx'] || 0) + (headers[':tx'] || 0)
|
122
|
+
end
|
115
123
|
end
|
116
124
|
end
|
data/lib/qeweney/request_info.rb
CHANGED
@@ -52,14 +52,16 @@ module Qeweney
|
|
52
52
|
def query
|
53
53
|
return @query if @query
|
54
54
|
|
55
|
-
@query = (q = uri.query) ?
|
55
|
+
@query = (q = uri.query) ? parse_query(q) : {}
|
56
56
|
end
|
57
57
|
|
58
|
-
|
58
|
+
QUERY_KV_REGEXP = /([^=]+)(?:=(.*))?/
|
59
|
+
|
60
|
+
def parse_query(query)
|
59
61
|
query.split('&').each_with_object({}) do |kv, h|
|
60
|
-
k, v = kv.
|
61
|
-
|
62
|
-
h[k.to_sym] = URI.decode_www_form_component(v)
|
62
|
+
k, v = kv.match(QUERY_KV_REGEXP)[1..2]
|
63
|
+
# k, v = kv.split('=')
|
64
|
+
h[k.to_sym] = v ? URI.decode_www_form_component(v) : true
|
63
65
|
end
|
64
66
|
end
|
65
67
|
|
@@ -102,10 +104,10 @@ module Qeweney
|
|
102
104
|
module RequestInfoClassMethods
|
103
105
|
def parse_form_data(body, headers)
|
104
106
|
case (content_type = headers['content-type'])
|
105
|
-
when
|
107
|
+
when /^multipart\/form\-data; boundary=([^\s]+)/
|
106
108
|
boundary = "--#{Regexp.last_match(1)}"
|
107
109
|
parse_multipart_form_data(body, boundary)
|
108
|
-
when
|
110
|
+
when /^application\/x-www-form-urlencoded/
|
109
111
|
parse_urlencoded_form_data(body)
|
110
112
|
else
|
111
113
|
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,6 +13,19 @@ 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
|
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:
|
4
|
+
version: 0.9.0
|
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-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: escape_utils
|