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.
上级 a9d72f6e
......@@ -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!"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册