class AcceptHeaders::Encoding::Negotiator
Constants
- ENCODING_PATTERN
- HEADER_PREFIX
Public Instance Methods
negotiate(supported)
click to toggle source
Calls superclass method
AcceptHeaders::Negotiatable#negotiate
# File lib/accept_headers/encoding/negotiator.rb, line 12 def negotiate(supported) support, match = super(supported) return nil if support.nil? && match.nil? begin return parse(support).first rescue Encoding::Error return nil end end
Private Instance Methods
no_header()
click to toggle source
# File lib/accept_headers/encoding/negotiator.rb, line 23 def no_header [Encoding.new] end
parse_item(header)
click to toggle source
# File lib/accept_headers/encoding/negotiator.rb, line 27 def parse_item(header) return nil if header.nil? header.strip! encoding_string, q_string = header.split(';', 2) raise Error if encoding_string.nil? encoding = ENCODING_PATTERN.match(encoding_string) raise Error if encoding.nil? Encoding.new(encoding[:encoding], q: parse_q(q_string)) end