qeweney 0.8.4 → 0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/Gemfile.lock +1 -1
- data/lib/qeweney/mime_types.rb +5 -1
- data/lib/qeweney/rack.rb +5 -3
- data/lib/qeweney/request_info.rb +6 -2
- data/lib/qeweney/response.rb +1 -0
- data/lib/qeweney/version.rb +1 -1
- data/test/test_request_info.rb +9 -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: 256f14b402547865d5b7ce2357ef5ac79cd4f1f8e30129544450c7b8a60e39bb
|
4
|
+
data.tar.gz: 94ecbd44f44c1e858873315780ae0661237692a20396bf0a06b96497ea93f76a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 794a72410e59205ae66325aea81ee3d8a3b3e2bdaa7053118922e9a855f6d0e474d7d1e741787fe4b753a9c626e2672d9de4b95af14dc80c3f4a62175f72f0e5
|
7
|
+
data.tar.gz: 1775acaaa03ab16287f18dd18deb8d4720febcd2d13d1e502afbe8525a244921bb2b2946dee15da949f1aae9ed803275c2faf7b4675e4f6f6542554769ca0b94
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
## 0.11 2021-07-26
|
2
|
+
|
3
|
+
- Fix rack env (digital-fabric/tipi#11)
|
4
|
+
|
5
|
+
## 0.10 2021-06-24
|
6
|
+
|
7
|
+
- Include file stat in `#serve_io` options as hint for adapter
|
8
|
+
- Fix `MimeTypes#[]` for empty extension
|
9
|
+
|
10
|
+
## 0.9.1 2021-06-14
|
11
|
+
|
12
|
+
- Fix reading host from `:authority` header
|
13
|
+
|
14
|
+
## 0.9.0 2021-05-14
|
15
|
+
|
16
|
+
- Fix query parsing for fields with empty value
|
17
|
+
|
1
18
|
## 0.8.4 2021-03-23
|
2
19
|
|
3
20
|
- Rename and fix `#parse_query` to deal with no-value query parts
|
data/Gemfile.lock
CHANGED
data/lib/qeweney/mime_types.rb
CHANGED
@@ -19,12 +19,16 @@ module Qeweney
|
|
19
19
|
'json' => 'application/json',
|
20
20
|
}.freeze
|
21
21
|
|
22
|
+
EXT_REGEXP = /\.?([^\.]+)$/.freeze
|
23
|
+
|
22
24
|
def self.[](ref)
|
23
25
|
case ref
|
24
26
|
when Symbol
|
25
27
|
TYPES[ref.to_s]
|
26
|
-
when
|
28
|
+
when EXT_REGEXP
|
27
29
|
TYPES[Regexp.last_match(1)]
|
30
|
+
when ''
|
31
|
+
nil
|
28
32
|
else
|
29
33
|
raise "Invalid argument #{ref.inspect}"
|
30
34
|
end
|
data/lib/qeweney/rack.rb
CHANGED
@@ -69,7 +69,7 @@ module Qeweney
|
|
69
69
|
|
70
70
|
def self.rack_env_from_request(request)
|
71
71
|
Hash.new do |h, k|
|
72
|
-
h[k] =
|
72
|
+
h[k] = rack_env_value_from_request(request, k)
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
@@ -90,9 +90,11 @@ module Qeweney
|
|
90
90
|
'rack.multipar.tempfile_factory' => nil
|
91
91
|
}
|
92
92
|
|
93
|
-
|
93
|
+
HTTP_HEADER_RE = /^HTTP_(.+)$/.freeze
|
94
|
+
|
95
|
+
def self.rack_env_value_from_request(request, key)
|
94
96
|
case key
|
95
|
-
when 'REQUEST_METHOD' then request.method
|
97
|
+
when 'REQUEST_METHOD' then request.method.upcase
|
96
98
|
when 'PATH_INFO' then request.path
|
97
99
|
when 'QUERY_STRING' then request.query_string || ''
|
98
100
|
when 'SERVER_NAME' then request.headers['host']
|
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']
|
@@ -55,9 +56,12 @@ module Qeweney
|
|
55
56
|
@query = (q = uri.query) ? parse_query(q) : {}
|
56
57
|
end
|
57
58
|
|
59
|
+
QUERY_KV_REGEXP = /([^=]+)(?:=(.*))?/
|
60
|
+
|
58
61
|
def parse_query(query)
|
59
62
|
query.split('&').each_with_object({}) do |kv, h|
|
60
|
-
k, v = kv.
|
63
|
+
k, v = kv.match(QUERY_KV_REGEXP)[1..2]
|
64
|
+
# k, v = kv.split('=')
|
61
65
|
h[k.to_sym] = v ? URI.decode_www_form_component(v) : true
|
62
66
|
end
|
63
67
|
end
|
data/lib/qeweney/response.rb
CHANGED
data/lib/qeweney/version.rb
CHANGED
data/test/test_request_info.rb
CHANGED
@@ -21,14 +21,23 @@ class RequestInfoTest < MiniTest::Test
|
|
21
21
|
r = Qeweney.mock(':path' => '/?a=1&b=2')
|
22
22
|
assert_equal '/', r.path
|
23
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)
|
24
27
|
end
|
25
28
|
|
26
29
|
def test_host
|
27
30
|
r = Qeweney.mock(':path' => '/')
|
28
31
|
assert_nil r.host
|
32
|
+
assert_nil r.authority
|
29
33
|
|
30
34
|
r = Qeweney.mock('host' => 'my.example.com')
|
31
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
|
32
41
|
end
|
33
42
|
|
34
43
|
def test_full_uri
|
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.11'
|
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-07-26 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.6
|
140
140
|
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: Qeweney - cross library HTTP request / response API
|