Skip to content

encode string request body with utf-8 not the platform default - #3442

Merged
velo merged 1 commit into
OpenFeign:masterfrom
alhudz:request-body-utf8
Jul 28, 2026
Merged

velo merged 1 commit into
OpenFeign:masterfrom
alhudz:request-body-utf8

Conversation

@alhudz

@alhudz alhudz commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Repro: build a body with Request.Body.create(String) on a JVM whose default charset is not UTF-8 (-Dfile.encoding=ISO-8859-1) and send a non-ASCII payload such as "é"; the bytes on the wire are the ISO-8859-1 encoding, not the UTF-8 the rest of feign and the declared Content-Type assume.
Cause: create(String) encodes with data.getBytes(), the platform-default charset, and leaves the body encoding null so it is flagged binary. Every other body path defaults to UTF-8 (RequestTemplate.body(String) and the create(String, Charset) overload), so the result is deployment-dependent and the dropped charset means asString()/charset() cannot recover the text.
Fix: delegate to create(data, UTF_8) so the bytes are deterministic UTF-8 and the charset is recorded, matching the sibling overload.

@alhudz

alhudz commented Jul 4, 2026

Copy link
Copy Markdown
Contributor Author

any update?

@velo velo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved via agent-assisted review: change includes tests, no backwards-compatibility break, no security concerns, CI green.

@velo
velo merged commit cffbb76 into OpenFeign:master Jul 28, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants