I have a Java application that runs on top of the Grizzly web server. I am already calling Response.suspend()and running the request in the background thread. It works a lot. Here is a sample code.
import org.glassfish.grizzly.http.server.Request;
import org.glassfish.grizzly.http.server.Response;
class Handler extends org.glassfish.grizzly.http.server.HttpHandler
{
@Override
public void service(Request request, Response response)
{
response.suspend();
}
private static void execute(Request request, Response response)
{
response.setStatus(200);
response.resume();
}
}
For one type of request, processing may take some time. I would like to periodically send the HTTP status code 102 Processingback to the client so that the client does not time out. How should I do it? I understand that I may have to complete a periodic scheduled task to send 102 Processing. It's not a problem. How do I interact with an object Response?
. HTTP 102. , , IllegalStateException, Response.isCommitted() .
response.setStatus(102, "Processing");
response.
getOutputBuffer().
acknowledge();