org.eclipse.jetty.server.Request.getAsyncContext()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(2.9k)|赞(0)|评价(0)|浏览(145)

本文整理了Java中org.eclipse.jetty.server.Request.getAsyncContext方法的一些代码示例,展示了Request.getAsyncContext的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getAsyncContext方法的具体详情如下:
包路径:org.eclipse.jetty.server.Request
类名称:Request
方法名:getAsyncContext

Request.getAsyncContext介绍

暂无

代码示例

代码示例来源:origin: jooby-project/jooby

@Override
protected void handshake(final Runnable handler) throws Exception {
 /** Infinite timeout because the continuation is never resumed but only completed on close. */
 req.getAsyncContext().setTimeout(0L);
 /** Server sent events headers. */
 rsp.setStatus(HttpServletResponse.SC_OK);
 rsp.setHeader("Connection", "Close");
 rsp.setContentType("text/event-stream; charset=utf-8");
 rsp.flushBuffer();
 HttpChannel channel = rsp.getHttpChannel();
 Connector connector = channel.getConnector();
 Executor executor = connector.getExecutor();
 executor.execute(handler);
}

代码示例来源:origin: stackoverflow.com

request.getAsyncContext().complete();

代码示例来源:origin: jenkinsci/winstone

public void complete (Session session, Request request)
{
  if (request.isAsyncStarted() && request.getDispatcherType() == DispatcherType.REQUEST)
  {
    request.getAsyncContext().addListener(new SessionAsyncListener(session));
  }
  else
  {
    complete(session);
  }
  //if dispatcher type is not async and not request, complete immediately (its a forward or an include)
  
  //else if dispatcher type is request and not async, complete immediately
  
  //else register an async callback completion listener that will complete the session
}

代码示例来源:origin: org.jooby/jooby-jetty

@Override
protected void handshake(final Runnable handler) throws Exception {
 /** Infinite timeout because the continuation is never resumed but only completed on close. */
 req.getAsyncContext().setTimeout(0L);
 /** Server sent events headers. */
 rsp.setStatus(HttpServletResponse.SC_OK);
 rsp.setHeader("Connection", "Close");
 rsp.setContentType("text/event-stream; charset=utf-8");
 rsp.flushBuffer();
 HttpChannel channel = rsp.getHttpChannel();
 Connector connector = channel.getConnector();
 Executor executor = connector.getExecutor();
 executor.execute(handler);
}

代码示例来源:origin: Nextdoor/bender

@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
{
  try
  {
    super.handle(target, baseRequest, request, response);
  }
  catch(Error|IOException|ServletException|RuntimeException e)
  {
    if (!response.isCommitted() && !baseRequest.getHttpChannelState().isAsync())
      response.setStatus(500);
    throw e;
  }
  finally
  {
    if (_requestLog != null && baseRequest.getDispatcherType().equals(DispatcherType.REQUEST))
    {
      if (baseRequest.getHttpChannelState().isAsync())
      {
        if (baseRequest.getHttpChannelState().isInitial())
          baseRequest.getAsyncContext().addListener(_listener);
      }
      else
        _requestLog.log(baseRequest, (Response)response);
    }
  }
}

代码示例来源:origin: Nextdoor/bender

if (!committed)
  LOG.warn("Could not send response error 500: "+x);
_request.getAsyncContext().complete();

相关文章

Request类方法