Project

General

Profile

Feature #16773 » patch3.diff

timcraft (Tim Craft), 04/10/2020 11:35 AM

View differences:

lib/net/http/header.rb
# 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
(3-3/3)