Permalink
Browse files

Kill request instance memoization

  • Loading branch information...
1 parent 815342a commit 0bf8d8e840ae226d6efed8af345feb67a10f6aa6 @josh josh committed May 11, 2009
Showing with 1 addition and 25 deletions.
  1. +0 −8 lib/rack/request.rb
  2. +1 −1 test/spec_rack_mock.rb
  3. +0 −16 test/spec_rack_request.rb
View
@@ -17,14 +17,6 @@ class Request
# The environment of the request.
attr_reader :env
- def self.new(env, *args)
- if self == Rack::Request
- env["rack.request"] ||= super
- else
- super
- end
- end
-
def initialize(env)
@env = env
end
View
@@ -216,7 +216,7 @@
res.original_headers["Content-Type"].should.equal "text/yaml"
res["Content-Type"].should.equal "text/yaml"
res.content_type.should.equal "text/yaml"
- res.content_length.should.be 477 # needs change often.
+ res.content_length.should.be 414 # needs change often.
res.location.should.be.nil
end
View
@@ -467,22 +467,6 @@
res.body.should.equal '212.212.212.212'
end
- specify "memoizes itself to reduce the cost of repetitive initialization" do
- env = Rack::MockRequest.env_for("http://example.com:8080/")
- env['rack.request'].should.be.nil
-
- req1 = Rack::Request.new(env)
- env['rack.request'].should.not.be.nil
- req1.should.equal env['rack.request']
-
- rack_request_object_id = env['rack.request'].object_id
-
- req2 = Rack::Request.new(env)
- env['rack.request'].should.not.be.nil
- rack_request_object_id.should.be.equal env['rack.request'].object_id
- req2.should.equal env['rack.request']
- end
-
class MyRequest < Rack::Request
def params
{:foo => "bar"}

1 comment on commit 0bf8d8e

Contributor

rtomayko commented on 0bf8d8e May 11, 2009

:)

Please sign in to comment.