From f9e14b02c460a1963b350fb5e0e10c0e71ee175c Mon Sep 17 00:00:00 2001 From: Eugene Kenny Date: Tue, 1 May 2018 01:24:32 +0100 Subject: Reset CONTENT_LENGTH between test requests If a POST request is followed by a GET request in a controller test, the `rack.input` and `RAW_POST_DATA` headers from the first request will be reset but the `CONTENT_LENGTH` header will leak, leading the request object in the second request to incorrectly believe it has a body. --- actionpack/lib/action_controller/test_case.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index 8f2a7e2b5f..5d784ceb31 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -604,6 +604,7 @@ module ActionController env.delete "action_dispatch.request.query_parameters" env.delete "action_dispatch.request.request_parameters" env["rack.input"] = StringIO.new + env.delete "CONTENT_LENGTH" env.delete "RAW_POST_DATA" env end -- cgit v1.2.3