You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2010/01/21 11:14:55 UTC

svn commit: r901634 - in /camel/trunk/components: camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java

Author: ningjiang
Date: Thu Jan 21 10:14:54 2010
New Revision: 901634

URL: http://svn.apache.org/viewvc?rev=901634&view=rev
Log:
CAMEL-2386 Parsing the request parameter for the POST method

Modified:
    camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
    camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java

Modified: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java?rev=901634&r1=901633&r2=901634&view=diff
==============================================================================
--- camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java (original)
+++ camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java Thu Jan 21 10:14:54 2010
@@ -79,8 +79,9 @@
         }
 
         //we populate the http request parameters for GET and POST 
+        
         String method = request.getMethod();
-        if (method.equalsIgnoreCase("GET") || (method.equalsIgnoreCase("POST") && contentType.equalsIgnoreCase("application/x-www-form-urlencoded"))) {
+        if (method.equalsIgnoreCase("GET") || (method.equalsIgnoreCase("POST"))) {
             names = request.getParameterNames();
             while (names.hasMoreElements()) {
                 String name = (String)names.nextElement();

Modified: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java?rev=901634&r1=901633&r2=901634&view=diff
==============================================================================
--- camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java (original)
+++ camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java Thu Jan 21 10:14:54 2010
@@ -113,6 +113,18 @@
         String out = context.getTypeConverter().convertTo(String.class, response);
         assertEquals("Get a wrong output " , "OK", out);
     }
+    
+    @Test
+    public void testPostParameterInURI() throws Exception {
+        HttpClient client = new HttpClient();
+        PostMethod post = new PostMethod("http://localhost:9080/post?request=PostParameter&others=bloggs");
+        StringRequestEntity entity = new StringRequestEntity(POST_MESSAGE, "application/xml", "UTF-8");
+        post.setRequestEntity(entity);
+        client.executeMethod(post);
+        InputStream response = post.getResponseBodyAsStream();
+        String out = context.getTypeConverter().convertTo(String.class, response);
+        assertEquals("Get a wrong output " , "PostParameter", out);
+    }
 
     protected void invokeHttpEndpoint() throws IOException {
         template.requestBodyAndHeader("http://localhost:9080/test", expectedBody, "Content-Type", "application/xml");