This is an automated email from the ASF dual-hosted git repository.
Croway pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 7f0d85c3f4b8 CAMEL-27236: camel-platform-http-vertx - skip a response
header whose name is not a valid HTTP header name
7f0d85c3f4b8 is described below
commit 7f0d85c3f4b8ebf44dda9a184739851ae62c1b79
Author: Torsten Mielke <[email protected]>
AuthorDate: Tue Nov 24 11:26:45 2026 +0100
CAMEL-27236: camel-platform-http-vertx - skip a response header whose name
is not a valid HTTP header name
A form field or a query parameter whose name is not an RFC 9110 token (a
space, a comma, a
colon, or the whole text of a bare `curl -d "some text"` body) is copied
into a message
header. Writing it back onto the HTTP response made Vert.x reject it with an
IllegalArgumentException, failing the response with a 500 after the route
had already run.
VertxPlatformHttpSupport.copyMessageHeadersToResponse now skips such a
header with a DEBUG
log instead, reusing HttpHelper.isValidHeaderName from camel-http-base
(already a dependency
of this module) - the same check CAMEL-27235 added for camel-http-common,
camel-netty-http
and camel-http. No request-side decoding change was needed here: Vert.x
already treats a form
field without `=` as a name with an empty value.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
---
.../http/vertx/VertxPlatformHttpSupport.java | 11 ++++++
.../http/vertx/VertxPlatformHttpEngineTest.java | 45 ++++++++++++++++++++--
.../ROOT/pages/camel-4x-upgrade-guide-4_24.adoc | 9 +++++
3 files changed, 62 insertions(+), 3 deletions(-)
diff --git
a/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpSupport.java
b/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpSupport.java
index 1046c166fef0..5d46d8d3ee3c 100644
---
a/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpSupport.java
+++
b/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpSupport.java
@@ -40,6 +40,7 @@ import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.NoTypeConversionAvailableException;
import org.apache.camel.TypeConverter;
+import org.apache.camel.http.base.HttpHelper;
import org.apache.camel.spi.HeaderFilterStrategy;
import org.apache.camel.support.BodyFacts;
import org.apache.camel.support.ExceptionHelper;
@@ -142,6 +143,16 @@ public final class VertxPlatformHttpSupport {
continue;
}
+ if (!HttpHelper.isValidHeaderName(key)) {
+ // a message header can have any name, for example a form
field or a query parameter mapped to a
+ // header, but it cannot be sent as an HTTP header, and the
route has already run
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("Skipping header {} in the response, as its
name is not a valid HTTP header name",
+ HttpHelper.sanitizeLog(key));
+ }
+ continue;
+ }
+
final Object value = entry.getValue();
// use an iterator as there can be multiple values. (must not use
a delimiter)
final Iterator<?> it = ObjectHelper.createIterator(value, null,
true);
diff --git
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpEngineTest.java
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpEngineTest.java
index b6cd597d48f4..3ce3a1d61160 100644
---
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpEngineTest.java
+++
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpEngineTest.java
@@ -1428,7 +1428,7 @@ public class VertxPlatformHttpEngineTest {
}
@Test
- public void testResponseBadQueryParamErrorHandled() throws Exception {
+ public void testResponseSkipsHeaderWithInvalidName() throws Exception {
final CamelContext context = createCamelContextForTest();
try {
@@ -1442,10 +1442,49 @@ public class VertxPlatformHttpEngineTest {
context.start();
- // Add a query param that Vert.x cannot handle
+ // a query param name that is not a valid HTTP header name (RFC
9110 token) is skipped, not a 500 (CAMEL-27236)
get("/error/response?::")
.then()
- .statusCode(500);
+ .statusCode(200)
+ .body(equalTo("Error"))
+ .header("::", nullValue());
+
+ get("/error/response?my%20key=1")
+ .then()
+ .statusCode(200)
+ .body(equalTo("Error"))
+ .header("my key", nullValue());
+
+ // a form field name that is not a valid HTTP header name is
skipped the same way
+ given()
+ .formParam("my key", "1")
+ .when()
+ .post("/error/response")
+ .then()
+ .statusCode(200)
+ .body(equalTo("Error"))
+ .header("my key", nullValue());
+
+ // a form body without = becomes a field name with an empty value,
as sent by curl -d "some text"
+ given()
+ .contentType(ContentType.URLENC)
+ .body("How long do I have?")
+ .when()
+ .post("/error/response")
+ .then()
+ .statusCode(200)
+ .body(equalTo("Error"))
+ .header("How long do I have?", nullValue());
+
+ // a valid field name still round-trips as a response header
+ given()
+ .formParam("q", "How long do I have?")
+ .when()
+ .post("/error/response")
+ .then()
+ .statusCode(200)
+ .body(equalTo("Error"))
+ .header("q", "How long do I have?");
} finally {
context.stop();
}
diff --git
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
index 26ddfa3f2d7a..8e892f5ce65b 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
@@ -11398,3 +11398,12 @@ or in XML and YAML with:
The `CamelPGPDataFormatEncryptionAlgorithm` and
`CamelPGPDataFormatSignatureHashAlgorithm` headers still override
these options for a single message.
+
+=== camel-platform-http-vertx - a header whose name is not a valid HTTP header
name is no longer written to the response
+
+platform-http on the Vert.x engine (Camel Main and Camel Quarkus) maps the
fields of an
+`application/x-www-form-urlencoded` request, and the request's query
parameters, to message headers. When one of these
+names is not a valid HTTP header name (an RFC 9110 token, for example a name
with a space, a comma or a colon), the
+response now leaves out that header and logs it at DEBUG level, instead of
failing the whole response with a 500 after
+the route has already run. Headers with a valid name are written as before. A
route that needs such a value in the
+response must set it in a header with a valid name.