Improved timeout handling for http connections

Change-Id: I5b91dd10d534f9413e9c5a78a9a9da3c5832808a