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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0c8b1f4fce0fcee4ebd03eaaf4d93ad9376c4183
4
- data.tar.gz: bc8ce26bf9b9536d0cba6e7537ce3fce707b6d57
3
+ metadata.gz: acc6978f0afad6cb3d2f28d834f2c60c08f6f6a9
4
+ data.tar.gz: 24c4f715b9b474a438567ce91314ce24e17f1acb
5
5
  SHA512:
6
- metadata.gz: 69fabcd7985017bd09cf783d576e38e02d565e0d02dce427d25c84d5477e3ea557de0a67dc66fd237f0ebff8f3e77990938fc8ba04bace87df497fbd1848489a
7
- data.tar.gz: 66335f209d5d66ef6d29336b04b84c23d13409f3ff514005fa9704a02452a1875207cd3f1d0412155e8afb9f98ac2658f823ce73dda7f3bdf1e9c2ac8e2c1519
6
+ metadata.gz: 115b5753fb3487f7a6e3ae3e0009c75bea89d2cbe9b1b67bf1de52e6795f7788123034a54627b38be5585061ce34db46ba7108f8cff03abef478fc6081cf3854
7
+ data.tar.gz: 9b7198cca050cc284a335184a7ab3ec630ec5bfe081a44e0760abf1b748ae0388c4b0171b609574ba27748445be5ecf16a62b371aa0dfe58e9dbc05454018420
@@ -1,3 +1,9 @@
1
+ === 2.12.2 / 2015-07-17
2
+
3
+ * 2 bug fix:
4
+ * Pull over and use Rack::URLMap. Fixes #741
5
+ * Stub out peercert on JRuby for now. Fixes #739
6
+
1
7
  === 2.12.1 / 2015-07-16
2
8
 
3
9
  * 2 bug fixes:
@@ -53,6 +53,7 @@ lib/puma/rack/backports/uri/common_18.rb
53
53
  lib/puma/rack/backports/uri/common_192.rb
54
54
  lib/puma/rack/backports/uri/common_193.rb
55
55
  lib/puma/rack/builder.rb
56
+ lib/puma/rack/urlmap.rb
56
57
  lib/puma/rack_default.rb
57
58
  lib/puma/reactor.rb
58
59
  lib/puma/runner.rb
@@ -384,4 +384,9 @@ public class MiniSSL extends RubyObject {
384
384
  throw new RuntimeException(e);
385
385
  }
386
386
  }
387
+
388
+ @JRubyMethod
389
+ public IRubyObject peercert() {
390
+ return getRuntime().getNil();
391
+ }
387
392
  }
@@ -99,7 +99,7 @@ module Puma
99
99
  # too taxing on performance.
100
100
  module Const
101
101
 
102
- PUMA_VERSION = VERSION = "2.12.1".freeze
102
+ PUMA_VERSION = VERSION = "2.12.2".freeze
103
103
  CODE_NAME = "Plutonian Photo Shoot".freeze
104
104
 
105
105
  FAST_TRACK_KA_TIMEOUT = 0.2
@@ -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.1
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-16 00:00:00.000000000 Z
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