I am using Apache HTTP Components to send a POST request to a server that is not owned by me (therefore I cannot modify its configuration).
The server, in response back to me, sets Content-Encoding: none
header which causes the org.apache.http.HttpException: Unsupported Content-Coding: none
exception.
I found somewhere on StackOverflow that I can use HttpClients.custom().disableContentCompression().build()
to disable RequestAcceptEncoding
and ResponseContentEncoding
interceptors, therefore making the exception not to be thrown. However, I do not want to reconfigure my HttpClient
in that way globally.
Is there any workaround of this issue without adding changes to HttpClient
?
As a note, I do not have to read response body at all, as it's empty. I just need to be able to read response code (ie. 200 OK
).
Thank you for your time.
Finally after months I found the solution for this problem!
There is a workaround with using interceptors to fix the bad Content-Encoding header, see this blog entry.