From 8c1e077fc0cd14f789fe8d043e739da8652e50d9 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sun, 23 Nov 2014 13:55:18 +0200 Subject: [PATCH] uaiohttpclient: Use "Connection: close" as workaround for broken HTTP 1.0 servers. --- uaiohttpclient/uaiohttpclient.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/uaiohttpclient/uaiohttpclient.py b/uaiohttpclient/uaiohttpclient.py index e502e07b..2ad3fc53 100644 --- a/uaiohttpclient/uaiohttpclient.py +++ b/uaiohttpclient/uaiohttpclient.py @@ -20,7 +20,10 @@ def request_raw(method, url): proto, dummy, host = url.split("/", 2) path = "" reader, writer = yield from asyncio.open_connection(host, 80) - query = "%s /%s HTTP/1.0\r\nHost: %s\r\n\r\n" % (method, path, host) + # Use protocol 1.0, because 1.1 always allows to use chunked transfer-encoding + # But explicitly set Connection: close, even though this should be default for 1.0, + # because some servers misbehave w/o it. + query = "%s /%s HTTP/1.0\r\nHost: %s\r\nConnection: close\r\n\r\n" % (method, path, host) yield from writer.awrite(query.encode('latin-1')) # yield from writer.close() return reader