You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by zr...@apache.org on 2017/04/03 07:43:41 UTC

camel git commit: CAMEL-11092 If setting Exchange.REST_HTTP_URI t...

Repository: camel
Updated Branches:
  refs/heads/master 276a75b4e -> 292e16a20


CAMEL-11092 If setting Exchange.REST_HTTP_URI t...

...he RestProducer should remove Exchange.HTTP_PATH header

As most HTTP components generate URIs by concatenating
`Exchange.REST_HTTP_URI` and `Exchange.HTTP_PATH` when the REST producer
generates `Exchange.REST_HTTP_URI` header that contains the whole URI to
be used it should remove the `Exchange.HTTP_PATH` header in order to
prevent incorrect URIs.

For example `Exchange.HTTP_PATH` is set by the REST consumer to
`/api/pet/123`, and REST producer is configured with
`Exchange.REST_HTTP_URI` with URI `/api/pet/{petId}` if the
`Exchange.HTTP_PATH` is not removed HTTP component (IMHO all except for
Restlet) would try to send the request to `/api/pet/{petId}/api/pet/123`


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/292e16a2
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/292e16a2
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/292e16a2

Branch: refs/heads/master
Commit: 292e16a20753d8322fb7fb3792edfaeb9e865056
Parents: 276a75b
Author: Zoran Regvart <zr...@apache.org>
Authored: Wed Mar 29 14:55:57 2017 +0200
Committer: Zoran Regvart <zr...@apache.org>
Committed: Mon Apr 3 09:43:15 2017 +0200

----------------------------------------------------------------------
 .../java/org/apache/camel/component/rest/RestProducer.java   | 8 ++++++++
 1 file changed, 8 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/292e16a2/camel-core/src/main/java/org/apache/camel/component/rest/RestProducer.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/rest/RestProducer.java b/camel-core/src/main/java/org/apache/camel/component/rest/RestProducer.java
index a69b1f6..644025f 100644
--- a/camel-core/src/main/java/org/apache/camel/component/rest/RestProducer.java
+++ b/camel-core/src/main/java/org/apache/camel/component/rest/RestProducer.java
@@ -194,6 +194,14 @@ public class RestProducer extends DefaultAsyncProducer {
             }
             // the http uri for the rest call to be used
             inMessage.setHeader(Exchange.REST_HTTP_URI, overrideUri);
+
+            // when chaining RestConsumer with RestProducer, the
+            // HTTP_PATH header will be present, we remove it here
+            // as the REST_HTTP_URI contains the full URI for the
+            // request and every other HTTP producer will concatenate
+            // REST_HTTP_URI with HTTP_PATH resulting in incorrect
+            // URIs
+            inMessage.removeHeader(Exchange.HTTP_PATH);
         }
 
         final String produces = getEndpoint().getProduces();