I'd like to write a program that modifies all outgoing (request) HTTP requests to change one of the outgoing headers on-the-fly on my Mac OS X Lion system. Is there any system APIs that would allow me to rewrite port 80 traffic like this?
For reference, I just need to replace a header in-place without actually changing the header length. I have also already tried using a standard HTTP proxy, however it is not easy to set up and only filters traffic on programs that I have configured the proxy on, and respect that setting. I would also like to know if it is easy to turn on and off, as I only need it at a certain network location and not at home.
P.S. I did find information on doing this in linux at Modify http headers on system level (Linux), however I'm pretty sure that Mac OS X lion doesn't support iptables, and although it does support ipfw, it is deprecated in favour of PF.