Skip to content

Conversation

@ok2c
Copy link
Member

@ok2c ok2c commented Aug 5, 2025

Treat unsupported content encoding as an error. @arturobernalg Please double-check

@ok2c ok2c requested a review from arturobernalg August 5, 2025 09:02
Copy link
Member

@arturobernalg arturobernalg left a comment

Choose a reason for hiding this comment

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

make sense. LGTM @ok2c

@ok2c ok2c merged commit 97e4041 into apache:master Aug 5, 2025
10 checks passed
@ok2c ok2c deleted the unsupported_content_encoding_as_error branch October 26, 2025 17:31
@plesingr-aeb
Copy link

plesingr-aeb commented Jan 12, 2026

Hi, I have a problem with this change.
Using HttpClients.custom() with some adaptions (useSystemProperties, setTargetAuthenticationStrategy, setRoutePlanner(new SystemDefaultRoutePlanner(proxySelector)), I have a simple request like

GET something
Accept: text/plain

w/o specifying any accept-encoding. The client appears to fill in some default codecs in this header before it is sent (it was filled in the previous versions, too).
The response from the server is

Content-Encoding: UTF-8
Content-Type: text/plain
foo bar

It worked with the previous versions but now the request fails with Unsupported Content-Encoding: utf-8. Am I doing something wrong?

@ok2c
Copy link
Member Author

ok2c commented Jan 12, 2026

It worked with the previous versions but now the request fails with Unsupported Content-Encoding: utf-8. Am I doing something wrong?

@plesingr-aeb You are doing nothing wrong, but the origin server does. UTF-8 is a charset, not a content encoding. The previous versions of HttpClient ignored such violations. As of 5.6 HttpClient support many different content encodings and the handling logic got stricter.

@plesingr-aeb
Copy link

plesingr-aeb commented Jan 12, 2026

@ok2c Thanks for the explanation (meanwhile, I also got the issue and a solution as well). But what should I do if I have such a legacy issue and can neither fix it nor use a previous client version (because of some internal update policies)?

@ok2c
Copy link
Member Author

ok2c commented Jan 12, 2026

@plesingr-aeb One option is to turn off automatic content decompression. A better solution would be to introduce a custom exec interceptor that drops that silly header before the response gets processed by the standard execution pipeline.

@plesingr-aeb
Copy link

@ok2c Sounds good, thanks.

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.

3 participants