bumptech/stud — pull request #121 by insom (2012-09-01 16:45:29+00:00)
Title: X-Forwarded-For header support

At the moment $WORK uses Nginx as an SSL proxy in front of Varnish, just because it will give us an X-Forwarded-For header where stunnel and stud won't.

I've hacked in support for XFF as delicately as I could - by waiting for the first newline on a connection, and when it sees it, inserting a line in the middle of the ringbuffer. This means having to copy the buffer, clear it and then write to it. This is all gated by config flags following the existing conventions, and documented in the man page.

This will only send an X-Forwarded-For header for the first request; we disable HTTP keep-alives so is not an issue for my use-case, I don't know if it would be for others. (mod_rpaf on Apache, for example, only reads the XFF header once anyway).