-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider removing assert about HTTP Reason-Phrase being always present #3906
Comments
That's interesting. |
I find some website response without reason-phrase. I checked response.reason is None, is empty string OK? (assert "" still fail) import aiohttp
import asyncio
url = 'http://pyconcn.qiniudn.com/images/volunteer/zhouqi.png'
async def main():
async with aiohttp.ClientSession() as client:
async with client.get(url) as resp:
print(resp.status)
resp.raise_for_status()
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
>>>
530
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/kk/.pyenv/versions/3.6.5/lib/python3.6/asyncio/base_events.py", line 468, in run_until_complete
return future.result()
File "<stdin>", line 5, in main
File "/Users/kk/.pyenv/versions/rssant/lib/python3.6/site-packages/aiohttp/client_reqrep.py", line 935, in raise_for_status
assert self.reason # always not None for started response
AssertionError |
I just encountered this issue while doing integration with one of my customer site. |
Hi!
aiohttp
has the following code:This assertion fails if the server omits
Reason-Phrase
, i.e. if response looks likeHTTP/1.1 404
(noNot Found
).HTTP spec is not clear about whether reason must be provided, but e.g. this answer suggests that it may not be: https://stackoverflow.com/questions/17517086/can-an-http-response-omit-the-reason-phrase
Maybe aiohttp should be more permissive in this case. For me, the problem is that hoverfly drops the reason phrase, which leads to aiohttp raising
AssertionError
. Reason can be set to an empty string if it is not found in response.The text was updated successfully, but these errors were encountered: