hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1700136 - in /httpcomponents/httpclient/branches/4.5.x/httpclient/src: main/java/org/apache/http/impl/execchain/RedirectExec.java test/java/org/apache/http/impl/execchain/TestRedirectExec.java
Date Sun, 30 Aug 2015 16:34:38 GMT
Author: olegk
Date: Sun Aug 30 16:34:38 2015
New Revision: 1700136

URL: http://svn.apache.org/r1700136
Log:
HTTPCLIENT-1680: redirect of a POST request causes ClientProtocolException

Modified:
    httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/impl/execchain/RedirectExec.java
    httpcomponents/httpclient/branches/4.5.x/httpclient/src/test/java/org/apache/http/impl/execchain/TestRedirectExec.java

Modified: httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/impl/execchain/RedirectExec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/impl/execchain/RedirectExec.java?rev=1700136&r1=1700135&r2=1700136&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/impl/execchain/RedirectExec.java
(original)
+++ httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/impl/execchain/RedirectExec.java
Sun Aug 30 16:34:38 2015
@@ -111,7 +111,7 @@ public class RedirectExec implements Cli
                     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 Cli
                     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());

Modified: httpcomponents/httpclient/branches/4.5.x/httpclient/src/test/java/org/apache/http/impl/execchain/TestRedirectExec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.5.x/httpclient/src/test/java/org/apache/http/impl/execchain/TestRedirectExec.java?rev=1700136&r1=1700135&r2=1700136&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/4.5.x/httpclient/src/test/java/org/apache/http/impl/execchain/TestRedirectExec.java
(original)
+++ httpcomponents/httpclient/branches/4.5.x/httpclient/src/test/java/org/apache/http/impl/execchain/TestRedirectExec.java
Sun Aug 30 16:34:38 2015
@@ -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());
 



Mime
View raw message