Skip to content

Commit

Permalink
Do not set Content-Type for DELETE requests
Browse files Browse the repository at this point in the history
Neither GET nor DELETE support the Content-Type header, so setting it to
application/x-www-form-urlencoded messes with some web frameworks
(including my own) in the test suite. This patch makes sure that
Content-Type is not automatically set for DELETE requests.

Signed-off-by: David Celis <me@davidcel.is>
  • Loading branch information
davidcelis committed Jul 27, 2015
1 parent 0cd8537 commit a319239
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rack/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def env_for(path, env)
# Stringifying and upcasing methods has be commit upstream
env["REQUEST_METHOD"] ||= env[:method] ? env[:method].to_s.upcase : "GET"

if env["REQUEST_METHOD"] == "GET"
if ["GET", "DELETE"].include?(env["REQUEST_METHOD"])
# merge :params with the query string
if params = env[:params]
params = parse_nested_query(params) if params.is_a?(String)
Expand Down
6 changes: 6 additions & 0 deletions spec/rack/test_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,12 @@ def verb
describe "#delete" do
it_should_behave_like "any #verb methods"

it "does not set a content type" do
delete "/"

last_request.env['HTTP_CONTENT_TYPE'].should be_nil
end

def verb
"delete"
end
Expand Down

0 comments on commit a319239

Please sign in to comment.