Persistent connections rebased after https_proxy refactoring

This squishes @clintongormley's work from #30 and rebases it after the https proxy refactoring.  I'm essentially considering this the 'devel' branch for the moment.

It still needs testing and probably more documentation and I want to do a deeper review of the semantics, but on my first skim I think it looks sane.

The suggested change in the #30 comments about doing one write instead of two is also worth considering.