So I finally figured out what was wrong with my proxy code.
The World Wide Web is held together by duct tape and bailing wire! I hadn’t realized that HTTP/1.1 requests aren’t uniform across the Internet–or even on the same damned server. A request can ask for a /1.1 request and get a /1.0 response–and I wasn’t handling /1.0 responses well. Further, some servers go so far as to just close the damned connection rather than return a 404 error. (*sigh*) So after working through all of the niggly issues (thanks to Safari, which provides helpful diagnostic tools to allow me to find the things failing to load) and a ton of debugging statements, and I’ve finally arrived at a proxy server that appears to work.
(In fact, I posted this message through my proxy engine.)
The proxy isn’t the most efficient thing in the world: for example, my connection caching code is serializing requests that are being made in parallel to the same web server. (Thus, even though Safari happily opens up five separate threads to process requests faster, I catch them and funnel them through one connection.) So the net effect is a connection which is pretty slow.
And of course I’m not caching or doing any of the nice things proxy servers are supposed to do.
But it appears to work!
I’ll clean it up and post it later this weekend.
Update, two seconds later: I went to hit ‘publish’, and nothing. WTF? Okay, back to the drawing board. Apparently I’m mangling the POST message being made when I tried to submit this post.