diff --git a/lib/net/http/header.rb b/lib/net/http/header.rb index 1f795d7d9d..b20894d66a 100644 --- a/lib/net/http/header.rb +++ b/lib/net/http/header.rb @@ -362,16 +362,18 @@ def content_type # Returns a content type string such as "text". # This method returns nil if Content-Type: header field does not exist. def main_type - return nil unless @header['content-type'] - self['Content-Type'].split(';').first.to_s.split('/')[0].to_s.strip + values = @header['content-type'] + return nil unless values + values.first.split(';').first.to_s.split('/')[0].to_s.strip end # Returns a content type string such as "html". # This method returns nil if Content-Type: header field does not exist # or sub-type is not given (e.g. "Content-Type: text"). def sub_type - return nil unless @header['content-type'] - _, sub = *self['Content-Type'].split(';').first.to_s.split('/') + values = @header['content-type'] + return nil unless values + _, sub = *values.first.split(';').first.to_s.split('/') return nil unless sub sub.strip end