Skip to content

honour requested charset in okhttp response body reader - #3441

Merged
velo merged 1 commit into
OpenFeign:masterfrom
alhudz:okhttp-asreader-charset
Jul 28, 2026
Merged

honour requested charset in okhttp response body reader#3441
velo merged 1 commit into
OpenFeign:masterfrom
alhudz:okhttp-asreader-charset

Conversation

@alhudz

@alhudz alhudz commented Jun 23, 2026

Copy link
Copy Markdown
Contributor
  1. OkHttpClient's response Body.asReader(Charset) ignores the charset argument and delegates to the deprecated asReader(), which returns okhttp's ResponseBody.charStream() (charset taken from Content-Type, defaulting to UTF-8).
  2. decoders read a non-buffered response via response.body().asReader(response.charset()), so the resolved charset is dropped on the okhttp client only; httpclient, hc5 and the core InputStreamBody/ByteArrayBody all decode with the requested charset.

Repro: a text/plain response (no charset parameter) whose body is café as ISO-8859-1 (63 61 66 E9), read via asReader(ISO_8859_1).
Expected: café.
Actual: caf� (decoded as UTF-8).
Fix: decode with the requested charset using new InputStreamReader(asInputStream(), charset), matching the other clients.

@alhudz

alhudz commented Jul 4, 2026

Copy link
Copy Markdown
Contributor Author

gentle ping

@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 f445e24 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