basho/webmachine — pull request #146 by ewanmellor (2013-05-13 20:37:48+00:00)
Title: Encode the error response before sending it.

Pass the response from ErrorHandler:render_error through encode_body before
sending it. This means that if the client has sent an appropriate
Accept-Encoding or Accept-Charset header then they will get the error
response encoded correctly.

As part of this, we have to handle the situation where a charset or encoding
hasn't yet been chose (or doesn't match one of the available options) even
though the resource specifies some. This happens if the error response is
triggered before the encoding/charset header processing.