Search in sources :

Example 1 with AbstractHttp11Protocol

use of org.apache.coyote.http11.AbstractHttp11Protocol in project spring-boot by spring-projects.

the class CompressionConnectorCustomizerTests method shouldCustomizeCompression.

@Test
void shouldCustomizeCompression() throws LifecycleException {
    CompressionConnectorCustomizer compressionConnectorCustomizer = new CompressionConnectorCustomizer(this.compression);
    Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
    Http2Protocol upgradeProtocol = new Http2Protocol();
    upgradeProtocol.setHttp11Protocol((AbstractHttp11Protocol<?>) connector.getProtocolHandler());
    connector.addUpgradeProtocol(upgradeProtocol);
    compressionConnectorCustomizer.customize(connector);
    AbstractHttp11Protocol<?> abstractHttp11Protocol = (AbstractHttp11Protocol<?>) connector.getProtocolHandler();
    compressionOn(abstractHttp11Protocol.getCompression());
    minSize(abstractHttp11Protocol.getCompressionMinSize());
    mimeType(abstractHttp11Protocol.getCompressibleMimeTypes());
    excludedUserAgents(abstractHttp11Protocol.getNoCompressionUserAgents());
}
Also used : Connector(org.apache.catalina.connector.Connector) AbstractHttp11Protocol(org.apache.coyote.http11.AbstractHttp11Protocol) Http2Protocol(org.apache.coyote.http2.Http2Protocol) Test(org.junit.jupiter.api.Test)

Example 2 with AbstractHttp11Protocol

use of org.apache.coyote.http11.AbstractHttp11Protocol in project spring-boot by spring-projects.

the class TomcatWebServerFactoryCustomizer method customizeMaxKeepAliveRequests.

private void customizeMaxKeepAliveRequests(ConfigurableTomcatWebServerFactory factory, int maxKeepAliveRequests) {
    factory.addConnectorCustomizers((connector) -> {
        ProtocolHandler handler = connector.getProtocolHandler();
        if (handler instanceof AbstractHttp11Protocol) {
            AbstractHttp11Protocol<?> protocol = (AbstractHttp11Protocol<?>) handler;
            protocol.setMaxKeepAliveRequests(maxKeepAliveRequests);
        }
    });
}
Also used : ProtocolHandler(org.apache.coyote.ProtocolHandler) AbstractHttp11Protocol(org.apache.coyote.http11.AbstractHttp11Protocol)

Example 3 with AbstractHttp11Protocol

use of org.apache.coyote.http11.AbstractHttp11Protocol in project spring-boot by spring-projects.

the class TomcatWebServerFactoryCustomizer method customizeMaxSwallowSize.

private void customizeMaxSwallowSize(ConfigurableTomcatWebServerFactory factory, int maxSwallowSize) {
    factory.addConnectorCustomizers((connector) -> {
        ProtocolHandler handler = connector.getProtocolHandler();
        if (handler instanceof AbstractHttp11Protocol) {
            AbstractHttp11Protocol<?> protocol = (AbstractHttp11Protocol<?>) handler;
            protocol.setMaxSwallowSize(maxSwallowSize);
        }
    });
}
Also used : ProtocolHandler(org.apache.coyote.ProtocolHandler) AbstractHttp11Protocol(org.apache.coyote.http11.AbstractHttp11Protocol)

Example 4 with AbstractHttp11Protocol

use of org.apache.coyote.http11.AbstractHttp11Protocol in project spring-boot by spring-projects.

the class TomcatWebServerFactoryCustomizer method customizeMaxHttpHeaderSize.

@SuppressWarnings("rawtypes")
private void customizeMaxHttpHeaderSize(ConfigurableTomcatWebServerFactory factory, int maxHttpHeaderSize) {
    factory.addConnectorCustomizers((connector) -> {
        ProtocolHandler handler = connector.getProtocolHandler();
        if (handler instanceof AbstractHttp11Protocol) {
            AbstractHttp11Protocol protocol = (AbstractHttp11Protocol) handler;
            protocol.setMaxHttpHeaderSize(maxHttpHeaderSize);
        }
    });
}
Also used : ProtocolHandler(org.apache.coyote.ProtocolHandler) AbstractHttp11Protocol(org.apache.coyote.http11.AbstractHttp11Protocol)

Example 5 with AbstractHttp11Protocol

use of org.apache.coyote.http11.AbstractHttp11Protocol in project spring-boot by spring-projects.

the class TomcatWebServerFactoryCustomizer method customizeRejectIllegalHeader.

private void customizeRejectIllegalHeader(ConfigurableTomcatWebServerFactory factory, boolean rejectIllegalHeader) {
    factory.addConnectorCustomizers((connector) -> {
        ProtocolHandler handler = connector.getProtocolHandler();
        if (handler instanceof AbstractHttp11Protocol) {
            AbstractHttp11Protocol<?> protocol = (AbstractHttp11Protocol<?>) handler;
            protocol.setRejectIllegalHeader(rejectIllegalHeader);
        }
    });
}
Also used : ProtocolHandler(org.apache.coyote.ProtocolHandler) AbstractHttp11Protocol(org.apache.coyote.http11.AbstractHttp11Protocol)

Aggregations

AbstractHttp11Protocol (org.apache.coyote.http11.AbstractHttp11Protocol)16 ProtocolHandler (org.apache.coyote.ProtocolHandler)7 ByteBuffer (java.nio.ByteBuffer)5 Connector (org.apache.catalina.connector.Connector)4 TomcatConnectorCustomizer (org.springframework.boot.context.embedded.tomcat.TomcatConnectorCustomizer)3 TomcatEmbeddedServletContainerFactory (org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory)3 Bean (org.springframework.context.annotation.Bean)3 IOException (java.io.IOException)2 SpringApplication (org.springframework.boot.SpringApplication)2 SpringBootApplication (org.springframework.boot.autoconfigure.SpringBootApplication)2 MultipartConfigElement (jakarta.servlet.MultipartConfigElement)1 ServletContext (jakarta.servlet.ServletContext)1 ServletException (jakarta.servlet.ServletException)1 Dynamic (jakarta.servlet.ServletRegistration.Dynamic)1 HttpServlet (jakarta.servlet.http.HttpServlet)1 HttpServletRequest (jakarta.servlet.http.HttpServletRequest)1 HttpServletResponse (jakarta.servlet.http.HttpServletResponse)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 SocketException (java.net.SocketException)1