Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8256153

HttpClient: investigate conveniences to help read the response body from a Reader

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Unresolved
    • P3
    • None
    • None
    • core-libs

    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

      Attachments

        Activity

          People

            dfuchs Daniel Fuchs
            dfuchs Daniel Fuchs
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: