uaiohttpclient: Use "Connection: close" as workaround for broken HTTP 1.0 servers.

pull/226/merge
Paul Sokolovsky 2014-11-23 13:55:18 +02:00
rodzic 51cd47ae2f
commit 8c1e077fc0
1 zmienionych plików z 4 dodań i 1 usunięć

Wyświetl plik

@ -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