Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/net/http/header.rb
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,7 @@ def type_params
list = self['Content-Type'].to_s.split(';')
list.shift
list.each do |param|
next if param.strip.empty?
k, v = *param.split('=', 2)
result[k.strip] = v.strip
end
Expand Down
6 changes: 6 additions & 0 deletions test/net/http/test_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,12 @@ def test_response_body_encoding_true_with_content_type
assert_equal(Encoding::UTF_8, res.body.encoding)
end

def test_response_body_encoding_true_with_trailing_semicolon_in_content_type
res = fe_request(true, 'text/html; charset=utf-8; ')
assert_equal("hello\u1234", res.body)
assert_equal(Encoding::UTF_8, res.body.encoding)
end

def test_response_body_encoding_string_without_content_type
res = fe_request('utf-8')
assert_equal("hello\u1234", res.body)
Expand Down
4 changes: 4 additions & 0 deletions test/net/http/test_httpheader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,10 @@ def test_type_params
assert_equal({'charset' => 'iso-2022-jp'}, @c.type_params)
@c.content_type = 'text'
assert_equal({}, @c.type_params)
@c['content-type'] = 'text/html; charset=utf-8; '
assert_equal({'charset' => 'utf-8'}, @c.type_params)
@c['content-type'] = 'text/html;'
assert_equal({}, @c.type_params)
end

def test_set_content_type
Expand Down
Loading