Class: HTTPX::ContentType
- Inherits:
-
Object
- Object
- HTTPX::ContentType
- Defined in:
- lib/httpx/response.rb,
sig/response.rbs
Overview
Helper class which decodes the HTTP "content-type" header.
Constant Summary collapse
- SPLIT_PATTERN =
/[;,]/.freeze
Instance Method Summary collapse
-
#charset ⇒ String?
returns the charset declared in the header.
-
#mime_type ⇒ String?
returns the mime type declared in the header.
Instance Method Details
#charset ⇒ String?
returns the charset declared in the header.
ContentType.new("application/json; charset=utf-8").charset #=> "utf-8"
ContentType.new("text/plain").charset #=> nil
240 241 242 243 244 245 246 |
# File 'lib/httpx/response.rb', line 240 def charset return @charset if @initialized load @charset end |
#mime_type ⇒ String?
returns the mime type declared in the header.
ContentType.new("application/json; charset=utf-8").mime_type #=> "application/json"
228 229 230 231 232 233 234 |
# File 'lib/httpx/response.rb', line 228 def mime_type return @mime_type if @initialized load @mime_type end |