Search in sources :

Example 1 with HttpProtocolConfig

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());
}
Also used : HttpServerBuilder(io.servicetalk.http.api.HttpServerBuilder) HttpProtocolConfig(io.servicetalk.http.api.HttpProtocolConfig) Test(org.junit.jupiter.api.Test)

Example 2 with HttpProtocolConfig

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());
        }
    }
}
Also used : HttpProtocolConfig(io.servicetalk.http.api.HttpProtocolConfig)

Aggregations

HttpProtocolConfig (io.servicetalk.http.api.HttpProtocolConfig)2 HttpServerBuilder (io.servicetalk.http.api.HttpServerBuilder)1 Test (org.junit.jupiter.api.Test)1