Validate the Content-Type on PUT requests

Return a 415
(https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/415) when the
Content-Type does not look like a valid MIME type (in the type/subtype
format)

Refs #137
This commit is contained in:
Greg Karékinian
2020-04-15 13:45:34 +02:00
parent ab673f1d43
commit 71d138894e
3 changed files with 17 additions and 0 deletions

View File

@@ -232,6 +232,16 @@ shared_examples_for 'a REST adapter' do
_(last_response.body).must_equal "Precondition Failed"
end
end
describe "Content-Type" do
it "must be in the type/subtype format" do
header "Content-Type", "text"
put "/phil/food/invalid_content_type", "invalid"
_(last_response.status).must_equal 415
end
end
end
end