private void shutDown(HttpResponse res) { LOGGER.info("Shutdown command received"); Runnable initiateShutDown = new Runnable() { public void run() { LOGGER.info("initiating shutdown"); AsyncExecute.sleepTight(500); System.exit(0); } }; Thread isd = new Thread(initiateShutDown); isd.setName("initiateShutDown"); isd.start(); if (res != null) { try { res.getOutputStream().write("OK".getBytes()); res.commit(); } catch (IOException e) { throw new RuntimeException(e); } } }
public void handle(String pathInContext, String pathParams, HttpRequest req, HttpResponse resp) throws IOException { HTTPDecoupledClientInputStreamContext ctx = new HTTPDecoupledClientInputStreamContext(req); responseCallback.dispatch(ctx); resp.commit(); req.setHandled(true); } }
void serviceRequest(final HttpRequest req, final HttpResponse resp) throws IOException { try { if (LOG.isLoggable(Level.INFO)) { LOG.info("Service http request on thread: " + Thread.currentThread()); } HTTPServerInputStreamContext ctx = new HTTPServerInputStreamContext(this) { public void initContext() throws IOException { super.initContext(); inStream = req.getInputStream(); origInputStream = inStream; } }; BindingContextUtils.storeAsyncOnewayDispatch(ctx, true); ctx.put(HTTPServerInputStreamContext.HTTP_REQUEST, req); ctx.put(HTTPServerInputStreamContext.HTTP_RESPONSE, resp); ctx.initContext(); callback.dispatch(ctx, this); resp.commit(); req.setHandled(true); } finally { if (LOG.isLoggable(Level.INFO)) { LOG.info("Finished servicing http request on thread: " + Thread.currentThread()); } } }
protected void flushHeaders() throws IOException { if (response != null) { copyHeaders(context, response); response.setStatus(HttpURLConnection.HTTP_ACCEPTED, "Accepted"); response.commit(); request.setHandled(true); origOut.resetOut(new BufferedOutputStream(response.getOutputStream(), 1024)); } } }
response.commit(); } catch (IOException e) { e.printStackTrace();
response.commit();