puma 2.12.1 → 2.12.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puma might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/History.txt +6 -0
- data/Manifest.txt +1 -0
- data/ext/puma_http11/org/jruby/puma/MiniSSL.java +5 -0
- data/lib/puma/const.rb +1 -1
- data/lib/puma/rack/builder.rb +2 -0
- data/lib/puma/rack/urlmap.rb +90 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acc6978f0afad6cb3d2f28d834f2c60c08f6f6a9
|
4
|
+
data.tar.gz: 24c4f715b9b474a438567ce91314ce24e17f1acb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 115b5753fb3487f7a6e3ae3e0009c75bea89d2cbe9b1b67bf1de52e6795f7788123034a54627b38be5585061ce34db46ba7108f8cff03abef478fc6081cf3854
|
7
|
+
data.tar.gz: 9b7198cca050cc284a335184a7ab3ec630ec5bfe081a44e0760abf1b748ae0388c4b0171b609574ba27748445be5ecf16a62b371aa0dfe58e9dbc05454018420
|
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
data/lib/puma/const.rb
CHANGED
data/lib/puma/rack/builder.rb
CHANGED
@@ -290,6 +290,8 @@ module Puma::Rack
|
|
290
290
|
private
|
291
291
|
|
292
292
|
def generate_map(default_app, mapping)
|
293
|
+
require 'puma/rack/urlmap'
|
294
|
+
|
293
295
|
mapped = default_app ? {'/' => default_app} : {}
|
294
296
|
mapping.each { |r,b| mapped[r] = self.class.new(default_app, &b).to_app }
|
295
297
|
URLMap.new(mapped)
|
@@ -0,0 +1,90 @@
|
|
1
|
+
module Puma::Rack
|
2
|
+
# Rack::URLMap takes a hash mapping urls or paths to apps, and
|
3
|
+
# dispatches accordingly. Support for HTTP/1.1 host names exists if
|
4
|
+
# the URLs start with <tt>http://</tt> or <tt>https://</tt>.
|
5
|
+
#
|
6
|
+
# URLMap modifies the SCRIPT_NAME and PATH_INFO such that the part
|
7
|
+
# relevant for dispatch is in the SCRIPT_NAME, and the rest in the
|
8
|
+
# PATH_INFO. This should be taken care of when you need to
|
9
|
+
# reconstruct the URL in order to create links.
|
10
|
+
#
|
11
|
+
# URLMap dispatches in such a way that the longest paths are tried
|
12
|
+
# first, since they are most specific.
|
13
|
+
|
14
|
+
class URLMap
|
15
|
+
NEGATIVE_INFINITY = -1.0 / 0.0
|
16
|
+
INFINITY = 1.0 / 0.0
|
17
|
+
|
18
|
+
def initialize(map = {})
|
19
|
+
remap(map)
|
20
|
+
end
|
21
|
+
|
22
|
+
def remap(map)
|
23
|
+
@mapping = map.map { |location, app|
|
24
|
+
if location =~ %r{\Ahttps?://(.*?)(/.*)}
|
25
|
+
host, location = $1, $2
|
26
|
+
else
|
27
|
+
host = nil
|
28
|
+
end
|
29
|
+
|
30
|
+
unless location[0] == ?/
|
31
|
+
raise ArgumentError, "paths need to start with /"
|
32
|
+
end
|
33
|
+
|
34
|
+
location = location.chomp('/')
|
35
|
+
match = Regexp.new("^#{Regexp.quote(location).gsub('/', '/+')}(.*)", nil, 'n')
|
36
|
+
|
37
|
+
[host, location, match, app]
|
38
|
+
}.sort_by do |(host, location, _, _)|
|
39
|
+
[host ? -host.size : INFINITY, -location.size]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def call(env)
|
44
|
+
path = env['PATH_INFO']
|
45
|
+
script_name = env['SCRIPT_NAME']
|
46
|
+
hHost = env['HTTP_HOST']
|
47
|
+
sName = env['SERVER_NAME']
|
48
|
+
sPort = env['SERVER_PORT']
|
49
|
+
|
50
|
+
@mapping.each do |host, location, match, app|
|
51
|
+
unless casecmp?(hHost, host) \
|
52
|
+
|| casecmp?(sName, host) \
|
53
|
+
|| (!host && (casecmp?(hHost, sName) ||
|
54
|
+
casecmp?(hHost, sName+':'+sPort)))
|
55
|
+
next
|
56
|
+
end
|
57
|
+
|
58
|
+
next unless m = match.match(path.to_s)
|
59
|
+
|
60
|
+
rest = m[1]
|
61
|
+
next unless !rest || rest.empty? || rest[0] == ?/
|
62
|
+
|
63
|
+
env['SCRIPT_NAME'] = (script_name + location)
|
64
|
+
env['PATH_INFO'] = rest
|
65
|
+
|
66
|
+
return app.call(env)
|
67
|
+
end
|
68
|
+
|
69
|
+
[404, {'Content-Type' => "text/plain", "X-Cascade" => "pass"}, ["Not Found: #{path}"]]
|
70
|
+
|
71
|
+
ensure
|
72
|
+
env['PATH_INFO'] = path
|
73
|
+
env['SCRIPT_NAME'] = script_name
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
def casecmp?(v1, v2)
|
78
|
+
# if both nil, or they're the same string
|
79
|
+
return true if v1 == v2
|
80
|
+
|
81
|
+
# if either are nil... (but they're not the same)
|
82
|
+
return false if v1.nil?
|
83
|
+
return false if v2.nil?
|
84
|
+
|
85
|
+
# otherwise check they're not case-insensitive the same
|
86
|
+
v1.casecmp(v2).zero?
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puma
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.12.
|
4
|
+
version: 2.12.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evan Phoenix
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdoc
|
@@ -150,6 +150,7 @@ files:
|
|
150
150
|
- lib/puma/rack/backports/uri/common_192.rb
|
151
151
|
- lib/puma/rack/backports/uri/common_193.rb
|
152
152
|
- lib/puma/rack/builder.rb
|
153
|
+
- lib/puma/rack/urlmap.rb
|
153
154
|
- lib/puma/rack_default.rb
|
154
155
|
- lib/puma/reactor.rb
|
155
156
|
- lib/puma/runner.rb
|