public class NonBlockingHttpHandlerSample extends Object
This example demonstrates the use of a HttpHandler to echo
HTTP POST data sent by the client, back to the client using
non-blocking streams introduced in Grizzly 2.0.
The is composed of two main parts (as nested classes of BlockingHttpHandlerSample)
HTTP based on the Grizzly HttpClientFilter.
The client uses a custom Filter on top
of the HttpClientFilter to send the POST and
read, and ultimately display, the response from the server. To
better demonstrate the callbacks defined by ReadHandler,
the client will send each data chunk two seconds apart.
HttpHandler is installed to the
HttpServer instance and associated
with the path /echo. The handler uses the NIOReader
returned by Request.getReader().
As data is received asynchronously, the ReadHandler callbacks are
invoked at this time data is then written to the response.
| Constructor and Description |
|---|
NonBlockingHttpHandlerSample() |
public static void main(String[] args)
Copyright © 2021 Oracle Corporation. All Rights Reserved.