Permalink
Browse files

don't cache request object in env, fixes #239

Conflicts:

	CHANGES
  • Loading branch information...
1 parent b50c707 commit 4cdef85cd4e72e66ff91b98c328663df9fe3b5f6 @rkh rkh committed Apr 17, 2011
Showing with 22 additions and 4 deletions.
  1. +7 −0 CHANGES
  2. +0 −4 lib/sinatra/base.rb
  3. +15 −0 test/routing_test.rb
View
7 CHANGES
@@ -1,3 +1,10 @@
+= 1.2.4 / Not Yet Released
+
+ * The request object was shared between multiple Sinatra instances in the
+ same middleware chain. This caused issues if any non-sinatra routing
+ happend in-between two of those instances. The caching was reverted. See
+ GH#239 for more infos. (Konstantin Haase)
+
= 1.2.3 / 2011-04-13
* This release is compatible with Tilt 1.3, it will still work with Tilt 1.2.2,
View
4 lib/sinatra/base.rb
@@ -12,10 +12,6 @@ module Sinatra
# The request object. See Rack::Request for more info:
# http://rack.rubyforge.org/doc/classes/Rack/Request.html
class Request < Rack::Request
- def self.new(env)
- env['sinatra.request'] ||= super
- end
-
# Returns an array of acceptable media types for the response
def accept
@env['sinatra.accept'] ||= begin
View
15 test/routing_test.rb
@@ -1042,4 +1042,19 @@ def authorize(username, password)
get '/foo'
assert not_found?
end
+
+
+ it 'is plays well with other routing middleware' do
+ middleware = Sinatra.new
+ inner_app = Sinatra.new { get('/foo') { 'hello' } }
+ builder = Rack::Builder.new do
+ use middleware
+ map('/test') { run inner_app }
+ end
+
+ @app = builder.to_app
+ get '/test/foo'
+ assert ok?
+ assert_body 'hello'
+ end
end

0 comments on commit 4cdef85

Please sign in to comment.