You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In case response contains blank Content-Encoding header call to await resp.text() will cause an error:
aiohttp.client_exceptions.ClientPayloadError: 400, message='Can not decode content-encoding: '
To reproduce you may use this two scripts - server:
from aiohttp import web
from multidict import MultiDict
async def index(request):
return web.Response(
text='Hello Aiohttp!',
headers=MultiDict({'CONTENT-ENCODING': ''}))
app = web.Application()
app.router.add_get('/', index)
web.run_app(app, host='127.0.0.1', port=8080)
and client:
import asyncio
import aiohttp
async def fetch_page():
async with aiohttp.ClientSession() as session:
async with session.get('http://127.0.0.1:8080/') as resp:
for key, value in resp.headers.items():
print("%s:" % key, value)
print(resp.status)
# Failed on this call
print(await resp.text())
loop = asyncio.get_event_loop()
loop.run_until_complete(fetch_page())
I don't know exactly why such thing happen, but I'd like to note that on versions of aiohttp prior 2.0 there is no such behavior. Other clients - wget/flask work without any errors.
And also seems that issue #1918 can have the same origin, but there Content-Encoding was provided as deflate.
In case response contains blank
Content-Encoding
header call toawait resp.text()
will cause an error:To reproduce you may use this two scripts - server:
and client:
I don't know exactly why such thing happen, but I'd like to note that on versions of aiohttp prior 2.0 there is no such behavior. Other clients - wget/flask work without any errors.
And also seems that issue #1918 can have the same origin, but there
Content-Encoding
was provided asdeflate
.Env:
Python 3.6.1
aiohttp==2.1.0
async-timeout==1.2.1
chardet==3.0.3
multidict==2.1.6
yarl==0.10.2
The text was updated successfully, but these errors were encountered: