Class HttpConnectorFactory

  • All Implemented Interfaces:
    Discoverable, ConnectorFactory
    Direct Known Subclasses:
    HttpsConnectorFactory

    public class HttpConnectorFactory
    extends Object
    implements ConnectorFactory
    Builds HTTP connectors.

    Configuration Parameters:

    Name Default Description
    port 8080 The TCP/IP port on which to listen for incoming connections.
    bindHost (none) The hostname to bind to.
    inheritChannel false Whether this connector uses a channel inherited from the JVM. Use it with Server::Starter, to launch an instance of Jetty on demand.
    headerCacheSize 512 bytes The size of the header field cache.
    outputBufferSize 32KiB The size of the buffer into which response content is aggregated before being sent to the client. A larger buffer can improve performance by allowing a content producer to run without blocking, however larger buffers consume more memory and may induce some latency before a client starts processing the content.
    maxRequestHeaderSize 8KiB The maximum allowed size in bytes for the HTTP request line and HTTP request headers. Larger headers will allow for more and/or larger cookies plus larger form content encoded in a URL. However, larger headers consume more memory and can make a server more vulnerable to denial of service attacks.
    maxResponseHeaderSize 8KiB The maximum size of a response header. Larger headers will allow for more and/or larger cookies and longer HTTP headers (eg for redirection). However, larger headers will also consume more memory.
    inputBufferSize 8KiB The size of the per-connection input buffer.
    idleTimeout 30 seconds The maximum idle time for a connection, which roughly translates to the Socket.setSoTimeout(int) call, although with NIO implementations other mechanisms may be used to implement the timeout.

    The max idle time is applied:

    • When waiting for a new message to be received on a connection
    • When waiting for a new message to be sent on a connection

    This value is interpreted as the maximum time between some progress being made on the connection. So if a single byte is read or written, then the timeout is reset.

    minBufferPoolSize 64 bytes The minimum size of the buffer pool.
    bufferPoolIncrement 1KiB The increment by which the buffer pool should be increased.
    maxBufferPoolSize 64KiB The maximum size of the buffer pool.
    acceptorThreads (Jetty's default) The number of worker threads dedicated to accepting connections. By default is max(1, min(4, #CPUs/8)).
    selectorThreads (Jetty's default) The number of worker threads dedicated to sending and receiving data. By default is max(1, min(4, #CPUs/2)).
    acceptQueueSize (OS default) The size of the TCP/IP accept queue for the listening socket.
    reuseAddress true Whether or not SO_REUSEADDR is enabled on the listening socket.
    useServerHeader false Whether or not to add the Server header to each response.
    useDateHeader true Whether or not to add the Date header to each response.
    minResponseDataPerSecond 0 bytes The minimum response data rate in bytes per second; or <=0 for no limit
    minRequestDataPerSecond 0 bytes The minimum request data rate in bytes per second; or <=0 for no limit
    useForwardedHeaders false Whether or not to look at X-Forwarded-* headers added by proxies. See ForwardedRequestCustomizer for details.
    useProxyProtocol false Enable jetty proxy protocol header support.
    httpCompliance RFC7230 This sets the http compliance level used by Jetty when parsing http, this can be useful when using a non-RFC7230 compliant front end, such as nginx, which can produce multi-line headers when forwarding client certificates using proxy_set_header X-SSL-CERT $ssl_client_cert; Possible values are set forth in the org.eclipse.jetty.http.HttpCompliance enum:
    • RFC7230: Disallow header folding.
    • RFC2616: Allow header folding.
    requestCookieCompliance RFC6265 This sets the cookie compliance level used by Jetty when parsing request Cookie headers, this can be useful when needing to support Version=1 cookies defined in RFC2109 (and continued in RFC2965) which allows for special/reserved characters (control, separator, et al) to be enclosed within double quotes when used in a cookie value; Possible values are set forth in the org.eclipse.jetty.http.CookieCompliance enum:
    • RFC6265: Special characters in cookie values must be encoded.
    • RFC2965: Allows for special characters enclosed within double quotes.
    responseCookieCompliance RFC6265 This sets the cookie compliance level used by Jetty when generating response Set-Cookie headers, this can be useful when needing to support Version=1 cookies defined in RFC2109 (and continued in RFC2965) which allows for special/reserved characters (control, separator, et al) to be enclosed within double quotes when used in a cookie value; Possible values are set forth in the org.eclipse.jetty.http.CookieCompliance enum:
    • RFC6265: Special characters in cookie values must be encoded.
    • RFC2965: Allows for special characters enclosed within double quotes.
    • Constructor Detail

      • HttpConnectorFactory

        public HttpConnectorFactory()
    • Method Detail

      • getPort

        public int getPort()
      • setPort

        public void setPort​(int port)
      • getBindHost

        public @Nullable String getBindHost()
      • setBindHost

        public void setBindHost​(String bindHost)
      • isInheritChannel

        public boolean isInheritChannel()
      • setInheritChannel

        public void setInheritChannel​(boolean inheritChannel)
      • getHeaderCacheSize

        public DataSize getHeaderCacheSize()
      • setHeaderCacheSize

        public void setHeaderCacheSize​(DataSize headerCacheSize)
      • getOutputBufferSize

        public DataSize getOutputBufferSize()
      • setOutputBufferSize

        public void setOutputBufferSize​(DataSize outputBufferSize)
      • getMaxRequestHeaderSize

        public DataSize getMaxRequestHeaderSize()
      • setMaxRequestHeaderSize

        public void setMaxRequestHeaderSize​(DataSize maxRequestHeaderSize)
      • getMaxResponseHeaderSize

        public DataSize getMaxResponseHeaderSize()
      • setMaxResponseHeaderSize

        public void setMaxResponseHeaderSize​(DataSize maxResponseHeaderSize)
      • getInputBufferSize

        public DataSize getInputBufferSize()
      • setInputBufferSize

        public void setInputBufferSize​(DataSize inputBufferSize)
      • getIdleTimeout

        public Duration getIdleTimeout()
      • setIdleTimeout

        public void setIdleTimeout​(Duration idleTimeout)
      • getMinBufferPoolSize

        public DataSize getMinBufferPoolSize()
      • setMinBufferPoolSize

        public void setMinBufferPoolSize​(DataSize minBufferPoolSize)
      • getBufferPoolIncrement

        public DataSize getBufferPoolIncrement()
      • setBufferPoolIncrement

        public void setBufferPoolIncrement​(DataSize bufferPoolIncrement)
      • getMaxBufferPoolSize

        public DataSize getMaxBufferPoolSize()
      • setMaxBufferPoolSize

        public void setMaxBufferPoolSize​(DataSize maxBufferPoolSize)
      • getMinResponseDataPerSecond

        public DataSize getMinResponseDataPerSecond()
      • setMinResponseDataPerSecond

        public void setMinResponseDataPerSecond​(DataSize minResponseDataPerSecond)
      • getMinRequestDataPerSecond

        public DataSize getMinRequestDataPerSecond()
      • setMinRequestDataPerSecond

        public void setMinRequestDataPerSecond​(DataSize minRequestDataPerSecond)
      • setAcceptorThreads

        public void setAcceptorThreads​(Optional<Integer> acceptorThreads)
      • setSelectorThreads

        public void setSelectorThreads​(Optional<Integer> selectorThreads)
      • getAcceptQueueSize

        public @Nullable Integer getAcceptQueueSize()
      • setAcceptQueueSize

        public void setAcceptQueueSize​(Integer acceptQueueSize)
      • isReuseAddress

        public boolean isReuseAddress()
      • setReuseAddress

        public void setReuseAddress​(boolean reuseAddress)
      • isUseServerHeader

        public boolean isUseServerHeader()
      • setUseServerHeader

        public void setUseServerHeader​(boolean useServerHeader)
      • isUseDateHeader

        public boolean isUseDateHeader()
      • setUseDateHeader

        public void setUseDateHeader​(boolean useDateHeader)
      • isUseForwardedHeaders

        public boolean isUseForwardedHeaders()
      • setUseForwardedHeaders

        public void setUseForwardedHeaders​(boolean useForwardedHeaders)
      • isUseProxyProtocol

        public boolean isUseProxyProtocol()
        Since:
        2.0
      • setUseProxyProtocol

        public void setUseProxyProtocol​(boolean useProxyProtocol)
        Since:
        2.0
      • getHttpCompliance

        public org.eclipse.jetty.http.HttpCompliance getHttpCompliance()
      • setHttpCompliance

        public void setHttpCompliance​(org.eclipse.jetty.http.HttpCompliance httpCompliance)
      • getRequestCookieCompliance

        public org.eclipse.jetty.http.CookieCompliance getRequestCookieCompliance()
        Since:
        2.0
      • setRequestCookieCompliance

        public void setRequestCookieCompliance​(org.eclipse.jetty.http.CookieCompliance requestCookieCompliance)
        Since:
        2.0
      • getResponseCookieCompliance

        public org.eclipse.jetty.http.CookieCompliance getResponseCookieCompliance()
        Since:
        2.0
      • setResponseCookieCompliance

        public void setResponseCookieCompliance​(org.eclipse.jetty.http.CookieCompliance responseCookieCompliance)
        Since:
        2.0
      • build

        public org.eclipse.jetty.server.Connector build​(org.eclipse.jetty.server.Server server,
                                                        com.codahale.metrics.MetricRegistry metrics,
                                                        String name,
                                                        @Nullable org.eclipse.jetty.util.thread.ThreadPool threadPool)
        Description copied from interface: ConnectorFactory
        Create a new connector.
        Specified by:
        build in interface ConnectorFactory
        Parameters:
        server - the application's Server instance
        metrics - the application's metrics
        name - the application's name
        threadPool - the application's thread pool
        Returns:
        a Connector
      • httpConnections

        protected String httpConnections()
        Get name of the timer that tracks incoming HTTP connections
      • buildConnector

        protected org.eclipse.jetty.server.ServerConnector buildConnector​(org.eclipse.jetty.server.Server server,
                                                                          org.eclipse.jetty.util.thread.Scheduler scheduler,
                                                                          org.eclipse.jetty.io.ByteBufferPool bufferPool,
                                                                          String name,
                                                                          @Nullable org.eclipse.jetty.util.thread.ThreadPool threadPool,
                                                                          org.eclipse.jetty.server.ConnectionFactory... factories)
      • buildHttpConnectionFactory

        protected org.eclipse.jetty.server.HttpConnectionFactory buildHttpConnectionFactory​(org.eclipse.jetty.server.HttpConfiguration httpConfig)
      • buildHttpConfiguration

        protected org.eclipse.jetty.server.HttpConfiguration buildHttpConfiguration()
      • buildBufferPool

        protected org.eclipse.jetty.io.ByteBufferPool buildBufferPool()