Skip to content
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

Too many 301 redirects #3132

Closed
amarynets opened this issue Jul 11, 2018 · 5 comments
Closed

Too many 301 redirects #3132

amarynets opened this issue Jul 11, 2018 · 5 comments
Labels

Comments

@amarynets
Copy link

Long story short

aiohttp.ClientSession.get() does 10 301 redirection and return empty text response

Expected behaviour

Passing the URL, get a not empty response

Actual behaviour

I make a request and in history of the response object I see 10 redirections with status code 301 and text of response is empty, I tried to make this request with curl and requests and the result was successful. got this result for url1 and url2

Steps to reproduce

import asyncio
import aiohttp

url1 = 'https://www.jonathanadler.com/art/by-artist/slim-aarons/slim-aarons-andldquo%3Bverbier-vacationandrdquo%3B-photograph/19135.html'
url2 = 'https://www.jonathanadler.com/furniture/by-category/benches-and-ottomans/x-bench/24-1900005.html?dwvar_24-1900005_base=NoBase&dwvar_24-1900005_quickShip=custom&dwvar_24-1900005_fabric=AntwerpSea&dwvar_24-1900005_fabricType=TexturedWoven'

async def request(url):
    async with aiohttp.ClientSession() as session:
        async with session.get(url, allow_redirects=True) as response:
            return response, await response.text()

async def check(url):
    response, text = await request(url)
    print(response.history)

loop = asyncio.get_event_loop()
loop.run_until_complete(check(url1))

Your environment

ubuntu 16.04, Python 3.6, Client
aiohttp==2.3.2
Also, tried aiohttp==3.3.2, and got exception line 418, in _request history[0].request_info, tuple(history)) aiohttp.client_exceptions.TooManyRedirects: 0, message=''

@asvetlov
Copy link
Member

requests has 30 redirects limit, aiohttp has only 10.
We can increase the number if really needed (the issue is the first request for it).
Anyway you can configure the number by passing sess.get(url, max_redirects=30) right now.

@amarynets
Copy link
Author

I increased num of redirects to 30, but it doesn't help. I've checked the history of requests response and it is empty

@asvetlov
Copy link
Member

aiohttp 2.3 is not supported, aiohttp 3.x should raise an exception on redirection limit exceeding.
If you have no exception but empty response only -- the problem is not related to redirection but a server returns an empty response somehow.

@amarynets
Copy link
Author

thanks

@lock
Copy link

lock bot commented Oct 28, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs.
If you feel like there's important points made in this discussion, please include those exceprts into that [new issue].
[new issue]: https://github.com/aio-libs/aiohttp/issues/new

@lock lock bot added the outdated label Oct 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants