allthingssecurity opened a new pull request, #27166: URL: https://github.com/apache/camel/pull/27166
# Description [CAMEL-25217](https://issues.apache.org/jira/browse/CAMEL-25217) `VertxPlatformHttpSupport.toHttpResponse` copies the message `Content-Type`, with its `charset` parameter, to the response. `writeResponse` then writes a `String` body with `ctx.end(string)`, which Vert.x always encodes as UTF-8. When the `Content-Type` declares another charset, the client decodes UTF-8 bytes in that charset: - a route that sets `Content-Type: text/plain; charset=ISO-8859-1` and a `String` body: `Grüße aus Köln` (14 characters) goes out as 17 bytes of UTF-8 labelled ISO-8859-1; - an echo, or any route that keeps the request `Content-Type`: the consumer reads an ISO-8859-1 request correctly (it sets `CamelCharsetName` from it), but the `String` reply under the same `Content-Type` is UTF-8. `byte[]`, `InputStream` and `Buffer` bodies are not affected, and neither is ASCII text. The `String` branch has been there since the component was created; the type converter `VertxBufferConverter.toBuffer(String, Exchange)` (CAMEL-16282) already encodes with the charset of the message `Content-Type`. This change: a `String` body is encoded in the charset of the response `Content-Type` when it declares one that the JVM supports. Without a `Content-Type`, without a charset in it, or with UTF-8, the bytes are the same as before. `CamelCharsetName` is deliberately not used when the header has no charset: that would change responses whose header does not announce it. The bytes of responses that declare a non-UTF-8 charset change, so the upgrade guide for 4.23 gets a note (a client that ignored the declared charset must now use it; characters that the declared charset cannot represent are written as `?`). Tests: - `VertxPlatformHttpResponseCharsetTest` (new): a route that declares `text/plain; charset=ISO-8859-1` with a `String` body, an echo of an ISO-8859-1 request (`convertBodyTo(String.class)`), and a control with `text/plain` (UTF-8 expected). - Without the change, the first two fail (`array lengths differ, expected: <14> but was: <17>`); the control passes. - With the change, all camel-platform-http-vertx tests pass: 150 tests, 0 failures, 1 skipped. # 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. - [ ] I have run `mvn clean install -DskipTests` locally from root folder and I have committed all auto-generated changes. (I built and tested the affected module, including the formatter and import-sort plugins. I did not run the full root build.) # AI-assisted contributions - [x] If this PR includes AI-generated code, commits have proper co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR description identifies the AI tool used. This PR was prepared with Claude Code (Claude Opus 5.5). The commit carries a `Co-Authored-By` trailer. _Claude Code on behalf of allthingssecurity_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
