You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2016/02/14 13:01:29 UTC

[2/2] camel git commit: CAMEL-9601: camel-restlet - Should support the Accept header

CAMEL-9601: camel-restlet - Should support the Accept header


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

Branch: refs/heads/camel-2.16.x
Commit: eaf374ab79b6983d657c846c1b6329894da404ef
Parents: 313086d
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Feb 14 13:00:55 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Feb 14 13:01:19 2016 +0100

----------------------------------------------------------------------
 .../camel/component/restlet/DefaultRestletBinding.java      | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/eaf374ab/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
index 32cd8ae..121bf73 100644
--- a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
+++ b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
@@ -212,11 +212,18 @@ public class DefaultRestletBinding implements RestletBinding, HeaderFilterStrate
             }
         }
 
+        // accept
+        String accept = exchange.getIn().getHeader("Accept", String.class);
+        if (accept != null) {
+            MediaType acceptedMediaType = exchange.getContext().getTypeConverter().tryConvertTo(MediaType.class, exchange, accept);
+            if (acceptedMediaType != null) {
+                request.getClientInfo().getAcceptedMediaTypes().add(new Preference<MediaType>(acceptedMediaType));
+            }
+        }
         MediaType acceptedMediaType = exchange.getIn().getHeader(Exchange.ACCEPT_CONTENT_TYPE, MediaType.class);
         if (acceptedMediaType != null) {
             request.getClientInfo().getAcceptedMediaTypes().add(new Preference<MediaType>(acceptedMediaType));
         }
-
     }
 
     public void populateRestletResponseFromExchange(Exchange exchange, Response response) throws Exception {