You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2008/01/10 17:31:33 UTC

svn commit: r610838 - in /httpcomponents/httpclient/trunk/module-client/src: main/java/org/apache/http/impl/client/DefaultRedirectHandler.java test/java/org/apache/http/client/protocol/TestRedirects.java

Author: olegk
Date: Thu Jan 10 08:31:32 2008
New Revision: 610838

URL: http://svn.apache.org/viewvc?rev=610838&view=rev
Log:
Fixed incorrect handling of redirect locations with the query component

Contributed by Johannes Koch <johannes.koch at fit.fraunhofer.de>  
Reviewed by Oleg Kalnichevski

Modified:
    httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultRedirectHandler.java
    httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/protocol/TestRedirects.java

Modified: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultRedirectHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultRedirectHandler.java?rev=610838&r1=610837&r2=610838&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultRedirectHandler.java (original)
+++ httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultRedirectHandler.java Thu Jan 10 08:31:32 2008
@@ -143,7 +143,7 @@
                         target.getPort(),
                         requestURI.getPath(),
                         requestURI.getQuery(),
-                        requestURI.getFragment());
+                        null);
                 uri = absoluteRequestURI.resolve(uri); 
             } catch (URISyntaxException ex) {
                 throw new ProtocolException(ex.getMessage(), ex);
@@ -169,7 +169,7 @@
                             uri.getHost(),
                             uri.getPort(),
                             uri.getPath(),
-                            null,
+                            uri.getQuery(),
                             null);
                 } catch (URISyntaxException ex) {
                     throw new ProtocolException(ex.getMessage(), ex);

Modified: httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/protocol/TestRedirects.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/protocol/TestRedirects.java?rev=610838&r1=610837&r2=610838&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/protocol/TestRedirects.java (original)
+++ httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/protocol/TestRedirects.java Thu Jan 10 08:31:32 2008
@@ -131,8 +131,6 @@
 
     private class CircularRedirectService implements HttpRequestHandler {
 
-        private int invocations = 0;
-        
         public CircularRedirectService() {
             super();
         }
@@ -145,10 +143,10 @@
             String uri = request.getRequestLine().getUri();
             if (uri.startsWith("/circular-oldlocation")) {
                 response.setStatusLine(ver, HttpStatus.SC_MOVED_TEMPORARILY);
-                response.addHeader(new BasicHeader("Location", "/circular-location2?invk=" + (++this.invocations)));
+                response.addHeader(new BasicHeader("Location", "/circular-location2"));
             } else if (uri.startsWith("/circular-location2")) {
                 response.setStatusLine(ver, HttpStatus.SC_MOVED_TEMPORARILY);
-                response.addHeader(new BasicHeader("Location", "/circular-oldlocation?invk=" + (++this.invocations)));
+                response.addHeader(new BasicHeader("Location", "/circular-oldlocation"));
             } else {
                 response.setStatusLine(ver, HttpStatus.SC_NOT_FOUND);
             }