Open
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;