HTTPCLIENT-1680: redirect of a POST request causes ClientProtocolException
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/branches/4.5.x@1700136 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
80ff3b2e27
commit
6fd73b5fb5
|
@ -111,7 +111,7 @@ public class RedirectExec implements ClientExecChain {
|
|||
currentRoute, currentRequest, context, execAware);
|
||||
try {
|
||||
if (config.isRedirectsEnabled() &&
|
||||
this.redirectStrategy.isRedirected(currentRequest, response, context)) {
|
||||
this.redirectStrategy.isRedirected(currentRequest.getOriginal(), response, context)) {
|
||||
|
||||
if (redirectCount >= maxRedirects) {
|
||||
throw new RedirectException("Maximum redirects ("+ maxRedirects + ") exceeded");
|
||||
|
@ -119,7 +119,7 @@ public class RedirectExec implements ClientExecChain {
|
|||
redirectCount++;
|
||||
|
||||
final HttpRequest redirect = this.redirectStrategy.getRedirect(
|
||||
currentRequest, response, context);
|
||||
currentRequest.getOriginal(), response, context);
|
||||
if (!redirect.headerIterator().hasNext()) {
|
||||
final HttpRequest original = request.getOriginal();
|
||||
redirect.setHeaders(original.getAllHeaders());
|
||||
|
|
|
@ -120,11 +120,11 @@ public class TestRedirectExec {
|
|||
Mockito.<HttpClientContext>any(),
|
||||
Mockito.<HttpExecutionAware>any())).thenReturn(response2);
|
||||
Mockito.when(redirectStrategy.isRedirected(
|
||||
Mockito.same(request),
|
||||
Mockito.same(get),
|
||||
Mockito.same(response1),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(Boolean.TRUE);
|
||||
Mockito.when(redirectStrategy.getRedirect(
|
||||
Mockito.same(request),
|
||||
Mockito.same(get),
|
||||
Mockito.same(response1),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(redirect);
|
||||
Mockito.when(httpRoutePlanner.determineRoute(
|
||||
|
@ -216,11 +216,11 @@ public class TestRedirectExec {
|
|||
Mockito.<HttpClientContext>any(),
|
||||
Mockito.<HttpExecutionAware>any())).thenReturn(response2);
|
||||
Mockito.when(redirectStrategy.isRedirected(
|
||||
Mockito.same(request),
|
||||
Mockito.same(get),
|
||||
Mockito.same(response1),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(Boolean.TRUE);
|
||||
Mockito.when(redirectStrategy.getRedirect(
|
||||
Mockito.same(request),
|
||||
Mockito.same(get),
|
||||
Mockito.same(response1),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(redirect);
|
||||
Mockito.when(httpRoutePlanner.determineRoute(
|
||||
|
@ -240,10 +240,10 @@ public class TestRedirectExec {
|
|||
|
||||
final AuthState targetAuthState = new AuthState();
|
||||
targetAuthState.setState(AuthProtocolState.SUCCESS);
|
||||
targetAuthState.update(new BasicScheme(), new UsernamePasswordCredentials("user:pass"));
|
||||
targetAuthState.update(new BasicScheme(), new UsernamePasswordCredentials("user", "pass"));
|
||||
final AuthState proxyAuthState = new AuthState();
|
||||
proxyAuthState.setState(AuthProtocolState.SUCCESS);
|
||||
proxyAuthState.update(new NTLMScheme(), new NTCredentials("user:pass"));
|
||||
proxyAuthState.update(new NTLMScheme(), new NTCredentials("user", "pass", null, null));
|
||||
context.setAttribute(HttpClientContext.TARGET_AUTH_STATE, targetAuthState);
|
||||
context.setAttribute(HttpClientContext.PROXY_AUTH_STATE, proxyAuthState);
|
||||
|
||||
|
@ -261,11 +261,11 @@ public class TestRedirectExec {
|
|||
Mockito.<HttpClientContext>any(),
|
||||
Mockito.<HttpExecutionAware>any())).thenReturn(response2);
|
||||
Mockito.when(redirectStrategy.isRedirected(
|
||||
Mockito.same(request),
|
||||
Mockito.same(get),
|
||||
Mockito.same(response1),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(Boolean.TRUE);
|
||||
Mockito.when(redirectStrategy.getRedirect(
|
||||
Mockito.same(request),
|
||||
Mockito.same(get),
|
||||
Mockito.same(response1),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(redirect);
|
||||
Mockito.when(httpRoutePlanner.determineRoute(
|
||||
|
@ -332,11 +332,11 @@ public class TestRedirectExec {
|
|||
Mockito.<HttpClientContext>any(),
|
||||
Mockito.<HttpExecutionAware>any())).thenReturn(response1);
|
||||
Mockito.when(redirectStrategy.isRedirected(
|
||||
Mockito.same(request),
|
||||
Mockito.same(get),
|
||||
Mockito.same(response1),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(Boolean.TRUE);
|
||||
Mockito.doThrow(new ProtocolException("Oppsie")).when(redirectStrategy).getRedirect(
|
||||
Mockito.same(request),
|
||||
Mockito.same(get),
|
||||
Mockito.same(response1),
|
||||
Mockito.<HttpClientContext>any());
|
||||
|
||||
|
|
Loading…
Reference in New Issue