Class Rack::Accept::Encoding
In: lib/rack/accept/encoding.rb
Parent: Object

Represents an HTTP Accept-Encoding header according to the HTTP 1.1 specification, and provides several convenience methods for determining acceptable content encodings.

www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.3

Methods

matches   name   qvalue  

Included Modules

Header

Public Instance methods

Returns an array of encodings from this header that match the given encoding, ordered by precedence.

[Source]

    # File lib/rack/accept/encoding.rb, line 27
27:     def matches(encoding)
28:       values.select {|v|
29:         v == encoding || v == '*'
30:       }.sort {|a, b|
31:         # "*" gets least precedence, any others should be equal.
32:         a == '*' ? 1 : (b == '*' ? -1 : 0)
33:       }
34:     end

The name of this header.

[Source]

    # File lib/rack/accept/encoding.rb, line 11
11:     def name
12:       'Accept-Encoding'
13:     end

Determines the quality factor (qvalue) of the given encoding.

[Source]

    # File lib/rack/accept/encoding.rb, line 16
16:     def qvalue(encoding)
17:       m = matches(encoding)
18:       if m.empty?
19:         encoding == 'identity' ? 1 : 0
20:       else
21:         normalize_qvalue(@qvalues[m.first])
22:       end
23:     end

[Validate]