Fixed issue with HTTP responses ending prematurely

Changed the way HTTP responses are read. This fixes an issue where in
some occassions a response was not read fully before the stream was
terminated.