Do not raise exception when content_type is a empty string
When content type header is blank we were raising an exception because `empty?` was being called on nil.
This commit is contained in:
parent
a9d72f6e47
commit
4eb3ef812c
@ -408,7 +408,7 @@ def cookies
|
||||
def parse_content_type(content_type)
|
||||
if content_type
|
||||
type, charset = content_type.split(/;\s*charset=/)
|
||||
type = nil if type.empty?
|
||||
type = nil if type && type.empty?
|
||||
ContentTypeHeader.new(type, charset)
|
||||
else
|
||||
NullContentTypeHeader
|
||||
|
@ -110,6 +110,11 @@ def test_setting_content_type_header_impacts_content_type_method
|
||||
assert_equal "application/aaron", @response.content_type
|
||||
end
|
||||
|
||||
def test_empty_content_type_returns_nil
|
||||
@response.headers['Content-Type'] = ""
|
||||
assert_equal nil, @response.content_type
|
||||
end
|
||||
|
||||
test "simple output" do
|
||||
@response.body = "Hello, World!"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user