There should be an exception in a case of "too many redirects" #2631
Closed
Description
Long story short
When loading http://relax-tip.de/ it redirects to http://deepskin.de/, but http://deepskin.de/ redirects back to http://relax-tip.de/.
aiohttp has built-in limit max_redirects=10, but when this limit is reached users get last redirect response and no way to figure-out that is cycle redirect, as well aiohttp follows redirects automatically and it is no expected to get 304 response.
Expected behaviour
I have an idea, when redirects limit is reached raise TooManyRedirects (requests do it)
Actual behaviour
10 redirect response returned as successful response
Steps to reproduce
import aiohttp
import asyncio
async def main():
async with aiohttp.ClientSession() as session:
async with session.get('http://relax-tip.de/') as response:
import ipdb; ipdb.set_trace()
response
loop = asyncio.get_event_loop()
loop.run_until_complete(main())Your environment
client
If such idea makes sense, I'll do pull request to implement this feature