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/07/11 15:06:12 UTC
camel git commit: CAMEL-11423 Make camel-olingo2/4 ACCEPT headers
RFC-7231 compliant.
Repository: camel
Updated Branches:
refs/heads/camel-2.18.x c4c0e31f9 -> 5db353756
CAMEL-11423 Make camel-olingo2/4 ACCEPT headers RFC-7231 compliant.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/5db35375
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/5db35375
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/5db35375
Branch: refs/heads/camel-2.18.x
Commit: 5db35375687397cfe17b3cbb5ac5d0b29bfe1d73
Parents: c4c0e31
Author: Sean Haynes <s....@ieee.org>
Authored: Tue Jul 11 09:13:43 2017 -0400
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Jul 11 17:05:16 2017 +0200
----------------------------------------------------------------------
.../olingo2/api/impl/Olingo2AppImpl.java | 24 ++++++++++++++++----
1 file changed, 19 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/5db35375/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/Olingo2AppImpl.java
----------------------------------------------------------------------
diff --git a/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/Olingo2AppImpl.java b/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/Olingo2AppImpl.java
index 028ff5c..c709b8b 100644
--- a/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/Olingo2AppImpl.java
+++ b/components/camel-olingo2/camel-olingo2-api/src/main/java/org/apache/camel/component/olingo2/api/impl/Olingo2AppImpl.java
@@ -766,7 +766,12 @@ public final class Olingo2AppImpl implements Olingo2App {
}
// Olingo is sensitive to batch part charset case!!
- headers.put(HttpHeaders.ACCEPT, getResourceContentType(uriInfo).toString().toLowerCase());
+ final ContentType contentType = getResourceContentType(uriInfo);
+ headers.put(HttpHeaders.ACCEPT, contentType.withCharset("").toString().toLowerCase());
+ final Charset charset = contentType.getCharset();
+ if (null != charset) {
+ headers.put(HttpHeaders.ACCEPT_CHARSET, charset.name().toLowerCase());
+ }
if (!headers.containsKey(HttpHeaders.CONTENT_TYPE)) {
headers.put(HttpHeaders.CONTENT_TYPE, getContentType());
}
@@ -788,10 +793,16 @@ public final class Olingo2AppImpl implements Olingo2App {
private BatchQueryPart createBatchQueryPart(UriInfoWithType uriInfo, Olingo2BatchQueryRequest batchRequest) {
final Map<String, String> headers = new HashMap<String, String>(batchRequest.getHeaders());
+ final ContentType contentType = getResourceContentType(uriInfo);
+ final Charset charset = contentType.getCharset();
if (!headers.containsKey(HttpHeaders.ACCEPT)) {
// Olingo is sensitive to batch part charset case!!
- headers.put(HttpHeaders.ACCEPT, getResourceContentType(uriInfo).toString().toLowerCase());
+ headers.put(HttpHeaders.ACCEPT, contentType.withCharset("").toString().toLowerCase());
+ }
+ if (!headers.containsKey(HttpHeaders.ACCEPT_CHARSET) && (null != charset)) {
+ headers.put(HttpHeaders.ACCEPT_CHARSET, charset.name().toLowerCase());
}
+
return BatchQueryPart.method("GET")
.uri(createBatchUri(batchRequest))
@@ -1013,16 +1024,19 @@ public final class Olingo2AppImpl implements Olingo2App {
FutureCallback<HttpResponse> callback) {
// add accept header when its not a form or multipart
- final String contentTypeString = contentType.toString();
if (!ContentType.APPLICATION_FORM_URLENCODED.getMimeType().equals(contentType.getMimeType())
&& !contentType.getMimeType().startsWith(MULTIPART_MIME_TYPE)) {
// otherwise accept what is being sent
- httpUriRequest.addHeader(HttpHeaders.ACCEPT, contentTypeString);
+ httpUriRequest.addHeader(HttpHeaders.ACCEPT, contentType.withCharset("").toString().toLowerCase());
}
// is something being sent?
if (httpUriRequest instanceof HttpEntityEnclosingRequestBase
&& httpUriRequest.getFirstHeader(HttpHeaders.CONTENT_TYPE) == null) {
- httpUriRequest.addHeader(HttpHeaders.CONTENT_TYPE, contentTypeString);
+ httpUriRequest.addHeader(HttpHeaders.CONTENT_TYPE, contentType.toString());
+ final Charset charset = contentType.getCharset();
+ if (null != charset) {
+ httpUriRequest.addHeader(HttpHeaders.ACCEPT_CHARSET, charset.name().toLowerCase());
+ }
}
// set user specified custom headers