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>

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • None
    • core-libs

      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.

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

              Created:
              Updated: