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

HttpClient: consider adding an HttpResponse::map method to map an HttpResponse<T> to an HttpResponse<U>

    Details

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

      Description

      We should consider to introduce a new AP method:

          `<U> HttpResponse<U> HttpResponse::map(Function<T,U> mapper);`

      This way we could also promote the following:

          HttpResponse<W> resp =
               client.sendAsync(req, BodySubscribers.ofInputStream())
                    .thenApplyAsync(r -> r.map(toJSON(W.class, r.body()))
                    .join();

      This would allow the caller to decide whether to performed the mapping in a synchronous or asynchronous dependent action, as well as allowing him to supply an executor if he so wishes.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated: