Bug in unicorn_rails when Encoding.default_internal is set

Eric Wong normalperson at yhbt.net
Fri Feb 17 03:59:20 UTC 2012

Lucas Parry <lucas at envato.com> wrote:
> On Fri, Feb 17, 2012 at 1:29 PM, Lucas Parry <lucas at envato.com> wrote:
> > We recently made the switch to 1.9 for our large rails 2.3.14 project

(odd, neither I nor gmane got your original message:
 Perhaps Mailman misdelivers UTF-8...

> I guess I should be more precise; This problem is occurring on MRI1.9.2-p290

Setting Encoding.default_* is probably a bad idea in your app.
If you run Ruby with warnings (-w switch), you'll see setting
Encoding.default_* will generate warnings to discourage their use.

If you want UTF-8, set LANG=en_US.UTF-8 in the environment _before_
starting Ruby, which will only set Encoding.default_external.

I've always just left Encoding.default_internal alone.  I'll let others
on the list with more Rails/encoding experience help you with that.

> All subsequent requests to that worker will fail with the same
> exception.

Seems to be Rails bug.  Rails 3.2.1 seems to handle the situation
without difficulty.

Fwiw, neither Rack nor HTTP specify an encoding for HTTP headers/paths.
The only place where encoding is specified for Rack is "rack.input",
which must be binary.  There was talk on the Rack mailing list a long
while back about enforcing encodings for certain headers, but nothing
came of it.

More information about the mongrel-unicorn mailing list