jossef / jossef/requests

Cookies are ignored on redirects

Open
#83 5 comments 0 reactions 0 assignees View on GitHub
bug good first issue
Dominant language
Dart
Stars
143
Forks
52
PR merge metrics
No merged PRs in 30d

Description

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:

1. Use `final request = Request(...)` for all methods
2. Set `request.followRedirects = false`
3. Do `var response = _handleHttpResponse(...)` before return
4. Check if `response.statusCode` is 301/302. **If true:** Set `response = _httpRequest(HttpMethod.GET, response.headers['location'], ...)`
5. `return response`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.