This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit fb197dc28add1338d18f19c5733cdde908d08a3a Author: Claus Ibsen <[email protected]> AuthorDate: Mon Dec 11 09:39:06 2023 +0100 CAMEL-20210: camel-core - Rest DSL Narrow content-type with charset fails clientRequestValidation --- .../rest/RestJettyInvalidContentTypeClientRequestValidationTest.java | 2 +- .../src/main/java/org/apache/camel/processor/RestBindingAdvice.java | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/rest/RestJettyInvalidContentTypeClientRequestValidationTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/rest/RestJettyInvalidContentTypeClientRequestValidationTest.java index 59dcfcac051..3735095cd40 100644 --- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/rest/RestJettyInvalidContentTypeClientRequestValidationTest.java +++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/rest/RestJettyInvalidContentTypeClientRequestValidationTest.java @@ -32,7 +32,7 @@ public class RestJettyInvalidContentTypeClientRequestValidationTest extends Base @Test public void testJettyInvalidContentType() { - fluentTemplate = fluentTemplate.withHeader(Exchange.CONTENT_TYPE, "application/json") + fluentTemplate = fluentTemplate.withHeader(Exchange.CONTENT_TYPE, "application/json; charset=utf-8") .withHeader(Exchange.HTTP_METHOD, "post") .withBody("{\"name\": \"Donald\"}") .to("http://localhost:" + getPort() + "/users/123/update"); diff --git a/core/camel-core-processor/src/main/java/org/apache/camel/processor/RestBindingAdvice.java b/core/camel-core-processor/src/main/java/org/apache/camel/processor/RestBindingAdvice.java index 3b28db61edd..e4beb3fadd0 100644 --- a/core/camel-core-processor/src/main/java/org/apache/camel/processor/RestBindingAdvice.java +++ b/core/camel-core-processor/src/main/java/org/apache/camel/processor/RestBindingAdvice.java @@ -36,6 +36,7 @@ import org.apache.camel.support.MessageHelper; import org.apache.camel.support.processor.MarshalProcessor; import org.apache.camel.support.processor.UnmarshalProcessor; import org.apache.camel.util.ObjectHelper; +import org.apache.camel.util.StringHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -594,6 +595,9 @@ public class RestBindingAdvice implements CamelInternalProcessorAdvice<Map<Strin return true; } + // content-type is before optional charset + target = StringHelper.before(target, ";", target); + valid = valid.toLowerCase(Locale.ENGLISH); target = target.toLowerCase(Locale.ENGLISH);
