final AsyncContext async = baseRequest.startAsync(); async.setTimeout(requestTimeout); final boolean added = containerQueue.offer(new HttpRequestContainer(request, response, async));
public void handle(String s, Request request, HttpServletRequest req, final HttpServletResponse resp) throws IOException { resp.setContentType("text/plain;charset=utf-8"); resp.setStatus(200); final AsyncContext asyncContext = request.startAsync(); final PrintWriter writer = resp.getWriter(); executorService.submit(() -> { try { Thread.sleep(100); } catch (InterruptedException e) { logger.error("Failed to sleep for 100 ms.", e); } logger.info("Delivering part1."); writer.write("part1"); writer.flush(); }); executorService.submit(() -> { try { Thread.sleep(200); } catch (InterruptedException e) { logger.error("Failed to sleep for 200 ms.", e); } logger.info("Delivering part2."); writer.write("part2"); writer.flush(); asyncContext.complete(); }); request.setHandled(true); } };
@Override public void handle( String target, org.eclipse.jetty.server.Request baseRequest, HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException { final AsyncContext asyncContext = baseRequest.startAsync(); RequestMetadata metadata = extractMetadata(req); AsyncContextOngoingRequest ongoingRequest = new AsyncContextOngoingRequest(asApolloRequest(req), asyncContext, logger, metadata); asyncContext.setTimeout(requestTimeout.toMillis()); asyncContext.addListener(TimeoutListener.create(ongoingRequest)); requestHandler.handle(ongoingRequest); baseRequest.setHandled(true); }
final AsyncContext async = baseRequest.startAsync(); async.setTimeout(requestTimeout); final boolean added = containerQueue.offer(new HttpRequestContainer(request, response, async));
AsyncContext ctx = baseRequest.startAsync(); contexts.put(id, ctx);
LOG.debug("Threadlimited {} {}",remote,target); AsyncContext async = baseRequest.startAsync();
AsyncContext context = baseRequest.startAsync(); baseRequest.setAttribute(AHW_ATTR,ctype);
AsyncContext context = baseRequest.startAsync(); baseRequest.setAttribute(AHW_ATTR,ctype);
AsyncContext context = baseRequest.startAsync(); baseRequest.setAttribute(AHW_ATTR,ctype);