    # File lib/rack/utils.rb, line 246
        def select_best_encoding(available_encodings, accept_encoding)
          # http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

          expanded_accept_encoding =
            accept_encoding.map { |m, q|
              if m == "*"
                (available_encodings - accept_encoding.map { |m2, _| m2 }).map { |m2| [m2, q] }
              else
                [[m, q]]
              end
            }.inject([]) { |mem, list|
              mem + list
            }

          encoding_candidates = expanded_accept_encoding.sort_by { |_, q| -q }.map { |m, _| m }

          unless encoding_candidates.include?("identity")
            encoding_candidates.push("identity")
          end

          expanded_accept_encoding.each { |m, q|
            encoding_candidates.delete(m) if q == 0.0
          }

          return (encoding_candidates & available_encodings)[0]
        end