Hi all.

I recently moved all my Django sites onto Cherokee and it's been pretty
awesome so far. I've just had one problem: Some X-* headers are not
properly transformed.

I found the error when trying to find the HTTP_X_REQUESTED_WITH header.
This is primarily a header for javascript frameworks to use to show that
the current request is an AJAX one. The libraries send a
X-Requested-With header. This confused me at first but after digging
around, I learnt that web servers are supposed to convert all X-Headers
to HTTP_X_UPPERCASE_HEADERS (replacing dashes with underscores too).

There is code that does some of this already (header.c circa line:1019):

case 'X':

    if (header_equals ("X-Forwarded-For", header_x_forwarded_for, begin, 
header_len)) {
        ret = add_known_header (hdr, header_x_forwarded_for, val_offs, val_len);
    } else if (header_equals ("X-Forwarded-Host", header_x_forwarded_host, 
begin, header_len)) {
        ret = add_known_header (hdr, header_x_forwarded_host, val_offs, 
val_len);
    } else
        goto unknown;
    break;


That covers two headers. But if I remember correctly, there are quite a
few more out there.

Would it not make more sense to replace that with a loop that replaces
any X- header with its HTTP_X_ counterpart (automatically generated, or
not)? The only downside I can see of doing that is a slight performance
hit.

Otherwise, would it just be possible to stick another "else if" in there
for X-Requested-With so AJAX is better supported?
_______________________________________________
Cherokee mailing list
[email protected]
http://lists.octality.com/listinfo/cherokee

Reply via email to