This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch srv2
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git

commit 011891ad42e18fe1b59ae5be9cb4668a93367b90
Author: Claus Ibsen <[email protected]>
AuthorDate: Sun Dec 21 10:58:58 2025 +0100

    CAMEL-22798: camel-platform-http-vertx - VertX has hardcoded content-type 
validation
---
 .../springboot/catalog/components/platform-http.json  |  7 ++++---
 .../src/main/docs/platform-http.json                  |  7 +++++++
 .../http/springboot/CamelRequestHandlerMapping.java   | 14 ++++++++------
 .../PlatformHttpComponentConfiguration.java           | 19 +++++++++++++++++++
 4 files changed, 38 insertions(+), 9 deletions(-)

diff --git 
a/catalog/camel-catalog-provider-springboot/src/main/resources/org/apache/camel/springboot/catalog/components/platform-http.json
 
b/catalog/camel-catalog-provider-springboot/src/main/resources/org/apache/camel/springboot/catalog/components/platform-http.json
index a560595493b..d49650e5a0b 100644
--- 
a/catalog/camel-catalog-provider-springboot/src/main/resources/org/apache/camel/springboot/catalog/components/platform-http.json
+++ 
b/catalog/camel-catalog-provider-springboot/src/main/resources/org/apache/camel/springboot/catalog/components/platform-http.json
@@ -28,9 +28,10 @@
     "bridgeErrorHandler": { "index": 0, "kind": "property", "displayName": 
"Bridge Error Handler", "group": "consumer", "label": "consumer", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": false, "description": 
"Allows for bridging the consumer to the Camel routing Error Handler, which 
mean any exceptions (if possible) occurred while the Camel consumer is trying 
to pickup incoming messages, or the like [...]
     "handleWriteResponseError": { "index": 1, "kind": "property", 
"displayName": "Handle Write Response Error", "group": "consumer", "label": 
"advanced,consumer", "required": false, "type": "boolean", "javaType": 
"boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "When Camel is complete processing the 
message, and the HTTP server is writing response. This option controls whether 
Camel should catch any failure during writing response [...]
     "requestTimeout": { "index": 2, "kind": "property", "displayName": 
"Request Timeout", "group": "consumer", "label": "advanced,consumer", 
"required": false, "type": "integer", "javaType": "long", "deprecated": false, 
"autowired": false, "secret": false, "description": "The period in milliseconds 
after which the request should be timed out." },
-    "autowiredEnabled": { "index": 3, "kind": "property", "displayName": 
"Autowired Enabled", "group": "advanced", "label": "advanced", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": true, "description": 
"Whether autowiring is enabled. This is used for automatic autowiring options 
(the option must be marked as autowired) by looking up in the registry to find 
if there is a single instance of matching t [...]
-    "engine": { "index": 4, "kind": "property", "displayName": "Engine", 
"group": "advanced", "label": "advanced", "required": false, "type": "object", 
"javaType": "org.apache.camel.component.platform.http.spi.PlatformHttpEngine", 
"deprecated": false, "autowired": false, "secret": false, "description": "An 
HTTP Server engine implementation to serve the requests" },
-    "headerFilterStrategy": { "index": 5, "kind": "property", "displayName": 
"Header Filter Strategy", "group": "filter", "label": "filter", "required": 
false, "type": "object", "javaType": 
"org.apache.camel.spi.HeaderFilterStrategy", "deprecated": false, "autowired": 
false, "secret": false, "description": "To use a custom 
org.apache.camel.spi.HeaderFilterStrategy to filter header to and from Camel 
message." }
+    "serverRequestValidation": { "index": 3, "kind": "property", 
"displayName": "Server Request Validation", "group": "consumer", "label": 
"advanced,consumer", "required": false, "type": "boolean", "javaType": 
"boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": true, "description": "Whether HTTP server should do preliminary 
validation of incoming requests, validating if Content-Type\/Accept header, 
matches what is allowed according to consumes\/produces c [...]
+    "autowiredEnabled": { "index": 4, "kind": "property", "displayName": 
"Autowired Enabled", "group": "advanced", "label": "advanced", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": true, "description": 
"Whether autowiring is enabled. This is used for automatic autowiring options 
(the option must be marked as autowired) by looking up in the registry to find 
if there is a single instance of matching t [...]
+    "engine": { "index": 5, "kind": "property", "displayName": "Engine", 
"group": "advanced", "label": "advanced", "required": false, "type": "object", 
"javaType": "org.apache.camel.component.platform.http.spi.PlatformHttpEngine", 
"deprecated": false, "autowired": false, "secret": false, "description": "An 
HTTP Server engine implementation to serve the requests" },
+    "headerFilterStrategy": { "index": 6, "kind": "property", "displayName": 
"Header Filter Strategy", "group": "filter", "label": "filter", "required": 
false, "type": "object", "javaType": 
"org.apache.camel.spi.HeaderFilterStrategy", "deprecated": false, "autowired": 
false, "secret": false, "description": "To use a custom 
org.apache.camel.spi.HeaderFilterStrategy to filter header to and from Camel 
message." }
   },
   "properties": {
     "path": { "index": 0, "kind": "path", "displayName": "Path", "group": 
"consumer", "label": "", "required": true, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": 
false, "secret": false, "description": "The path under which this endpoint 
serves the HTTP requests, for proxy use 'proxy'" },
diff --git 
a/components-starter/camel-platform-http-starter/src/main/docs/platform-http.json
 
b/components-starter/camel-platform-http-starter/src/main/docs/platform-http.json
index f3d6dab4d6a..d304354f5d2 100644
--- 
a/components-starter/camel-platform-http-starter/src/main/docs/platform-http.json
+++ 
b/components-starter/camel-platform-http-starter/src/main/docs/platform-http.json
@@ -62,6 +62,13 @@
       "type": "java.lang.Long",
       "description": "The period in milliseconds after which the request 
should be timed out.",
       "sourceType": 
"org.apache.camel.component.platform.http.springboot.PlatformHttpComponentConfiguration"
+    },
+    {
+      "name": "camel.component.platform-http.server-request-validation",
+      "type": "java.lang.Boolean",
+      "description": "Whether HTTP server should do preliminary validation of 
incoming requests, validating if Content-Type\/Accept header, matches what is 
allowed according to consumes\/produces configuration (if set). If validation 
fails HTTP Status 415\/406 is returned. The HTTP server performs this 
validation before Camel is involved, and as such if validation fails then Camel 
is never activated. Setting this option to false, allows Camel to process any 
incoming requests such as to d [...]
+      "sourceType": 
"org.apache.camel.component.platform.http.springboot.PlatformHttpComponentConfiguration",
+      "defaultValue": true
     }
   ],
   "hints": [],
diff --git 
a/components-starter/camel-platform-http-starter/src/main/java/org/apache/camel/component/platform/http/springboot/CamelRequestHandlerMapping.java
 
b/components-starter/camel-platform-http-starter/src/main/java/org/apache/camel/component/platform/http/springboot/CamelRequestHandlerMapping.java
index 6959eff4da6..f6dc2854e24 100644
--- 
a/components-starter/camel-platform-http-starter/src/main/java/org/apache/camel/component/platform/http/springboot/CamelRequestHandlerMapping.java
+++ 
b/components-starter/camel-platform-http-starter/src/main/java/org/apache/camel/component/platform/http/springboot/CamelRequestHandlerMapping.java
@@ -59,7 +59,7 @@ public class CamelRequestHandlerMapping extends 
RequestMappingHandlerMapping imp
     @Override
     protected String[] getCandidateBeanNames() {
         // no candidates
-        return new String[] {};
+        return new String[]{};
     }
 
     @Override
@@ -202,12 +202,14 @@ public class CamelRequestHandlerMapping extends 
RequestMappingHandlerMapping imp
                 .methods(methods)
                 .options(this.getBuilderConfiguration());
 
-        if (model.getConsumes() != null
+        if (component.isServerRequestValidation()) {
+            if (model.getConsumes() != null && rm != null
                 && (RequestMethod.POST.name().equals(rm.name()) || 
RequestMethod.PUT.name().equals(rm.name()) || 
RequestMethod.PATCH.name().equals(rm.name()))) {
-            info.consumes(model.getConsumes().split(","));
-        }
-        if (model.getProduces() != null) {
-            info.produces(model.getProduces().split(","));
+                info.consumes(model.getConsumes().split(","));
+            }
+            if (model.getProduces() != null) {
+                info.produces(model.getProduces().split(","));
+            }
         }
 
         result.add(info.build());
diff --git 
a/components-starter/camel-platform-http-starter/src/main/java/org/apache/camel/component/platform/http/springboot/PlatformHttpComponentConfiguration.java
 
b/components-starter/camel-platform-http-starter/src/main/java/org/apache/camel/component/platform/http/springboot/PlatformHttpComponentConfiguration.java
index 000cc95d9ae..1226cb10dcf 100644
--- 
a/components-starter/camel-platform-http-starter/src/main/java/org/apache/camel/component/platform/http/springboot/PlatformHttpComponentConfiguration.java
+++ 
b/components-starter/camel-platform-http-starter/src/main/java/org/apache/camel/component/platform/http/springboot/PlatformHttpComponentConfiguration.java
@@ -63,6 +63,17 @@ public class PlatformHttpComponentConfiguration
      * The period in milliseconds after which the request should be timed out.
      */
     private Long requestTimeout;
+    /**
+     * Whether HTTP server should do preliminary validation of incoming
+     * requests, validating if Content-Type/Accept header, matches what is
+     * allowed according to consumes/produces configuration (if set). If
+     * validation fails HTTP Status 415/406 is returned. The HTTP server
+     * performs this validation before Camel is involved, and as such if
+     * validation fails then Camel is never activated. Setting this option to
+     * false, allows Camel to process any incoming requests such as to do 
custom
+     * validation or all requests must be handled by Camel.
+     */
+    private Boolean serverRequestValidation = true;
     /**
      * Whether autowiring is enabled. This is used for automatic autowiring
      * options (the option must be marked as autowired) by looking up in the
@@ -108,6 +119,14 @@ public class PlatformHttpComponentConfiguration
         this.requestTimeout = requestTimeout;
     }
 
+    public Boolean getServerRequestValidation() {
+        return serverRequestValidation;
+    }
+
+    public void setServerRequestValidation(Boolean serverRequestValidation) {
+        this.serverRequestValidation = serverRequestValidation;
+    }
+
     public Boolean getAutowiredEnabled() {
         return autowiredEnabled;
     }

Reply via email to