It's quite possible that the server is responding with chunked data. Try changing HTTP/1.1 to HTTP/1.0 and see if that resolves your problem.