Fix open socket leak

Good news:
This commit appears to fix the resource leak that breaks long-running
apps.

Bad news:
We have to be extra careful to make sure all http requests are cleaned
up properly, or apps will silently stop working (not crash)
Merge pull request #3 from hudl/TooManyOpenSockets

Fix open socket leak