Java Code Examples for org.openqa.selenium.remote.http.HttpRequest#getMethod()

The following examples show how to use org.openqa.selenium.remote.http.HttpRequest#getMethod() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocalNode.java    From selenium with Apache License 2.0 6 votes vote down vote up
@Override
public HttpResponse executeWebDriverCommand(HttpRequest req) {
  // True enough to be good enough
  SessionId id = getSessionId(req.getUri()).map(SessionId::new)
    .orElseThrow(() -> new NoSuchSessionException("Cannot find session: " + req));

  SessionSlot slot = currentSessions.getIfPresent(id);
  if (slot == null) {
    throw new NoSuchSessionException("Cannot find session with id: " + id);
  }

  HttpResponse toReturn = slot.execute(req);
  if (req.getMethod() == DELETE && req.getUri().equals("/session/" + id)) {
    stop(id);
  }
  return toReturn;
}
 
Example 2
Source File: ProtocolConvertingSession.java    From selenium with Apache License 2.0 5 votes vote down vote up
@Override
public HttpResponse execute(HttpRequest req) {
  String host = "host";
  StreamSupport.stream(req.getHeaderNames().spliterator(), true)
    .filter(host::equalsIgnoreCase)
    .collect(Collectors.toList())
    .forEach(req::removeHeader);
  req.addHeader(host, String.format("%s:%s", getUri().getHost(), getUri().getPort()));
  HttpResponse res = handler.execute(req);
  if (req.getMethod() == DELETE && killUrl.equals(req.getUri())) {
    stop();
  }
  return res;
}
 
Example 3
Source File: ResourceHandler.java    From selenium with Apache License 2.0 4 votes vote down vote up
@Override
public boolean matches(HttpRequest req) {
  return GET == req.getMethod() && resource.get(req.getUri()).isPresent();
}
 
Example 4
Source File: WebDriverBackedSeleniumHandler.java    From selenium with Apache License 2.0 4 votes vote down vote up
@Override
public boolean matches(HttpRequest req) {
  return req.getMethod() == POST &&
         ("/selenium-server/driver/".equals(req.getUri()) ||
          "/selenium-server/driver".equals(req.getUri()));
}