Implement automatic redirects for requests regardless of the `HttpClient`
Open
Nobody has claimed this yet.
s: feature
- Dominant language
- Dart
- Stars
- 12.8k
- Forks
- 1.6k
- PR merge metrics
- No merged PRs in 30d
Description
Request Statement
As Dart doc stated:
/// Automatic redirect will only happen for "GET" and "HEAD" requests
/// and only for the status codes [HttpStatus.movedPermanently]
/// (301), [HttpStatus.found] (302),
/// [HttpStatus.movedTemporarily] (302, alias for
/// [HttpStatus.found]), [HttpStatus.seeOther] (303),
/// [HttpStatus.temporaryRedirect] (307) and
/// [HttpStatus.permanentRedirect] (308). For
/// [HttpStatus.seeOther] (303) automatic redirect will also happen
/// for "POST" requests with the method changed to "GET" when
/// following the redirect.
The redirections will only happen in these circumstances.
But it might be great if other requests could follow redirections too.
Solution Brainstorm
Pseudo implementation:
int redirectTimes = 0;
Response response = await request(redirectTimes);
while (reseponse.isRedirect && redirectTimes < options.maxRedirects) {
redirectTimes++;
response = await request(redirectTimes);
}
if (response.isRedirect) {
throw StateError('Maximum redirects limit reached.');
}
return response;
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating Dio's current Dart HTTP client redirect handling and the existing redirect options. Review how redirects are handled for request methods and define tests covering additional methods and the maximum redirect limit. Done means supported requests follow redirects consistently and exceeding the limit is reported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- networking
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100