mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Change Request#media_type to return nil
When the request don't have a Content-Type header we were returning an empty string instead of nil like Rack does.
This commit is contained in:
parent
13a96dd76e
commit
a2efdf5577
3 changed files with 5 additions and 3 deletions
|
@ -1,4 +1,6 @@
|
|||
## Unreleased
|
||||
* Change `ActionDispatch::Request#media_type` to return `nil` when the request don't have a `Content-Type` header.
|
||||
|
||||
*Rafael Mendonça França*
|
||||
|
||||
* Fix error in `ActionController::LogSubscriber` that would happen when throwing inside a controller action.
|
||||
|
||||
|
|
|
@ -266,7 +266,7 @@ module ActionDispatch
|
|||
# # get "/articles"
|
||||
# request.media_type # => "application/x-www-form-urlencoded"
|
||||
def media_type
|
||||
content_mime_type.to_s
|
||||
content_mime_type&.to_s
|
||||
end
|
||||
|
||||
# Returns the content length of the request as an integer.
|
||||
|
|
|
@ -1301,7 +1301,7 @@ class RequestFormData < BaseRequestTest
|
|||
test "no Content-Type header is provided and the request_method is POST" do
|
||||
request = stub_request("REQUEST_METHOD" => "POST")
|
||||
|
||||
assert_equal "", request.media_type
|
||||
assert_nil request.media_type
|
||||
assert_equal "POST", request.request_method
|
||||
assert_not_predicate request, :form_data?
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue