Helper class which decodes the HTTP “content-type” header.
Constants
| SPLIT_PATTERN | = | /[;,]/.freeze |
Public Class methods
new(header_value)
[show source]
# File lib/httpx/response.rb 219 def initialize(header_value) 220 @header_value = header_value 221 @mime_type = @charset = nil 222 @initialized = false 223 end
Public Instance methods
charset()
returns the charset declared in the header.
ContentType.new("application/json; charset=utf-8").charset #=> "utf-8" ContentType.new("text/plain").charset #=> nil
[show source]
# File lib/httpx/response.rb 240 def charset 241 return @charset if @initialized 242 243 load 244 245 @charset 246 end
mime_type()
returns the mime type declared in the header.
ContentType.new("application/json; charset=utf-8").mime_type #=> "application/json"
[show source]
# File lib/httpx/response.rb 228 def mime_type 229 return @mime_type if @initialized 230 231 load 232 233 @mime_type 234 end