This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch camel-3.22.x in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-3.22.x by this push: new 2385aa464de CAMEL-20210: camel-core - Rest DSL Narrow content-type with charset fails clientRequestValidation (#13353) 2385aa464de is described below commit 2385aa464de4bd935989bfd1bc5fb8482acd0aa1 Author: Kari Mattila <33413417+kari-w...@users.noreply.github.com> AuthorDate: Thu Feb 29 17:19:27 2024 +0200 CAMEL-20210: camel-core - Rest DSL Narrow content-type with charset fails clientRequestValidation (#13353) Co-authored-by: Claus Ibsen <claus.ib...@gmail.com> --- .../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 b6737e9f545..0734309896e 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; @@ -565,6 +566,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);