我也一样:
$ ./test-debug.py
Starting GET request for http://stackoverflow.com. I will send: <CIMultiDict()>
Ending GET request for https://stackoverflow.com/. I sent: <CIMultiDict()>
<ClientResponse(https://stackoverflow.com/) [200 OK]>
<CIMultiDictProxy('Cache-Control': 'private', 'Content-Type': 'text/html; charset=utf-8', 'Content-Encoding': 'gzip', 'X-Frame-Options': 'SAMEORIGIN', 'X-Request-Guid': 'c89dd68d-cb88-43c1-b08d-f2a07bf81043', 'Strict-Transport-Security': 'max-age=15552000', 'Content-Security-Policy': 'upgrade-insecure-requests', 'Content-Length': '52698', 'Accept-Ranges': 'bytes', 'Date': 'Tue, 15 Jan 2019 08:06:32 GMT', 'Via': '1.1 varnish', 'Connection': 'keep-alive', 'X-Served-By': 'cache-cdg20748-CDG', 'X-Cache': 'MISS', 'X-Cache-Hits': '0', 'X-Timer': 'S1547539592.382231,VS0,VE120', 'Vary': 'Accept-Encoding,Fastly-SSL', 'X-DNS-Prefetch-Control': 'off')>
$ python --version
Python 3.7.1
$ python -c "import aiohttp; print(aiohttp.__version__)"
3.4.4
如果我明确地向clientsession添加一个头部,
async with aiohttp.ClientSession(trace_configs=[trace_config], headers={"Host": "stackoverflow.com"}) as session:
我从痕迹中看到:
$ ./test-debug.py
Starting GET request for http://stackoverflow.com. I will send: <CIMultiDict('Host': 'stackoverflow.com')>
Ending GET request for http://stackoverflow.com. I sent: <CIMultiDict('Host': 'stackoverflow.com')>