Followup to #195 - Set-Cookie header is spit out above response body using Mongrel

I've been testing out 2.3.1, and I've noticed this weird bug I'm kind
of stumped about. Of course I've been using script/server locally, but
I've noticed that a Set-Cookie header keeps appearing at the very top
of the response body, above the HTML and everything. It seems to
happen whenever there are multiple cookies being set -- I ran a
request through Live HTTP Headers and it looks like a Set-Cookie
header is properly sent for the first cookie but if there are any
other cookies, they come through above the response body as I

I know someone's encountered this before, because I found #195 in
Lighthouse[1], but the fix that Josh made [2] doesn't seem to have
helped here -- I think because he fixed the deprecated FCGI handler,
but not necessarily Mongrel or anything like that. I can confirm that
when using Thin instead of Mongrel, the rogue headers no longer show
up in the response body.

The thing is, I haven't seen talk about this problem other than in
Lighthouse. So what I'm wondering now is if this is a problem with
Mongrel, or with Rack's Mongrel handler, or with Rails...? Anybody got
any ideas?

-- Elliot


Forgot to mention: I have Mongrel 1.1.5 and Rack 0.9.1 installed on my

Okay, this is interesting. I just went into Rack::Handler::Mongrel and
asked #process to tell me what the "headers" and "body" variables
were. headers["Set-Cookie"] is one string consisting of three cookies,
separated by \n's. The "body" variable appears normal - nothing at the
front of it. Even so, when the response ends up in the browser, there
are headers prepended (same as before), and they're the last two
cookies in the headers hash. So I'm not sure what this means.

-- Elliot

I believe I fixed this issue already:

Can you please test on RC2, or better edge.

Alright, my bad then, in 2.3 final this issue goes away. Whatever :wink:

-- Elliot