HTTP client API
michael.x.mcmahon at oracle.com
Wed Sep 7 17:15:51 UTC 2016
First, sorry for the delay in replying. We took your comments and
prototyped how the major ones
might be accommodated. In particular, we did the following:
- moved "business logic" out of HttpRequest. The methods for sending
exist in HttpClient. Given that requests are no longer associated
with a client and can
be sent through any client, this means that some properties of a
request that used
to be inherited from the client can no longer be visible in the
but that is not a problem as far as I can see. This changes the look
of the sample code
in HttpRequest, but doesn't make it any harder to read.
- changed some method names as suggested eg newBuilder()
- added protected constructors to the public classes. This allows
for use in mocking/test frameworks etc.
- changed the PUT, POST, GET methods in the request builder to only set
the method type.
PUT, POST takes the request body processor as parameter. A new
build() method returns
- added a method to HttpResponse which returns the "final" request that
was sent on the wire
for the particular response, which might be different from the user
I put an updated apidoc  and specdiff  up to show the changes. In
particular, the sample
code described in the HttpClient docs is updated to reflect the changes.
On 26/08/2016, 07:59, Wenbo Zhu wrote:
> Hi Michael,
> Thanks for the update! The adoption of the Flow API is indeed a big
> improvement (async flow-control is very hard to get right).
> Attached is a feedback doc on this new version. One specific idea to
> discuss is whether it's possible to release the new HTTP client API as
> a standalone library (that works on JDK 9).
> On Mon, Aug 22, 2016 at 12:56 AM, Michael McMahon
> <michael.x.mcmahon at oracle.com <mailto:michael.x.mcmahon at oracle.com>>
> There is an updated version of the HTTP client API doc  and a
> specdiff  showing the changes
> proposed from the current version in JDK9 dev.
> The main changes are:
> 1) The request and response processors are now based on
> Flow.Publisher and Flow.Subscriber
> 2) Response bodies are retrieved synchronously with the response
> headers as part of the
> HttpRequest.response() and responseAsync() methods
> 3) Because of the change above, to allow code to examine the
> headers and decide what to do
> with the body before retrieving it, there is a new entity
> called a HttpResponse.BodyHandler
> which is given the status code and headers, and which returns
> a HttpResponse.BodyProcessor.
> Static implementations of both body handlers and body
> processors are provided, to make the
> simple cases easy to code.
> We are currently working in the sandbox repository again and will
> have these changes
> in the main JDK9 dev forest soon.
>  http://cr.openjdk.java.net/~michaelm/httpclient/api/
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the net-dev