Add timeouts on connect and read and ensure that the input stream is closed.

This is in order to prevent hung open TCP connections that I have observed in production.
Change tabs to spaces
Merge pull request #6 from karlvr/too-many-open-files

Close HttpURLConnections