How many CRLFs between header and body?
Brendan Taylor
whateley at gmail.com
Thu Nov 22 18:05:22 EST 2007
I guess I should have waited a bit longer to send that email, I think
I've tracked it down.
When one of the values in @headers contains an empty list we get a
superfluous CRLF, ie:
>> Z = "\r\n"
>> headers = {"Content-Type"=>"text/plain;charset=utf-8", "Set-Cookie"=>[]}
>> headers.map{|k,v|[*v].map{|x|[k,v]*": "}}*Z+Z # the relevant part of Base#to_s
=> "Content-Type: text/plain;charset=utf-8\r\n\r\n"
...
>> headers["Set-Cookie"] = "something"
>> headers.map{|k,v|[*v].map{|x|[k,v]*": "}}*Z+Z
=> "Content-Type: text/plain;charset=utf-8\r\nSet-Cookie: something\r\n"
If no cookies have been set, @headers["Set-Cookie"] = [] and you get the
correct number of CRLFs; otherwise, you're short one. I'll leave it to
the golfing pros to figure out the best fix for that.
Unfortunately this brings another, unrelated problem to my attention;
apparently I'm getting "0x1df\r\n" inserted between my headers and my
body. Only on FastCGI, and only with Camping. Maybe it's time to move
from FastCGI :(.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/camping-list/attachments/20071122/b59527f5/attachment.bin
More information about the Camping-list
mailing list