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:28 UTC

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

Repository: camel
Updated Branches:
  refs/heads/camel-2.16.x 313086d25 -> eaf374ab7
  refs/heads/master 1f09884c6 -> 5e61eba52


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/5e61eba5
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/5e61eba5
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/5e61eba5

Branch: refs/heads/master
Commit: 5e61eba520bbf93441efe8111096da7f7fb43792
Parents: 1f09884
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:00:55 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/5e61eba5/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 1f6738e..69821b2 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 {


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

Posted by da...@apache.org.
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 {