use of org.springframework.boot.web.server.Http2 in project spring-boot by spring-projects.
the class SslServerCustomizerTests method alpnConnectionFactoryHasNullDefaultProtocolToAllowNegotiationToHttp11.
@Test
void alpnConnectionFactoryHasNullDefaultProtocolToAllowNegotiationToHttp11() {
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(((ALPNServerConnectionFactory) factories.get(1)).getDefaultProtocol()).isNull();
}
use of org.springframework.boot.web.server.Http2 in project spring-boot by spring-projects.
the class AbstractServletWebServerFactoryTests method whenHttp2IsEnabledAndSslIsDisabledThenHttp11CanStillBeUsed.
@Test
protected void whenHttp2IsEnabledAndSslIsDisabledThenHttp11CanStillBeUsed() throws InterruptedException, ExecutionException, IOException, URISyntaxException {
AbstractServletWebServerFactory factory = getFactory();
Http2 http2 = new Http2();
http2.setEnabled(true);
factory.setHttp2(http2);
this.webServer = factory.getWebServer(exampleServletRegistration());
this.webServer.start();
assertThat(getResponse("http://localhost:" + this.webServer.getPort() + "/hello")).isEqualTo("Hello World");
}
use of org.springframework.boot.web.server.Http2 in project spring-boot by spring-projects.
the class AbstractReactiveWebServerFactoryTests method whenHttp2IsEnabledAndSslIsDisabledThenH2cCanBeUsed.
@Test
protected void whenHttp2IsEnabledAndSslIsDisabledThenH2cCanBeUsed() throws Exception {
AbstractReactiveWebServerFactory factory = getFactory();
Http2 http2 = new Http2();
http2.setEnabled(true);
factory.setHttp2(http2);
this.webServer = factory.getWebServer(new EchoHandler());
this.webServer.start();
org.eclipse.jetty.client.HttpClient client = new org.eclipse.jetty.client.HttpClient(new HttpClientTransportOverHTTP2(new HTTP2Client()));
client.start();
try {
ContentResponse response = client.POST("http://localhost:" + this.webServer.getPort()).body(new StringRequestContent("text/plain", "Hello World")).send();
assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
assertThat(response.getContentAsString()).isEqualTo("Hello World");
} finally {
client.stop();
}
}
use of org.springframework.boot.web.server.Http2 in project spring-boot by spring-projects.
the class UndertowWebServerFactoryDelegate method createBuilder.
Builder createBuilder(AbstractConfigurableWebServerFactory factory) {
Ssl ssl = factory.getSsl();
InetAddress address = factory.getAddress();
int port = factory.getPort();
Builder builder = Undertow.builder();
if (this.bufferSize != null) {
builder.setBufferSize(this.bufferSize);
}
if (this.ioThreads != null) {
builder.setIoThreads(this.ioThreads);
}
if (this.workerThreads != null) {
builder.setWorkerThreads(this.workerThreads);
}
if (this.directBuffers != null) {
builder.setDirectBuffers(this.directBuffers);
}
Http2 http2 = factory.getHttp2();
if (http2 != null) {
builder.setServerOption(UndertowOptions.ENABLE_HTTP2, http2.isEnabled());
}
if (ssl != null && ssl.isEnabled()) {
new SslBuilderCustomizer(factory.getPort(), address, ssl, factory.getSslStoreProvider()).customize(builder);
} else {
builder.addHttpListener(port, (address != null) ? address.getHostAddress() : "0.0.0.0");
}
builder.setServerOption(UndertowOptions.SHUTDOWN_TIMEOUT, 0);
for (UndertowBuilderCustomizer customizer : this.builderCustomizers) {
customizer.customize(builder);
}
return builder;
}
use of org.springframework.boot.web.server.Http2 in project spring-boot by spring-projects.
the class AbstractServletWebServerFactoryTests method whenHttp2IsEnabledAndSslIsDisabledThenH2cCanBeUsed.
@Test
protected void whenHttp2IsEnabledAndSslIsDisabledThenH2cCanBeUsed() throws Exception {
AbstractServletWebServerFactory factory = getFactory();
Http2 http2 = new Http2();
http2.setEnabled(true);
factory.setHttp2(http2);
this.webServer = factory.getWebServer(exampleServletRegistration());
this.webServer.start();
org.eclipse.jetty.client.HttpClient client = new org.eclipse.jetty.client.HttpClient(new HttpClientTransportOverHTTP2(new HTTP2Client()));
client.start();
try {
ContentResponse response = client.GET("http://localhost:" + this.webServer.getPort() + "/hello");
assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
assertThat(response.getContentAsString()).isEqualTo("Hello World");
} finally {
client.stop();
}
}
Aggregations