You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ri...@apache.org on 2007/12/12 11:45:53 UTC

svn commit: r603548 - in /geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec: HttpIoHandler.java HttpRequestMessage.java

Author: rickmcguire
Date: Wed Dec 12 02:45:53 2007
New Revision: 603548

URL: http://svn.apache.org/viewvc?rev=603548&view=rev
Log:
GERONIMO-3618 when redirected via status code 30x, the original query is incorrectly appended to the location

Patch submitted by Sangjin Lee. 


Modified:
    geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpIoHandler.java
    geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpRequestMessage.java

Modified: geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpIoHandler.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpIoHandler.java?rev=603548&r1=603547&r2=603548&view=diff
==============================================================================
--- geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpIoHandler.java (original)
+++ geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpIoHandler.java Wed Dec 12 02:45:53 2007
@@ -117,8 +117,13 @@
             AsyncHttpClient client = (AsyncHttpClient) ioSession.getAttachment();
 
             //Change the request url to the redirect
-            String query = request.getUrl().getQuery();
             request.setUrl(new URL(response.getLocation()));
+            // if we're redirected via 30x, the request method should be reset to GET
+            if (!request.getRequestMethod().equals(HttpRequestMessage.REQUEST_GET)) {
+            	request.setRequestMethod(HttpRequestMessage.REQUEST_GET);
+            }
+            // we also need to clear out the parameters
+            request.clearAllParameters();
 
             //Send the redirect
             client.sendRequest(request);

Modified: geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpRequestMessage.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpRequestMessage.java?rev=603548&r1=603547&r2=603548&view=diff
==============================================================================
--- geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpRequestMessage.java (original)
+++ geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpRequestMessage.java Wed Dec 12 02:45:53 2007
@@ -360,6 +360,14 @@
     public void setParameter(String name, String value) {
         parameters.put(name, value);
     }
+    
+    /**
+     * Clears all parameters.
+     *
+     */
+    public void clearAllParameters() {
+    	parameters.clear();
+    }
 
     /**
      * Gets the user agent string.