rack/rack — pull request #443 by jamesarosen (2012-10-18 22:17:06+00:00)
Title: Add Rack::Utils.q_value

### What

This pull request adds `Rack::Utils.q_value`, which accepts a q-value-style header and returns an ordered Array of `[value, quality]` pairs.

### Rationale

The q-value-style header is common in HTTP requests, so many types of Rack middleware will be interested in parsing it. Additionally, it's easy to get wrong, as [rack-contrib/locale.rb](https://github.com/rack/rack-contrib/blob/master/lib/rack/contrib/locale.rb#L14-22) does. Having one central method will help many middleware authors do the right thing.

### Caveat

This pull request also changes `Rack::Request#accept_encoding` to use this new method. Doing so changes its behavior in that it sorts the entries by quality, descending. This doesn't change the *meaning* of `#accept_encoding` (since anyone who was using it should have been sorting on quality themselves), but it is possible that it would break clients. If there is concern that this is a breaking change, I will gladly revert this second commit.