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 2021/02/25 18:56:17 UTC
[camel] branch master updated (35154b6 -> 1d1051e)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git.
from 35154b6 CAMEL-16262: camel-http - Add disable options on component to turn features off
new d062cfb camel-http - optimize a bit
new 1d1051e camel-util - Optimize to get charset from content-type header when its UTF-8
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../apache/camel/component/http/helper/HttpMethodHelper.java | 12 ++++++------
.../src/main/java/org/apache/camel/util/IOHelper.java | 5 +++++
.../src/test/java/org/apache/camel/util/IOHelperTest.java | 10 ++++++++++
3 files changed, 21 insertions(+), 6 deletions(-)
[camel] 01/02: camel-http - optimize a bit
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit d062cfb517cf08bbdd924afb22784c4e0ff26bc3
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Feb 25 19:43:43 2021 +0100
camel-http - optimize a bit
---
.../apache/camel/component/http/helper/HttpMethodHelper.java | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpMethodHelper.java b/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpMethodHelper.java
index 64a8053..474048d 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpMethodHelper.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpMethodHelper.java
@@ -40,13 +40,13 @@ public final class HttpMethodHelper {
String queryString = exchange.getIn().getHeader(Exchange.HTTP_QUERY, String.class);
// We need also check the HTTP_URI header query part
String uriString = exchange.getIn().getHeader(Exchange.HTTP_URI, String.class);
- // resolve placeholders in uriString
- try {
- uriString = exchange.getContext().resolvePropertyPlaceholders(uriString);
- } catch (Exception e) {
- throw new RuntimeExchangeException("Cannot resolve property placeholders with uri: " + uriString, exchange, e);
- }
if (uriString != null) {
+ // resolve placeholders in uriString
+ try {
+ uriString = exchange.getContext().resolvePropertyPlaceholders(uriString);
+ } catch (Exception e) {
+ throw new RuntimeExchangeException("Cannot resolve property placeholders with uri: " + uriString, exchange, e);
+ }
// in case the URI string contains unsafe characters
uriString = UnsafeUriCharactersEncoder.encodeHttpURI(uriString);
URI uri = new URI(uriString);
[camel] 02/02: camel-util - Optimize to get charset from
content-type header when its UTF-8
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 1d1051ed1b3207766030b4e317d98d656be1cfc3
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Feb 25 19:51:18 2021 +0100
camel-util - Optimize to get charset from content-type header when its UTF-8
---
.../src/main/java/org/apache/camel/util/IOHelper.java | 5 +++++
.../src/test/java/org/apache/camel/util/IOHelperTest.java | 10 ++++++++++
2 files changed, 15 insertions(+)
diff --git a/core/camel-util/src/main/java/org/apache/camel/util/IOHelper.java b/core/camel-util/src/main/java/org/apache/camel/util/IOHelper.java
index 4c13957..a54cd90 100644
--- a/core/camel-util/src/main/java/org/apache/camel/util/IOHelper.java
+++ b/core/camel-util/src/main/java/org/apache/camel/util/IOHelper.java
@@ -469,6 +469,11 @@ public final class IOHelper {
// try optimized for direct match without using splitting
int pos = contentType.indexOf("charset=");
if (pos != -1) {
+ // special optimization for utf-8 which is a common charset
+ if (contentType.regionMatches(true, pos + 8, "utf-8", 0, 5)) {
+ return "UTF-8";
+ }
+
int end = contentType.indexOf(';', pos);
String charset;
if (end > pos) {
diff --git a/core/camel-util/src/test/java/org/apache/camel/util/IOHelperTest.java b/core/camel-util/src/test/java/org/apache/camel/util/IOHelperTest.java
index 1fbbd71..9db6672 100644
--- a/core/camel-util/src/test/java/org/apache/camel/util/IOHelperTest.java
+++ b/core/camel-util/src/test/java/org/apache/camel/util/IOHelperTest.java
@@ -21,6 +21,7 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class IOHelperTest {
+
@Test
public void testLookupEnvironmentVariable() throws Exception {
assertEquals("8081", IOHelper.lookupEnvironmentVariable("FOO_SERVICE_PORT"));
@@ -28,4 +29,13 @@ public class IOHelperTest {
assertEquals("8081", IOHelper.lookupEnvironmentVariable("foo-service-port"));
assertEquals("8081", IOHelper.lookupEnvironmentVariable("foo.service.port"));
}
+
+ @Test
+ public void testCharset() throws Exception {
+ assertEquals("UTF-8", IOHelper.getCharsetNameFromContentType("charset=utf-8"));
+ assertEquals("UTF-8", IOHelper.getCharsetNameFromContentType("charset=UTF-8"));
+ assertEquals("UTF-8", IOHelper.getCharsetNameFromContentType("text/plain; charset=UTF-8"));
+ assertEquals("UTF-8", IOHelper.getCharsetNameFromContentType("application/json; charset=utf-8"));
+ assertEquals("iso-8859-1", IOHelper.getCharsetNameFromContentType("application/json; charset=iso-8859-1"));
+ }
}