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 2017/10/05 16:13:31 UTC
camel git commit: CAMEL-10665: Setting restlet standard headers
should be done via their special api instead of making it easy :(
Repository: camel
Updated Branches:
refs/heads/master acde8ebe7 -> 3d630602d
CAMEL-10665: Setting restlet standard headers should be done via their special api instead of making it easy :(
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/3d630602
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/3d630602
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/3d630602
Branch: refs/heads/master
Commit: 3d630602deb92cf9c5a8d15b4bdcf0a2f37cca08
Parents: acde8eb
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Oct 5 18:13:11 2017 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Oct 5 18:13:11 2017 +0200
----------------------------------------------------------------------
.../restlet/DefaultRestletBinding.java | 24 +++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/3d630602/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 b190f5c..46d9ddc 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
@@ -47,6 +47,7 @@ import org.apache.camel.spi.HeaderFilterStrategyAware;
import org.apache.camel.util.IOHelper;
import org.apache.camel.util.MessageHelper;
import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.StringHelper;
import org.apache.camel.util.URISupport;
import org.apache.http.NameValuePair;
import org.apache.http.client.utils.URLEncodedUtils;
@@ -58,8 +59,11 @@ import org.restlet.data.ChallengeResponse;
import org.restlet.data.ChallengeScheme;
import org.restlet.data.CharacterSet;
import org.restlet.data.ClientInfo;
+import org.restlet.data.Cookie;
+import org.restlet.data.Encoding;
import org.restlet.data.Form;
import org.restlet.data.Header;
+import org.restlet.data.Language;
import org.restlet.data.MediaType;
import org.restlet.data.Method;
import org.restlet.data.Preference;
@@ -349,6 +353,23 @@ public class DefaultRestletBinding implements RestletBinding, HeaderFilterStrate
for (MediaType acceptedMediaType : acceptedMediaTypes) {
acceptedMediaTypesList.add(new Preference<MediaType>(acceptedMediaType));
}
+ } else if ("Accept-Encoding".equalsIgnoreCase(key)) {
+ // assume only accepting one encoding
+ ClientInfo clientInfo = request.getClientInfo();
+ Encoding encoding = Encoding.valueOf(value);
+ clientInfo.getAcceptedEncodings().add(new Preference<>(encoding));
+ } else if ("Accept-Language".equalsIgnoreCase(key)) {
+ // assume only accepting one encoding
+ ClientInfo clientInfo = request.getClientInfo();
+ Language language = Language.valueOf(value);
+ clientInfo.getAcceptedLanguages().add(new Preference<>(language));
+ } else if ("Cookie".equalsIgnoreCase(key)) {
+ String k = StringHelper.before(value, "=");
+ String v = StringHelper.after(value, "=");
+ if (k != null && v != null) {
+ Cookie cookie = new Cookie(k, v);
+ request.getCookies().add(cookie);
+ }
} else if ("Content-Type".equalsIgnoreCase(key)) {
MediaType mediaType = exchange.getContext().getTypeConverter().tryConvertTo(MediaType.class, exchange, value);
if (mediaType != null) {
@@ -381,7 +402,8 @@ public class DefaultRestletBinding implements RestletBinding, HeaderFilterStrate
// ignore these headers
if ("Host".equalsIgnoreCase(key) || "Accept".equalsIgnoreCase(key) || "Accept-encoding".equalsIgnoreCase(key)
- || "User-Agent".equalsIgnoreCase(key) || "Referer".equalsIgnoreCase(key) || "Connection".equalsIgnoreCase(key)) {
+ || "User-Agent".equalsIgnoreCase(key) || "Referer".equalsIgnoreCase(key) || "Connection".equalsIgnoreCase(key)
+ || "Cookie".equalsIgnoreCase(key)) {
continue;
}
if ("Content-Type".equalsIgnoreCase(key)) {