camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r761334 - in /camel/trunk/components/camel-http/src: main/java/org/apache/camel/component/http/HttpProducer.java test/java/org/apache/camel/component/http/HttpGetWithPathHeaderTest.java
Date Thu, 02 Apr 2009 16:15:49 GMT
Author: davsclaus
Date: Thu Apr  2 16:15:48 2009
New Revision: 761334

URL: http://svn.apache.org/viewvc?rev=761334&view=rev
Log:
CAMEL-1504: HTTP_PATH header is now also used when building URI to call http service with.
Applied patch with thanks to Mathis Schwuchow.

Added:
    camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetWithPathHeaderTest.java
  (with props)
Modified:
    camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.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=761334&r1=761333&r2=761334&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
Thu Apr  2 16:15:48 2009
@@ -201,6 +201,19 @@
             uri = ((HttpEndpoint)getEndpoint()).getHttpUri().toString();
         }
 
+        // append HTTP_PATH to HTTP_URI if it is provided in the header
+        String path = exchange.getIn().getHeader(HttpConstants.HTTP_PATH, String.class);
+        if (path != null) {
+            // make sure that there is exactly one "/" between HTTP_URI and HTTP_PATH
+            if (!uri.endsWith("/")) {
+                uri = uri + "/";
+            }
+            if (path.startsWith("/")) {
+                path = path.substring(1);
+            }
+            uri = uri.concat(path);
+        }
+
         HttpMethod method = methodToUse.createMethod(uri);
 
         if (queryString != null) {

Added: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetWithPathHeaderTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetWithPathHeaderTest.java?rev=761334&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetWithPathHeaderTest.java
(added)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetWithPathHeaderTest.java
Thu Apr  2 16:15:48 2009
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.http;
+
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class HttpGetWithPathHeaderTest extends HttpGetTest {
+    
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() {
+                from("direct:start")
+                    .setHeader(HttpConstants.HTTP_PATH, constant("search"))
+                    .setHeader(HttpConstants.HTTP_QUERY, constant("hl=en&q=activemq"))
+                    .to("http://www.google.com").to("mock:results");
+            }
+        };
+    }
+}

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetWithPathHeaderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetWithPathHeaderTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message