camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r950422 - in /camel/trunk/components: camel-http/src/main/java/org/apache/camel/component/http/ camel-http/src/main/java/org/apache/camel/component/http/helper/ camel-jetty/src/test/java/org/apache/camel/component/jetty/
Date Wed, 02 Jun 2010 08:31:19 GMT
Author: ningjiang
Date: Wed Jun  2 08:31:19 2010
New Revision: 950422

URL: http://svn.apache.org/viewvc?rev=950422&view=rev
Log:
CAMEL-2778 merged the patch into camel-http

Modified:
    camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
    camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpProducerHelper.java
    camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpClientRouteTest.java

Modified: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java?rev=950422&r1=950421&r2=950422&view=diff
==============================================================================
--- camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
(original)
+++ camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
Wed Jun  2 08:31:19 2010
@@ -247,9 +247,10 @@ public class HttpProducer extends Defaul
         // is a query string provided in the endpoint URI or in a header (header overrules
endpoint)
         String queryString = exchange.getIn().getHeader(Exchange.HTTP_QUERY, String.class);
         if (queryString == null) {
-            queryString = getEndpoint().getHttpUri().getQuery();
+            queryString = getEndpoint().getHttpUri().getRawQuery();            
         }
         if (queryString != null) {
+            // need to make sure the queryString is URI safe
             method.setQueryString(queryString);
         }
 

Modified: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpProducerHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpProducerHelper.java?rev=950422&r1=950421&r2=950422&view=diff
==============================================================================
--- camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpProducerHelper.java
(original)
+++ camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpProducerHelper.java
Wed Jun  2 08:31:19 2010
@@ -47,7 +47,7 @@ public final class HttpProducerHelper {
             uri = exchange.getIn().getHeader(Exchange.HTTP_URI, String.class);
         }
         if (uri == null) {
-            uri = endpoint.getHttpUri().toString();
+            uri = endpoint.getHttpUri().toASCIIString();
         }
 
         // append HTTP_PATH to HTTP_URI if it is provided in the header
@@ -66,7 +66,7 @@ public final class HttpProducerHelper {
                         }
                     }
                     baseURI = new URI(baseURIString);
-                    String basePath = baseURI.getPath();
+                    String basePath = baseURI.getRawPath();
                     if (path.startsWith(basePath)) {
                         path = path.substring(basePath.length());
                         if (path.startsWith("/")) {
@@ -90,7 +90,7 @@ public final class HttpProducerHelper {
                 uri = uri.concat(path);
             }
         }
-
+        System.out.println("The uri is " + uri);
         return uri;
     }
 

Modified: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpClientRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpClientRouteTest.java?rev=950422&r1=950421&r2=950422&view=diff
==============================================================================
--- camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpClientRouteTest.java
(original)
+++ camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpClientRouteTest.java
Wed Jun  2 08:31:19 2010
@@ -67,6 +67,16 @@ public class HttpClientRouteTest extends
         // should get the Content-Length
         assertNotNull("Should get the content-lenghth ", headers.get("Content-Length"));
     }
+    
+    @Test
+    public void testHttpRouteWithQuery() throws Exception {
+        MockEndpoint mockEndpoint = getMockEndpoint("mock:a");
+        mockEndpoint.expectedBodiesReceived("%40 query");        
+        
+        template.sendBody("direct:start3", null);
+        mockEndpoint.assertIsSatisfied();        
+        
+    }
 
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
@@ -81,6 +91,7 @@ public class HttpClientRouteTest extends
                 
                 from("direct:start").to("http://localhost:9080/hello").process(clientProc).convertBodyTo(String.class).to("mock:a");
                 from("direct:start2").to("http://localhost:9081/hello").to("mock:a");
+                from("direct:start3").to("http://localhost:9081/Query%20/test?myQuery=%40%20query").to("mock:a");
                 
                 Processor proc = new Processor() {
                     public void process(Exchange exchange) throws Exception {
@@ -91,6 +102,14 @@ public class HttpClientRouteTest extends
                 from("jetty:http://localhost:9080/hello").process(proc).setHeader(Exchange.HTTP_CHUNKED).constant(false);
                 
                 from("jetty:http://localhost:9081/hello?chunked=false").process(proc);
+                
+                from("jetty:http://localhost:9081/Query%20/test").process(new Processor()
{
+
+                    public void process(Exchange exchange) throws Exception {
+                        exchange.getOut().setBody(exchange.getIn().getHeader("myQuery", String.class));
                       
+                    }
+                    
+                });
             }
         };
     }    



Mime
View raw message