Module: URLCanonicalize::MediaType
Overview
Normalizes response media types for safe buffering and parsing decisions
Constant Summary collapse
- HTML =
%w[text/html application/xhtml+xml].freeze
- BUFFERED =
(HTML + %w[application/xml text/xml]).freeze
Instance Method Summary collapse
Instance Method Details
#buffered?(response) ⇒ Boolean
11 12 13 |
# File 'lib/url_canonicalize/media_type.rb', line 11 def buffered?(response) BUFFERED.include?(normalized(response)) end |
#html?(response) ⇒ Boolean
15 16 17 |
# File 'lib/url_canonicalize/media_type.rb', line 15 def html?(response) HTML.include?(normalized(response)) end |
#normalized(response) ⇒ Object
19 20 21 |
# File 'lib/url_canonicalize/media_type.rb', line 19 def normalized(response) response['content-type'].to_s.split(';', 2).first.to_s.strip.downcase end |