camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r788406 - in /camel/branches/camel-1.x: ./ components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java
Date Thu, 25 Jun 2009 15:55:12 GMT
Author: ningjiang
Date: Thu Jun 25 15:55:12 2009
New Revision: 788406

URL: http://svn.apache.org/viewvc?rev=788406&view=rev
Log:
Merged revisions 788393 via svnmerge from 
https://svn.apache.org/repos/asf/camel/trunk

........
  r788393 | ningjiang | 2009-06-25 23:30:27 +0800 (Thu, 25 Jun 2009) | 1 line
  
  CAMEL-1760 fixed the issue of post params in camel-jetty component
........

Modified:
    camel/branches/camel-1.x/   (props changed)
    camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
    camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java

Propchange: camel/branches/camel-1.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jun 25 15:55:12 2009
@@ -1 +1 @@
-/camel/trunk:736980,739733,739904,740251,740295,740306,740596,740663,741848,742231,742705,742739,742854,742856,742898,742906,743613,743762,743773,743920,743959-743960,744123,745105,745367,745541,745751,745826,745978,746269,746872,746895,746962,747258,747678-747704,748392,748436,748821,749563-749564,749574,749628-749629,749936,749956,750017,750334,750396,750761,750796,752068,752117,752418,752751-752755,752764-752773,752956,753087,753101,753175,755136,755487,756313,756348,756870,756939,757636,757693,757743,757865,758539,758563,758600,758617,758692,758990,759362,759453,759887,759931,760003,760890,760909,760937,761194,761536,761583,761607,762047,762633,762650,762935,763095,763484,763551,765154,765686,765729,765743,765824,766016,766289,766584,766588,766590,766602,766673,767403,767824,768342,769239,769346,769368,769434,770172,770906,771303,773193,773446,773781,774192,774383,774658-774659,776198,776289,776504,776975,778102,778689-778701,779121,779143,779489,781314-781349,781775,781
 923,781974,781993,782557,782594,782681,782886,782918-782923,783204,783248,783363,783639,783704,785564,785584,785599,787206,787581,787598,787605,787928
+/camel/trunk:736980,739733,739904,740251,740295,740306,740596,740663,741848,742231,742705,742739,742854,742856,742898,742906,743613,743762,743773,743920,743959-743960,744123,745105,745367,745541,745751,745826,745978,746269,746872,746895,746962,747258,747678-747704,748392,748436,748821,749563-749564,749574,749628-749629,749936,749956,750017,750334,750396,750761,750796,752068,752117,752418,752751-752755,752764-752773,752956,753087,753101,753175,755136,755487,756313,756348,756870,756939,757636,757693,757743,757865,758539,758563,758600,758617,758692,758990,759362,759453,759887,759931,760003,760890,760909,760937,761194,761536,761583,761607,762047,762633,762650,762935,763095,763484,763551,765154,765686,765729,765743,765824,766016,766289,766584,766588,766590,766602,766673,767403,767824,768342,769239,769346,769368,769434,770172,770906,771303,773193,773446,773781,774192,774383,774658-774659,776198,776289,776504,776975,778102,778689-778701,779121,779143,779489,781314-781349,781775,781
 923,781974,781993,782557,782594,782681,782886,782918-782923,783204,783248,783363,783639,783704,785564,785584,785599,787206,787581,787598,787605,787928,788393

Propchange: camel/branches/camel-1.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java?rev=788406&r1=788405&r2=788406&view=diff
==============================================================================
--- camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
(original)
+++ camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
Thu Jun 25 15:55:12 2009
@@ -51,6 +51,9 @@
     }
 
     public void readRequest(HttpServletRequest request, HttpMessage message) {
+        // lets parser the parameterMap first to avoid consuming the POST parameters as InputStream
+        request.getParameterMap();
+        
         // lets force a parse of the body and headers
         message.getBody();
         // populate the headers from the request

Modified: camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java?rev=788406&r1=788405&r2=788406&view=diff
==============================================================================
--- camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java
(original)
+++ camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java
Thu Jun 25 15:55:12 2009
@@ -23,6 +23,7 @@
 import java.util.List;
 import java.util.Map;
 
+import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpSession;
 
 import org.apache.camel.ContextTestSupport;
@@ -33,6 +34,12 @@
 import org.apache.camel.component.http.HttpExchange;
 import org.apache.camel.component.mock.MockEndpoint;
 
+import org.apache.camel.converter.stream.InputStreamCache;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.NameValuePair;
+import org.apache.commons.httpclient.methods.PostMethod;
+
+
 /**
  * @version $Revision$
  */
@@ -73,6 +80,18 @@
         assertEquals("<b>Hello World</b>", data);
 
     }
+    
+    public void testPostParameter() throws Exception {
+        NameValuePair[] data = {new NameValuePair("request", "PostParameter"),
+                                new NameValuePair("others", "bloggs")};
+        HttpClient client = new HttpClient();
+        PostMethod post = new PostMethod("http://localhost:9080/post");
+        post.setRequestBody(data);
+        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.sendBodyAndHeader("http://localhost:9080/test", expectedBody, "Content-Type",
"application/xml");
@@ -82,6 +101,7 @@
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() {
+
                 from("jetty:http://localhost:9080/test").to("mock:a");
 
                 Processor proc = new Processor() {
@@ -97,6 +117,20 @@
                     }
                 };
                 from("jetty:http://localhost:9080/hello?sessionSupport=true").process(proc);
+                
+                Processor procPostParameters = new Processor() {
+                    public void process(Exchange exchange) throws Exception {
+                        HttpServletRequest req = exchange.getIn().getBody(HttpServletRequest.class);
+                        String value = req.getParameter("request");                     
  
+                        if (value != null) {
+                            exchange.getOut().setBody(value);
+                        } else {
+                            exchange.getOut().setBody("Can't get a right parameter");
+                        }
+                    }
+                };
+                
+                from("jetty:http://localhost:9080/post").process(procPostParameters);
             }
         };
     }



Mime
View raw message