mirror of https://github.com/rails/rails
Fix NoMethodError when request Content-Type is blank.
This commit is contained in:
parent
a167350aca
commit
a4633725d2
|
@ -163,7 +163,7 @@ module Mime
|
|||
|
||||
def lookup(string)
|
||||
# fallback to the media-type without parameters if it was not found
|
||||
LOOKUP[string] || LOOKUP[string.split(";", 2)[0].rstrip] || Type.new(string)
|
||||
LOOKUP[string] || LOOKUP[string.split(";", 2)[0]&.rstrip] || Type.new(string)
|
||||
end
|
||||
|
||||
def lookup_by_extension(extension)
|
||||
|
|
|
@ -607,6 +607,13 @@ class TestCaseTest < ActionController::TestCase
|
|||
assert_equal "application/json", parsed_env["CONTENT_TYPE"]
|
||||
end
|
||||
|
||||
test "blank Content-Type header" do
|
||||
@request.headers["Content-Type"] = ""
|
||||
assert_raises(ActionDispatch::Http::MimeNegotiation::InvalidType) do
|
||||
get :test_headers
|
||||
end
|
||||
end
|
||||
|
||||
def test_using_as_json_sets_request_content_type_to_json
|
||||
post :render_body, params: { bool_value: true, str_value: "string", num_value: 2 }, as: :json
|
||||
|
||||
|
|
Loading…
Reference in New Issue