Package io.dropwizard.jetty
Class HttpConnectorFactory
- java.lang.Object
-
- io.dropwizard.jetty.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
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. SeeForwardedRequestCustomizer
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.
uriCompliance
DEFAULT This sets the uri compliance level used by Jetty when parsing http, this can be useful when attempting to avoid breaking changes with Jetty 10 and onward; Possible values are set forth in the org.eclipse.jetty.http.UriCompliance enum and include: - DEFAULT: The default compliance mode that extends RFC3986 compliance with additional violations to avoid most ambiguous URIs.
- LEGACY: Compliance mode that models Jetty-9.4 behavior.
- RFC3986: Compliance mode that exactly follows RFC3986, including allowing all additional ambiguous URI Violations.
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 Summary
Constructors Constructor Description HttpConnectorFactory()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ConnectorFactory
admin()
static ConnectorFactory
application()
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)
Create a new connector.protected org.eclipse.jetty.io.ByteBufferPool
buildBufferPool()
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)
protected org.eclipse.jetty.server.HttpConfiguration
buildHttpConfiguration()
protected org.eclipse.jetty.server.HttpConnectionFactory
buildHttpConnectionFactory(org.eclipse.jetty.server.HttpConfiguration httpConfig)
Optional<Integer>
getAcceptorThreads()
@Nullable Integer
getAcceptQueueSize()
@Nullable String
getBindHost()
DataSize
getBufferPoolIncrement()
DataSize
getHeaderCacheSize()
org.eclipse.jetty.http.HttpCompliance
getHttpCompliance()
Duration
getIdleTimeout()
DataSize
getInputBufferSize()
DataSize
getMaxBufferPoolSize()
DataSize
getMaxRequestHeaderSize()
DataSize
getMaxResponseHeaderSize()
DataSize
getMinBufferPoolSize()
DataSize
getMinRequestDataPerSecond()
DataSize
getMinResponseDataPerSecond()
DataSize
getOutputBufferSize()
int
getPort()
org.eclipse.jetty.http.CookieCompliance
getRequestCookieCompliance()
org.eclipse.jetty.http.CookieCompliance
getResponseCookieCompliance()
Optional<Integer>
getSelectorThreads()
org.eclipse.jetty.http.UriCompliance
getUriCompliance()
protected String
httpConnections()
Get name of the timer that tracks incoming HTTP connectionsboolean
isInheritChannel()
boolean
isReuseAddress()
boolean
isUseDateHeader()
boolean
isUseForwardedHeaders()
boolean
isUseProxyProtocol()
boolean
isUseServerHeader()
void
setAcceptorThreads(Optional<Integer> acceptorThreads)
void
setAcceptQueueSize(Integer acceptQueueSize)
void
setBindHost(String bindHost)
void
setBufferPoolIncrement(DataSize bufferPoolIncrement)
void
setHeaderCacheSize(DataSize headerCacheSize)
void
setHttpCompliance(org.eclipse.jetty.http.HttpCompliance httpCompliance)
void
setIdleTimeout(Duration idleTimeout)
void
setInheritChannel(boolean inheritChannel)
void
setInputBufferSize(DataSize inputBufferSize)
void
setMaxBufferPoolSize(DataSize maxBufferPoolSize)
void
setMaxRequestHeaderSize(DataSize maxRequestHeaderSize)
void
setMaxResponseHeaderSize(DataSize maxResponseHeaderSize)
void
setMinBufferPoolSize(DataSize minBufferPoolSize)
void
setMinRequestDataPerSecond(DataSize minRequestDataPerSecond)
void
setMinResponseDataPerSecond(DataSize minResponseDataPerSecond)
void
setOutputBufferSize(DataSize outputBufferSize)
void
setPort(int port)
void
setRequestCookieCompliance(org.eclipse.jetty.http.CookieCompliance requestCookieCompliance)
void
setResponseCookieCompliance(org.eclipse.jetty.http.CookieCompliance responseCookieCompliance)
void
setReuseAddress(boolean reuseAddress)
void
setSelectorThreads(Optional<Integer> selectorThreads)
void
setUriCompliance(org.eclipse.jetty.http.UriCompliance uriCompliance)
void
setUseDateHeader(boolean useDateHeader)
void
setUseForwardedHeaders(boolean useForwardedHeaders)
void
setUseProxyProtocol(boolean useProxyProtocol)
void
setUseServerHeader(boolean useServerHeader)
-
-
-
Method Detail
-
application
public static ConnectorFactory application()
-
admin
public static ConnectorFactory admin()
-
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)
-
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)
-
getUriCompliance
public org.eclipse.jetty.http.UriCompliance getUriCompliance()
-
setUriCompliance
public void setUriCompliance(org.eclipse.jetty.http.UriCompliance uriCompliance)
-
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 interfaceConnectorFactory
- Parameters:
server
- the application'sServer
instancemetrics
- the application's metricsname
- the application's namethreadPool
- 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()
-
-