org.openqa.selenium.remote.http.HttpMethod#GET源码实例Demo

下面列出了org.openqa.selenium.remote.http.HttpMethod#GET 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: selenium   文件: AbstractHttpCommandCodec.java
@Override
public HttpRequest encode(Command command) {
  String name = aliases.getOrDefault(command.getName(), command.getName());
  CommandSpec spec = nameToSpec.get(name);
  if (spec == null) {
    throw new UnsupportedCommandException(command.getName());
  }
  Map<String, ?> parameters = amendParameters(command.getName(), command.getParameters());
  String uri = buildUri(name, command.getSessionId(), parameters, spec);

  HttpRequest request = new HttpRequest(spec.method, uri);

  if (HttpMethod.POST == spec.method) {

    String content = json.toJson(parameters);
    byte[] data = content.getBytes(UTF_8);

    request.setHeader(CONTENT_LENGTH, String.valueOf(data.length));
    request.setHeader(CONTENT_TYPE, JSON_UTF_8.toString());
    request.setContent(bytes(data));
  }

  if (HttpMethod.GET == spec.method) {
    request.setHeader(CACHE_CONTROL, "no-cache");
  }

  return request;
}
 
源代码2 项目: selenium   文件: ReverseProxyHandlerTest.java
@Test
public void shouldForwardRequestsToEndPoint() {
  HttpHandler handler = new ReverseProxyHandler(tracer, factory.createClient(server.url));
  HttpRequest req = new HttpRequest(HttpMethod.GET, "/ok");
  req.addHeader("X-Cheese", "Cake");
  handler.execute(req);

  // HTTP headers are case insensitive. This is how the HttpUrlConnection likes to encode things
  assertEquals("Cake", server.lastRequest.getHeader("x-cheese"));
}
 
源代码3 项目: selenium   文件: AbstractHttpCommandCodec.java
protected static CommandSpec get(String path) {
  return new CommandSpec(HttpMethod.GET, path);
}
 
源代码4 项目: java-client   文件: 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 AppiumCommandInfo getC(String url) {
    return new AppiumCommandInfo(url, HttpMethod.GET);
}
 
 同类方法