use of io.servicetalk.http.api.HttpProtocolConfig in project servicetalk by apple.
the class HttpProtocolConfigTest method serverWithEmptyProtocolConfig.
@Test
void serverWithEmptyProtocolConfig() {
HttpServerBuilder builder = HttpServers.forAddress(localAddress(0));
Exception e = assertThrows(IllegalArgumentException.class, () -> builder.protocols(new HttpProtocolConfig[0]));
assertEquals("No protocols specified", e.getMessage());
}
use of io.servicetalk.http.api.HttpProtocolConfig in project servicetalk by apple.
the class HttpConfig method protocols.
void protocols(final HttpProtocolConfig... protocols) {
requireNonNull(protocols);
if (protocols.length < 1) {
throw new IllegalArgumentException("No protocols specified");
}
h1Config = null;
h2Config = null;
for (HttpProtocolConfig protocol : protocols) {
if (protocol instanceof H1ProtocolConfig) {
h1Config((H1ProtocolConfig) protocol);
} else if (protocol instanceof H2ProtocolConfig) {
h2Config((H2ProtocolConfig) protocol);
} else {
throw new IllegalArgumentException("Unsupported HttpProtocolConfig: " + protocol.getClass().getName() + ", see " + HttpProtocolConfigs.class.getName());
}
}
}
Aggregations