aiohttp
aiohttp copied to clipboard
aiohttp ClientSession 302 ServerDisconnectedError
Long story short
i'm used aiohttp.clientSession send http request , target:
curl -v http://10.101.158.223:8000
* Rebuilt URL to: http://10.101.158.223:8000/
* Trying 10.101.158.223...
* TCP_NODELAY set
* Connected to 10.101.158.223 (10.101.158.223) port 8000 (#0)
> GET / HTTP/1.1
> Host: 10.101.158.223:8000
> User-Agent: curl/7.55.1
> Accept: */*
>
< HTTP/1.1 302 Found
< Date: Mon, 23 Jul 2018 08:42:53 GMT
< Server: WSGIServer/0.2 CPython/3.4.8
< X-Frame-Options: SAMEORIGIN
< Vary: Cookie
< Content-Length: 0
< Location: /view/
< Content-Type: text/html; charset=utf-8
<
* Connection #0 to host 10.101.158.223 left intact
Expected behaviour
async with aiohttp.ClientSession(loop=loop) as session:
try:
async with session.get(url, ssl=False,allow_redirects=True) as response:
res = response.status
print(res)
except aiohttp.ServerDisconnectedError as e:
print(e)
use allow_redirects=False
, console prints "302", but allow_redirects=True
prints None aiohttp.client_exceptions.ServerDisconnectedError: None
Actual behaviour
why ServerDisconnectedError is None ?
Steps to reproduce
async with aiohttp.ClientSession(loop=loop) as session:
try:
async with session.get(url, ssl=False,allow_redirects=True) as response:
res = response.status
print(res)
except aiohttp.ServerDisconnectedError as e:
print(e)
Your environment
Python 3.7.0 aiohttp 3.3.2 async 0.6.2
Sorry, I cannot help you very much.
Need both client and server to reproduce the problem and figure out what's going wrong in your particular case. As an option, you can analyze/debug the problem yourself.