Details
-
Enhancement
-
Resolution: Unresolved
-
P3
-
None
-
None
Description
The HttpClient provides a BodyHandlers.ofInputStream method that can be used to read a response body as an InputStream.
However there is no easy way to transform that InputStream into a Reader, even though that is quite a common thing to do.
The HttpClient has all the internal logic to retrieve a Charset from the response headers but that is not exposed; this makes it difficult to figure out which charset should be used when creating the reader.
Adding a convenience method to HttpHeaders to retrieve the charset from the Content-Type, or a BodyHandlers method that could be used to read the body from a Reader should be investigated.
See https://mail.openjdk.java.net/pipermail/net-dev/2020-November/014794.html
However there is no easy way to transform that InputStream into a Reader, even though that is quite a common thing to do.
The HttpClient has all the internal logic to retrieve a Charset from the response headers but that is not exposed; this makes it difficult to figure out which charset should be used when creating the reader.
Adding a convenience method to HttpHeaders to retrieve the charset from the Content-Type, or a BodyHandlers method that could be used to read the body from a Reader should be investigated.
See https://mail.openjdk.java.net/pipermail/net-dev/2020-November/014794.html