-
Notifications
You must be signed in to change notification settings - Fork 56
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
Cookies are ignored on redirects #83
Comments
Hi @Alyxsqrd, I've tested locally on dart vm and flutter web your fix and requests requests/lib/src/requests.dart Line 24 in e5192e9
Or the regexes in CookieJar.parseCookiesString are not picking your cookie.Line 104 in e5192e9
Is your fix working for you ? |
Or maybe you thought that this package does redirects by itself ? Unlike Python's requests library, this requests dart package does not yet support redirects, this matter was discussed in #11 but was unfortunately left on hiatus. |
Can you test doing your request that does a 301/302 redirect and see the stored cookies with this: and tell me if the cookies are set or not ? CookieJar cookieJar = await Requests.getStoredCookies(Requests.getHostname(url));
print(cookieJar.values); |
I've experienced similar issues. Requests library doesn't even have a chance to save cookies from intermediate responses, as these are not even returned to Requests when followRedirects is set to true. |
I'm running into this same issue right now. A Which workarounds would I have as of today? Edit: I should add that, generally, a 302 after a |
Hi, it appears that this library ignores the cookies provided by the
Set-Cookie
header in a 301/302 redirect.My best guess as to what's causing this: when Dart's HTTP library has☹️
followRedirects = true
, ONLY the headers from the final destination are returned, meaning the headers from the prior responses are totally lost.Possible workaround could be:
final request = Request(...)
for all methodsrequest.followRedirects = false
var response = _handleHttpResponse(...)
before returnresponse.statusCode
is 301/302. If true: Setresponse = _httpRequest(HttpMethod.GET, response.headers['location'], ...)
return response
The text was updated successfully, but these errors were encountered: