Search in sources :

Example 6 with Http2

use of org.springframework.boot.web.server.Http2 in project spring-boot by spring-projects.

the class AbstractReactiveWebServerFactoryTests method whenHttp2IsEnabledAndSslIsDisabledThenHttp11CanStillBeUsed.

@Test
protected void whenHttp2IsEnabledAndSslIsDisabledThenHttp11CanStillBeUsed() throws InterruptedException, ExecutionException, IOException {
    AbstractReactiveWebServerFactory factory = getFactory();
    Http2 http2 = new Http2();
    http2.setEnabled(true);
    factory.setHttp2(http2);
    this.webServer = factory.getWebServer(new EchoHandler());
    this.webServer.start();
    Mono<String> result = getWebClient(this.webServer.getPort()).build().post().uri("/test").contentType(MediaType.TEXT_PLAIN).body(BodyInserters.fromValue("Hello World")).retrieve().bodyToMono(String.class);
    assertThat(result.block(Duration.ofSeconds(30))).isEqualTo("Hello World");
}
Also used : Http2(org.springframework.boot.web.server.Http2) Test(org.junit.jupiter.api.Test)

Example 7 with Http2

use of org.springframework.boot.web.server.Http2 in project spring-boot by spring-projects.

the class SslServerCustomizerTests method whenHttp2IsEnabledServerConnectorsHasSslAlpnH2AndHttpConnectionFactories.

@Test
@SuppressWarnings("rawtypes")
void whenHttp2IsEnabledServerConnectorsHasSslAlpnH2AndHttpConnectionFactories() {
    Http2 http2 = new Http2();
    http2.setEnabled(true);
    Server server = createCustomizedServer(http2);
    assertThat(server.getConnectors()).hasSize(1);
    List<ConnectionFactory> factories = new ArrayList<>(server.getConnectors()[0].getConnectionFactories());
    assertThat(factories).extracting((factory) -> (Class) factory.getClass()).containsExactly(SslConnectionFactory.class, ALPNServerConnectionFactory.class, HTTP2ServerConnectionFactory.class, HttpConnectionFactory.class);
}
Also used : HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) SslConnectionFactory(org.eclipse.jetty.server.SslConnectionFactory) ALPNServerConnectionFactory(org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory) SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) WebServerException(org.springframework.boot.web.server.WebServerException) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Http2(org.springframework.boot.web.server.Http2) ConnectionFactory(org.eclipse.jetty.server.ConnectionFactory) InetSocketAddress(java.net.InetSocketAddress) Ssl(org.springframework.boot.web.server.Ssl) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test) List(java.util.List) HTTP2ServerConnectionFactory(org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory) Assertions.assertThatExceptionOfType(org.assertj.core.api.Assertions.assertThatExceptionOfType) Server(org.eclipse.jetty.server.Server) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) SslConnectionFactory(org.eclipse.jetty.server.SslConnectionFactory) ALPNServerConnectionFactory(org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory) ConnectionFactory(org.eclipse.jetty.server.ConnectionFactory) HTTP2ServerConnectionFactory(org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory) Server(org.eclipse.jetty.server.Server) Http2(org.springframework.boot.web.server.Http2) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Aggregations

Http2 (org.springframework.boot.web.server.Http2)7 Test (org.junit.jupiter.api.Test)6 ArrayList (java.util.ArrayList)2 ALPNServerConnectionFactory (org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory)2 ContentResponse (org.eclipse.jetty.client.api.ContentResponse)2 HTTP2Client (org.eclipse.jetty.http2.client.HTTP2Client)2 HttpClientTransportOverHTTP2 (org.eclipse.jetty.http2.client.http.HttpClientTransportOverHTTP2)2 HTTP2ServerConnectionFactory (org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory)2 ConnectionFactory (org.eclipse.jetty.server.ConnectionFactory)2 HttpConnectionFactory (org.eclipse.jetty.server.HttpConnectionFactory)2 Server (org.eclipse.jetty.server.Server)2 SslConnectionFactory (org.eclipse.jetty.server.SslConnectionFactory)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 Ssl (org.springframework.boot.web.server.Ssl)2 Builder (io.undertow.Undertow.Builder)1 InetAddress (java.net.InetAddress)1 InetSocketAddress (java.net.InetSocketAddress)1 List (java.util.List)1 HttpClient (org.apache.http.client.HttpClient)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1