kopia lustrzana https://github.com/micropython/micropython-lib
uaiohttpclient: Use "Connection: close" as workaround for broken HTTP 1.0 servers.
rodzic
51cd47ae2f
commit
8c1e077fc0
|
@ -20,7 +20,10 @@ def request_raw(method, url):
|
||||||
proto, dummy, host = url.split("/", 2)
|
proto, dummy, host = url.split("/", 2)
|
||||||
path = ""
|
path = ""
|
||||||
reader, writer = yield from asyncio.open_connection(host, 80)
|
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.awrite(query.encode('latin-1'))
|
||||||
# yield from writer.close()
|
# yield from writer.close()
|
||||||
return reader
|
return reader
|
||||||
|
|
Ładowanie…
Reference in New Issue