diff --git a/lib/rack/request.rb b/lib/rack/request.rb index 5778bf296..db81909fb 100644 --- a/lib/rack/request.rb +++ b/lib/rack/request.rb @@ -197,7 +197,6 @@ def POST elsif @env["rack.request.form_input"].eql? @env["rack.input"] @env["rack.request.form_hash"] elsif form_data? || parseable_data? - @env["rack.request.form_input"] = @env["rack.input"] unless @env["rack.request.form_hash"] = parse_multipart(env) form_vars = @env["rack.input"].read @@ -210,6 +209,7 @@ def POST @env["rack.input"].rewind end + @env["rack.request.form_input"] = @env["rack.input"] @env["rack.request.form_hash"] else {} diff --git a/test/spec_request.rb b/test/spec_request.rb index f94579557..b7ac42f74 100644 --- a/test/spec_request.rb +++ b/test/spec_request.rb @@ -776,6 +776,20 @@ lambda{ req.POST }.should.not.raise("input re-processed!") end + should "consistently raise EOFError on bad multipart form data" do + input = < "multipart/form-data, boundary=AaB03x", + "CONTENT_LENGTH" => input.size, + :input => input) + + lambda { req.POST }.should.raise(EOFError) + lambda { req.POST }.should.raise(EOFError) + end + should "conform to the Rack spec" do app = lambda { |env| content = Rack::Request.new(env).POST["file"].inspect