HTTPCLIENT-2051: corrected handling of 303 redirects

This commit is contained in:
Oleg Kalnichevski 2020-04-23 17:14:56 +02:00
parent 177fc804e5
commit e26d537658
2 changed files with 11 additions and 2 deletions

View File

@ -142,11 +142,16 @@ public final class AsyncRedirectExec implements AsyncExecChainHandler {
switch (statusCode) {
case HttpStatus.SC_MOVED_PERMANENTLY:
case HttpStatus.SC_MOVED_TEMPORARILY:
case HttpStatus.SC_SEE_OTHER:
if (Method.POST.isSame(request.getMethod())) {
state.currentRequest = new BasicHttpRequest(Method.GET, redirectUri);
state.currentEntityProducer = null;
}
break;
case HttpStatus.SC_SEE_OTHER:
if (!Method.GET.isSame(request.getMethod()) && !Method.HEAD.isSame(request.getMethod())) {
state.currentRequest = new BasicHttpRequest(Method.GET, redirectUri);
state.currentEntityProducer = null;
}
}
if (state.currentRequest == null) {
state.currentRequest = new BasicHttpRequest(request.getMethod(), redirectUri);

View File

@ -145,10 +145,14 @@ public final class RedirectExec implements ExecChainHandler {
switch (statusCode) {
case HttpStatus.SC_MOVED_PERMANENTLY:
case HttpStatus.SC_MOVED_TEMPORARILY:
case HttpStatus.SC_SEE_OTHER:
if (Method.POST.isSame(request.getMethod())) {
redirect = new HttpGet(redirectUri);
}
break;
case HttpStatus.SC_SEE_OTHER:
if (!Method.GET.isSame(request.getMethod()) && !Method.HEAD.isSame(request.getMethod())) {
redirect = new HttpGet(redirectUri);
}
}
if (redirect == null) {
redirect = new BasicClassicHttpRequest(originalRequest.getMethod(), redirectUri);