/** * Returns whether the {@link SessionProtocol#PROXY} is in the list of {@link SessionProtocol}s. */ public boolean hasProxyProtocol() { return hasProtocol(PROXY); }
/** * Returns whether the {@link SessionProtocol#HTTP}, {@link SessionProtocol#H1C} or * {@link SessionProtocol#H2C} is in the list of {@link SessionProtocol}s. */ public boolean hasHttp() { return hasProtocol(HTTP) || hasProtocol(H1C) || hasProtocol(H2C); }
/** * Returns whether the {@link SessionProtocol#HTTPS}, {@link SessionProtocol#H1} or * {@link SessionProtocol#H2} is in the list of {@link SessionProtocol}s. */ public boolean hasHttps() { return hasProtocol(HTTPS) || hasProtocol(H1) || hasProtocol(H2); }
private boolean hasSessionProtocol(SessionProtocol protocol) { final Server server = this.server.get(); return server != null && server.activePorts().values().stream() .anyMatch(port -> port.hasProtocol(protocol)); }
/** * Returns the port number of the {@link Server} for the specified {@link SessionProtocol}. * * @throws IllegalStateException if the {@link Server} is not started or it did not open a port of the * specified protocol. */ public int port(SessionProtocol protocol) { return server().activePorts().values().stream() .filter(p1 -> p1.hasProtocol(protocol)).findAny() .flatMap(p -> Optional.of(p.localAddress().getPort())) .orElseThrow(() -> new IllegalStateException(protocol + " port not open")); }