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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f42e3096a55b17945a57c5251356358d001c0dffccd946b6d15e45197a2b14e7
4
- data.tar.gz: 461d3ee59c50da3600f9dbb77240de119a796e720cfb3e5887f872e472619eb6
3
+ metadata.gz: 256f14b402547865d5b7ce2357ef5ac79cd4f1f8e30129544450c7b8a60e39bb
4
+ data.tar.gz: 94ecbd44f44c1e858873315780ae0661237692a20396bf0a06b96497ea93f76a
5
5
  SHA512:
6
- metadata.gz: 2b8767bb2d9c537d612270d14b99c250cc1094d5809d937a921da59aa53156ea91a06db51393fb0e98d850bbd996e6f7f019757f1e041ad25e65efcc1e1d4f20
7
- data.tar.gz: 8fc8247af91f73ceba720d76eb5ef0965d9543e72c6d8edfae9e8b951ddd7269b2d2c921abf7cca05b18037f165389f9c43d3b57093206e3b81975b67c4aac75
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- qeweney (0.8.4)
4
+ qeweney (0.11)
5
5
  escape_utils (~> 1.2.1)
6
6
 
7
7
  GEM
@@ -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] = env_value_from_request(request, 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
- def self.env_value_from_request(request, key)
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']
@@ -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.split('=')
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
@@ -74,6 +74,7 @@ module Qeweney
74
74
  end
75
75
 
76
76
  mime_type = Qeweney::MimeTypes[File.extname(path)]
77
+ opts[:stat] = stat
77
78
  (opts[:headers] ||= {})['Content-Type'] ||= mime_type if mime_type
78
79
 
79
80
  respond_with_static_file(full_path, etag, last_modified, opts)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Qeweney
4
- VERSION = '0.8.4'
4
+ VERSION = '0.11'
5
5
  end
@@ -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.8.4
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-03-23 00:00:00.000000000 Z
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.0.8
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