Skip to content

Commit

Permalink
don't cache request object in env, fixes sinatra#239
Browse files Browse the repository at this point in the history
Conflicts:

	CHANGES
  • Loading branch information
rkh committed Apr 17, 2011
1 parent b50c707 commit 4cdef85
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
7 changes: 7 additions & 0 deletions 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,
Expand Down
4 changes: 0 additions & 4 deletions lib/sinatra/base.rb
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions test/routing_test.rb
Expand Up @@ -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.