Java 类org.openqa.selenium.remote.http.HttpMethod 实例源码

项目:grid-refactor-remote-server    文件:DriverServlet.java   
private void handleCrossDomainRpc(
    HttpServletRequest servletRequest, HttpServletResponse servletResponse)
    throws ServletException, IOException {
  CrossDomainRpc rpc;

  try {
    rpc = new CrossDomainRpcLoader().loadRpc(servletRequest);
  } catch (IllegalArgumentException e) {
    servletResponse.setStatus(HttpServletResponse.SC_BAD_REQUEST);
    servletResponse.getOutputStream().println(e.getMessage());
    servletResponse.getOutputStream().flush();
    return;
  }

  HttpRequest request = new HttpRequest(
      HttpMethod.valueOf(rpc.getMethod()),
      rpc.getPath());
  request.setHeader(HttpHeaders.CONTENT_TYPE, MediaType.JSON_UTF_8.toString());
  request.setContent(rpc.getContent());

  HttpResponse response = commandHandler.handleRequest(request);
  sendResponse(response, servletResponse);
}
项目:grid-refactor-remote-server    文件:DriverServlet.java   
private static HttpRequest createInternalRequest(HttpServletRequest servletRequest)
    throws IOException {
  String path = servletRequest.getPathInfo();
  if (Strings.isNullOrEmpty(path)) {
    path = "/";
  }
  HttpRequest request = new HttpRequest(
      HttpMethod.valueOf(servletRequest.getMethod().toUpperCase()),
      path);

  @SuppressWarnings("unchecked")
  Enumeration<String> headerNames = servletRequest.getHeaderNames();
  for (String name : list(headerNames)) {
    @SuppressWarnings("unchecked")
    Enumeration<String> headerValues = servletRequest.getHeaders(name);
    for (String value : list(headerValues)) {
      request.setHeader(name, value);
    }
  }

  InputStream stream = null;
  try {
    stream = servletRequest.getInputStream();
    request.setContent(ByteStreams.toByteArray(stream));
  } finally {
    if (stream != null) {
      try {
        stream.close();
      } catch (IOException ignored) {
        // Do nothing.
      }
    }
  }

  return request;
}
项目:selendroid    文件:SelendroidCommandExecutor.java   
private static CommandInfo newVendorCommand(String path, HttpMethod method) {
  return new CommandInfo(VENDOR_PREFIX + path, method);
}
项目:menggeqa    文件:MobileCommand.java   
/**
 * This methods forms GET commands.
 *
 * @param url is the command URL
 * @return an instance of {@link org.openqa.selenium.remote.CommandInfo}
 */
public static CommandInfo getC(String url) {
    return new CommandInfo(url, HttpMethod.GET);
}
项目:menggeqa    文件:MobileCommand.java   
/**
 * This methods forms POST commands.
 *
 * @param url is the command URL
 * @return an instance of {@link org.openqa.selenium.remote.CommandInfo}
 */
public static CommandInfo postC(String url) {
    return new CommandInfo(url, HttpMethod.POST);
}
项目:menggeqa    文件:MobileCommand.java   
/**
 * This methods forms DELETE commands.
 *
 * @param url is the command URL
 * @return an instance of {@link org.openqa.selenium.remote.CommandInfo}
 */
public static CommandInfo deleteC(String url) {
    return new CommandInfo(url, HttpMethod.DELETE);
}