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

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

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

Request.setHandled介绍

暂无

代码示例

代码示例来源:origin: perwendel/spark

@Override
public void doHandle(
    String target,
    Request baseRequest,
    HttpServletRequest request,
    HttpServletResponse response) throws IOException, ServletException {
  HttpRequestWrapper wrapper = new HttpRequestWrapper(request);
  filter.doFilter(wrapper, response, null);
  if (wrapper.notConsumed()) {
    baseRequest.setHandled(false);
  } else {
    baseRequest.setHandled(true);
  }
}

代码示例来源:origin: gocd/gocd

private void respondWith503(Request baseRequest, HttpServletResponse response, String contentType, String body) throws IOException {
  addHeaders(response);
  response.setStatus(org.eclipse.jetty.http.HttpStatus.SERVICE_UNAVAILABLE_503);
  response.setContentType(contentType);
  response.getWriter().println(body);
  baseRequest.setHandled(true);
}

代码示例来源:origin: apache/incubator-gobblin

@Override
 public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
   throws IOException, ServletException {
  if (request.getRequestURI().equals("/js/settings.js")) {
   response.setContentType("application/javascript");
   response.setStatus(HttpServletResponse.SC_OK);
   response.getWriter().println(String.format(responseTemplate, AdminWebServer.this.restServerUri.toString(),
     AdminWebServer.this.hideJobsWithoutTasksByDefault, AdminWebServer.this.refreshInterval));
   baseRequest.setHandled(true);
  }
 }
};

代码示例来源:origin: jphp-group/jphp

@Signature
  public void end() {
    request.setHandled(true);
  }
}

代码示例来源:origin: kilim/kilim

public void execute() throws Pausable, Exception {
    try {
      String result = handler.handle(target,br,req,resp);
      if (result != null) resp.getOutputStream().print(result);
    }
    catch (Exception ex) { resp.sendError(500,"the server encountered an error"); }
    br.setHandled(true);
    async.complete();
  }
}.start();

代码示例来源:origin: stagemonitor/stagemonitor

@Override
  public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    baseRequest.setHandled(true);
    response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
  }
});

代码示例来源:origin: AsyncHttpClient/async-http-client

public void handle(String s, Request request, HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
  if (!req.getMethod().equalsIgnoreCase("PUT")) {
   resp.setStatus(HttpServletResponse.SC_OK);
  } else {
   resp.setStatus(204);
  }
  request.setHandled(true);
 }
}

代码示例来源:origin: AsyncHttpClient/async-http-client

public void handle(String s, org.eclipse.jetty.server.Request r, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
  if ("HEAD".equalsIgnoreCase(request.getMethod())) {
   response.setStatus(HttpServletResponse.SC_FOUND); // 302
   response.setHeader("Location", request.getPathInfo() + "_moved");
  } else if ("GET".equalsIgnoreCase(request.getMethod())) {
   response.setStatus(HttpServletResponse.SC_OK);
  } else {
   response.setStatus(HttpServletResponse.SC_FORBIDDEN);
  }
  r.setHandled(true);
 }
}

代码示例来源:origin: AsyncHttpClient/async-http-client

public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException {
  InputStream is = baseRequest.getInputStream();
  int read;
  do {
   // drain upload
   read = is.read();
  } while (read >= 0);
  response.setStatus(200);
  response.getOutputStream().flush();
  response.getOutputStream().close();
  baseRequest.setHandled(true);
 }
};

代码示例来源:origin: apache/nifi

@Override
  public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    baseRequest.setHandled(true);
    dateString = request.getHeader("Date");
    response.setStatus(200);
    response.setContentType("text/plain");
    response.getWriter().println("Way to go!");
  }
}

代码示例来源:origin: SonarSource/sonarqube

@Override
 public void handle(String target, Request request, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException {
  if ("/ping".equals(target)) {
   request.setHandled(true);
   httpServletResponse.getWriter().print("ping");
  } else if ("/restart".equals(target)) {
   writeTimeToFile("restartAskedAt");
   request.setHandled(true);
   processCommands.askForRestart();
   httpServletResponse.getWriter().print("ok");
  } else if ("/kill".equals(target)) {
   writeTimeToFile("killedAt");
   System.exit(0);
  }
 }
});

代码示例来源:origin: AsyncHttpClient/async-http-client

public void handle(String s, org.eclipse.jetty.server.Request r, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
  if ("GET".equalsIgnoreCase(request.getMethod())) {
   response.addHeader("target", r.getHttpURI().getPath());
   response.setStatus(HttpServletResponse.SC_OK);
  } else {
   // this handler is to handle POST request
   response.sendError(HttpServletResponse.SC_FORBIDDEN);
  }
  r.setHandled(true);
 }
}

代码示例来源:origin: AsyncHttpClient/async-http-client

public void handle(String target, Request baseRequest, HttpServletRequest req, HttpServletResponse resp) throws IOException {
  ServletInputStream in = req.getInputStream();
  byte[] b = new byte[8192];
  int count;
  int total = 0;
  while ((count = in.read(b)) != -1) {
   b = new byte[8192];
   total += count;
  }
  resp.setStatus(200);
  resp.addHeader("X-TRANSFERRED", String.valueOf(total));
  resp.getOutputStream().flush();
  resp.getOutputStream().close();
  baseRequest.setHandled(true);
 }
};

代码示例来源:origin: AsyncHttpClient/async-http-client

public void handle(String target, Request baseRequest, HttpServletRequest req, HttpServletResponse resp) throws IOException {
  ServletInputStream in = req.getInputStream();
  byte[] b = new byte[8192];
  int count;
  int total = 0;
  while ((count = in.read(b)) != -1) {
   b = new byte[8192];
   total += count;
  }
  resp.setStatus(200);
  resp.addHeader("X-TRANFERED", String.valueOf(total));
  resp.getOutputStream().flush();
  resp.getOutputStream().close();
  baseRequest.setHandled(true);
 }
};

代码示例来源:origin: stagemonitor/stagemonitor

@Override
  public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    baseRequest.setHandled(true);
    assertEquals("Basic dXNlcjpwYXNz", request.getHeader("Authorization"));
    assertThat(request.getQueryString()).isEqualTo("bar=baz");
    handled[0] = true;
  }
});

代码示例来源:origin: AsyncHttpClient/async-http-client

public void handle(String s, Request r, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
  if ("GET".equalsIgnoreCase(request.getMethod())) {
   String qs = request.getQueryString();
   if (isNonEmpty(qs)) {
    for (String qnv : qs.split("&")) {
     String nv[] = qnv.split("=");
     response.addHeader(nv[0], nv[1]);
    }
    response.setStatus(HttpServletResponse.SC_OK);
   } else {
    response.sendError(HttpServletResponse.SC_NOT_ACCEPTABLE);
   }
  } else { // this handler is to handle POST request
   response.sendError(HttpServletResponse.SC_FORBIDDEN);
  }
  r.setHandled(true);
 }
}

代码示例来源:origin: AsyncHttpClient/async-http-client

public void handle(String target, Request baseRequest, HttpServletRequest request, final HttpServletResponse response)
     throws IOException, ServletException {
  response.setStatus(HttpServletResponse.SC_OK);
  final AsyncContext asyncContext = request.startAsync();
  new Thread(() -> {
   try {
    Thread.sleep(SLEEPTIME_MS);
    response.getOutputStream().print(MSG);
    response.getOutputStream().flush();
    asyncContext.complete();
   } catch (InterruptedException | IOException e) {
    logger.error(e.getMessage(), e);
   }
  }).start();
  baseRequest.setHandled(true);
 }
}

代码示例来源:origin: graphql-java/graphql-java

@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
  boolean handled = false;
  if ("/graphql".equals(target)) {
    handleStarWars(request, response);
    handled = true;
  } else if (target.startsWith("/executionresult")) {
    new ExecutionResultJSONTesting(target, response);
    handled = true;
  }
  if (handled) {
    baseRequest.setHandled(true);
  }
}

代码示例来源:origin: stagemonitor/stagemonitor

@Override
  public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    IOUtils.copy(IOUtils.getResourceAsStream("wsdl.xml"), response.getOutputStream());
    baseRequest.setHandled(true);
  }
});

代码示例来源:origin: neo4j/neo4j

@Override
public void handle(
    String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response )
    throws IOException
{
  response.setContentType( "text/plain; charset=utf-8" );
  response.setStatus( HttpServletResponse.SC_OK );
  PrintWriter out = response.getWriter();
  writeBatch( out, firstBatchSize );
  out.flush();
  latch.start();
  innerBarrier.reached();
  latch.finish();
  writeBatch( out, otherBatchSize );
  baseRequest.setHandled(true);
}

相关文章

Request类方法