class Rack::AcceptHeaders::Encoding
Represents an HTTP Accept-Encoding header according to the HTTP 1.1 specification, and provides several convenience methods for determining acceptable content encodings.
Public Instance Methods
matches(encoding)
click to toggle source
Returns an array of encodings from this header that match the given encoding
, ordered by precedence.
# File lib/rack/accept_headers/encoding.rb, line 27 def matches(encoding) values.select {|v| v == encoding || v == '*' }.sort {|a, b| # "*" gets least precedence, any others should be equal. a == '*' ? 1 : (b == '*' ? -1 : 0) } end
name()
click to toggle source
The name of this header.
# File lib/rack/accept_headers/encoding.rb, line 11 def name 'Accept-Encoding' end
qvalue(encoding)
click to toggle source
Determines the quality factor (qvalue) of the given encoding
.
# File lib/rack/accept_headers/encoding.rb, line 16 def qvalue(encoding) m = matches(encoding) if m.empty? encoding == 'identity' ? 1 : 0 else normalize_qvalue(@qvalues[m.first]) end end