Ayush0612005 opened a new pull request, #30916: URL: https://github.com/apache/camel/pull/30916
# Description [CAMEL-27310](https://issues.apache.org/jira/browse/CAMEL-27310) is the follow-up of CAMEL-27235 (#30509), from the review by @davsclaus. A message header can have any name, for example the text of a form field without `=`, which the form parsers map to a header. As in CAMEL-27235, a header whose name is not a valid HTTP header name (an RFC 9110 token, checked with `HttpHelper.isValidHeaderName` from camel-http-base) is now left out of the response and the request, with a DEBUG log through `HttpHelper.sanitizeLog`: - **camel-undertow**: `DefaultUndertowHttpBinding` wrote such a name as it is with `new HttpString(key)`, which rejects CR/LF but not a space, a comma or a colon, in the response (consumer) and in the request (producer). - **camel-vertx-http**: `DefaultVertxHttpBinding.populateRequestHeaders` failed the exchange with `IllegalArgumentException: a header name cannot contain some prohibited characters` after the route had run. platform-http-vertx is tracked in CAMEL-27236. The smaller points from the CAMEL-27235 review: - A field such as `=x` has an empty name, which the WHATWG parser keeps, and so do both bindings: new tests pin that in `DefaultHttpBinding` and `DefaultNettyHttpBinding` (the response does not write it), and the comment next to the empty-field check now says so. - `DefaultHttpBindingFormUrlEncodedTest` also covers a declared ISO-8859-1 charset with `%E9`, an unknown charset (`UnsupportedEncodingException`), and repeated fields (`a=1&a=2`, `flag&flag`). - The Javadoc of `DefaultNettyHttpBinding.decodeFormField` notes that an `IllegalArgumentException` thrown on purpose by an overriding `shouldUrlDecodeHeader` gets the fallback decoding. The upgrade guide for 4.24 has an entry for the undertow and vertx-http change. # Tests - `UndertowInvalidHeaderNameTest`: with a raw socket, the response of an undertow consumer and the request of an undertow producer do not contain a header named `Bad Name`, and a form field without `=` is still a message header. - `VertxHttpInvalidHeaderNameTest`: a vertx-http producer with a header named `Save 50 percent now` succeeds, and the server does not receive it. Without the fix, both undertow tests fail (`Bad Name: x` is in the raw response and request), and the vertx-http test fails with the `IllegalArgumentException`. With it, the full test suites pass: camel-undertow (307), camel-vertx-http (130), camel-http-common (60) and camel-netty-http (411). # Target - [x] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch) # Tracking - [x] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it). # Apache Camel coding standards and style - [x] I checked that each commit in the pull request has a meaningful subject line and body. - [x] I built the four modules with `install` (including `formatter:format` and `impsort:sort`); no generated file changed. _Claude Code on behalf of Ayush0612005_ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
