Class NonBlockingHttpHandlerSample

java.lang.Object
org.glassfish.grizzly.samples.httpserver.nonblockinghandler.NonBlockingHttpHandlerSample

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)

  • Client: This is a simple 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.
  • NoneBlockingEchoHandler: This 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 Details

    • NonBlockingHttpHandlerSample

      public NonBlockingHttpHandlerSample()
  • Method Details

    • main

      public static void main(String[] args)