Search in sources :

Example 11 with ProtocolHandler

use of org.apache.coyote.ProtocolHandler 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 12 with ProtocolHandler

use of org.apache.coyote.ProtocolHandler 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 13 with ProtocolHandler

use of org.apache.coyote.ProtocolHandler 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)

Example 14 with ProtocolHandler

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

the class TomcatWebServerFactoryCustomizer method customizeAcceptCount.

private void customizeAcceptCount(ConfigurableTomcatWebServerFactory factory, int acceptCount) {
    factory.addConnectorCustomizers((connector) -> {
        ProtocolHandler handler = connector.getProtocolHandler();
        if (handler instanceof AbstractProtocol) {
            AbstractProtocol<?> protocol = (AbstractProtocol<?>) handler;
            protocol.setAcceptCount(acceptCount);
        }
    });
}
Also used : ProtocolHandler(org.apache.coyote.ProtocolHandler) AbstractProtocol(org.apache.coyote.AbstractProtocol)

Example 15 with ProtocolHandler

use of org.apache.coyote.ProtocolHandler in project tomcat by apache.

the class TestCustomSsl method doTestCustomTrustManager.

private void doTestCustomTrustManager(boolean serverTrustAll) throws Exception {
    Tomcat tomcat = getTomcatInstance();
    Assume.assumeTrue("SSL renegotiation has to be supported for this test", TesterSupport.isRenegotiationSupported(getTomcatInstance()));
    TesterSupport.configureClientCertContext(tomcat);
    // Override the defaults
    ProtocolHandler handler = tomcat.getConnector().getProtocolHandler();
    if (handler instanceof AbstractHttp11JsseProtocol) {
        ((AbstractHttp11JsseProtocol<?>) handler).setTruststoreFile(null);
    } else {
        // Unexpected
        fail("Unexpected handler type");
    }
    if (serverTrustAll) {
        tomcat.getConnector().setAttribute("trustManagerClassName", "org.apache.tomcat.util.net.TesterSupport$TrustAllCerts");
    }
    // Start Tomcat
    tomcat.start();
    TesterSupport.configureClientSsl();
    // Unprotected resource
    ByteChunk res = getUrl("https://localhost:" + getPort() + "/unprotected");
    assertEquals("OK", res.toString());
    // Protected resource
    res.recycle();
    int rc = -1;
    try {
        rc = getUrl("https://localhost:" + getPort() + "/protected", res, null, null);
    } catch (SocketException se) {
        if (serverTrustAll) {
            fail(se.getMessage());
            se.printStackTrace();
        }
    } catch (SSLException he) {
        if (serverTrustAll) {
            fail(he.getMessage());
            he.printStackTrace();
        }
    }
    if (serverTrustAll) {
        assertEquals(200, rc);
        assertEquals("OK-" + TesterSupport.ROLE, res.toString());
    } else {
        assertTrue(rc != 200);
        assertEquals("", res.toString());
    }
}
Also used : ProtocolHandler(org.apache.coyote.ProtocolHandler) AbstractHttp11JsseProtocol(org.apache.coyote.http11.AbstractHttp11JsseProtocol) SocketException(java.net.SocketException) Tomcat(org.apache.catalina.startup.Tomcat) ByteChunk(org.apache.tomcat.util.buf.ByteChunk) SSLException(javax.net.ssl.SSLException)

Aggregations

ProtocolHandler (org.apache.coyote.ProtocolHandler)27 AbstractProtocol (org.apache.coyote.AbstractProtocol)8 Connector (org.apache.catalina.connector.Connector)7 AbstractHttp11Protocol (org.apache.coyote.http11.AbstractHttp11Protocol)7 Tomcat (org.apache.catalina.startup.Tomcat)5 AbstractHttp11JsseProtocol (org.apache.coyote.http11.AbstractHttp11JsseProtocol)5 SocketException (java.net.SocketException)4 Service (org.apache.catalina.Service)4 SSLException (javax.net.ssl.SSLException)3 File (java.io.File)2 Executor (java.util.concurrent.Executor)2 ObjectName (javax.management.ObjectName)2 Context (org.apache.catalina.Context)2 Engine (org.apache.catalina.Engine)2 Http11AprProtocol (org.apache.coyote.http11.Http11AprProtocol)2 Http11NioProtocol (org.apache.coyote.http11.Http11NioProtocol)2 Http11Protocol (org.apache.coyote.http11.Http11Protocol)2 ByteChunk (org.apache.tomcat.util.buf.ByteChunk)2 ThreadPoolExecutor (org.apache.tomcat.util.threads.ThreadPoolExecutor)2 Test (org.junit.jupiter.api.Test)2