I wouldn’t use HttpListener or something like that, in that way you’ll come across so many issues.
Most importantly it’ll be a huge pain to support:
- Proxy Keep-Alives
- SSL won’t work (in a correct way, you’ll get popups)
- .NET libraries strictly follows RFCs which causes some requests to fail (even though IE, FF and any other browser in the world will work.)
What you need to do is:
- Listen a TCP port
- Parse the browser request
- Extract Host connect to that host in TCP level
- Forward everything back and forth unless you want to add custom headers etc.
I wrote 2 different HTTP proxies in .NET with different requirements and I can tell you that this is the best way to do it.
Mentalis doing this, but their code is “delegate spaghetti”, worse than GoTo 🙂