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

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

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:

      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

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

              Dates

              Created:
              Updated: