-
-
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
Redirect not been followed #2502
Comments
Try |
with requests In [1]: import requests
In [2]: res = requests.get("https://www.gulp.de/gulp2/projekte/suche?scope=projects&query=python")
In [3]: res.status_code
Out[3]: 200
In [4]: len(res.text)
Out[4]: 171410 |
Not sure what requests does, but even browsers reports about improper redirection caused by this URL. I'm sure we can investigate what the request does to handle it - it's very interesting how -, but I guess it's not our problem if reference HTTP client and browsers tells that there is a redirection issue. |
Narrowed it down to setting cookies. Possible solutions:
[1] JSESSION_ID_PROFILE_APP=A3C47AF767CCC88FA36B8292A6FB94A3; Path=/; HttpOnly, gp_intern=(null);path=/;Secure, gp_intern=(null);path=/;Secure |
Nice found! So the problem looks like that aiohttp doesn't set / preserve cookies during redirects and that site sets them though thme (horrible solution). But at least now it's clear why happens what we see with curl. Would you like to submit PR? |
Not sure if we should fix it. |
@asvetlov For me I see it as a buggy server which forces to set cookies via redirect to pass you through. Honestly, it's horrible solution, but technically it may be correct. |
The site is protected from usage by correctly implemented client libraries. Honestly I have no idea where and when we will stop If we try process every buggy quirk out of the box. |
@asvetlov I'm kind of unsure what would be right solution. Fixing it feels like a Tested with Node: var request = require('request');
const url = 'https://www.gulp.de/gulp2/projekte/suche?scope=projects&query=python';
request(url, function(error, response, body) {
console.log('error:', error); // Print the error if one occurred
console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
console.log('body:', body); // Print the HTML for the Google homepage.
}); Error:
|
I went a bit deeper the rabbit hole. Firefox on the other side implements something custom RFC2109/2616 So long story short |
Thanks for shading a light on the problem. aiohttp cannot just use |
Sorry, the RFC specifies Ideas? |
SimpleCookie.__parsestring is just too strict: it also fails to handle expiration dates incorrectly (parses them based on the sane-cookie-date only), see https://bugs.python.org/issue35824#msg334392. Line 175 in 9504fe2
Set-Cookie: has_recent_activity=1; path=/; expires=Mon, 22 Apr 2019 23:27:18 -0000 (due to "-0000" instead of "GMT" at the end).
The interface for
But couldn't it be changed to be based on Another/simpler solution might be to pass an adjusted Currently aiohttp fails to handle 3 out of 4 cookies sent by github.com:
|
From Section 3 in RFC6265: [...] User agents MAY ignore Set-Cookie headers contained in responses with 100-level status codes but MUST process Set-Cookie headers contained in other responses [...] I'm not sure if that server is/was buggy, but the client implementation is broken w.r.t. that RFC when it ignores cookies set in HTTP 3xx responses. On the other hand, the aiohttp documentation states: Response cookies contain only values, that were in I found it surprising that cookies set on redirection (HTTP 302 where I've tried) are discarded by |
If somebody wants to propose a pull request with the fix -- I'll be happy to review it. |
Long story short
Redirect not been followed. I always get a
302
back.Expected behaviour
Get a
200
back with text filled.Steps to reproduce
The text was updated successfully, but these errors were encountered: