Package io.dropwizard.jetty
Class HttpConnectorFactory
java.lang.Object
io.dropwizard.jetty.HttpConnectorFactory
- All Implemented Interfaces:
io.dropwizard.jackson.Discoverable,ConnectorFactory
- Direct Known Subclasses:
HttpsConnectorFactory
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:
|
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:
|
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:
|
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:
|
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:
|
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ConnectorFactoryadmin()static ConnectorFactoryorg.eclipse.jetty.server.Connectorbuild(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.ByteBufferPoolprotected org.eclipse.jetty.server.ServerConnectorbuildConnector(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.HttpConfigurationprotected org.eclipse.jetty.server.HttpConnectionFactorybuildHttpConnectionFactory(org.eclipse.jetty.server.HttpConfiguration httpConfig) @Nullable Integer@Nullable Stringio.dropwizard.util.DataSizeio.dropwizard.util.DataSizeorg.eclipse.jetty.http.HttpComplianceio.dropwizard.util.Durationio.dropwizard.util.DataSizeio.dropwizard.util.DataSizeio.dropwizard.util.DataSizeio.dropwizard.util.DataSizeio.dropwizard.util.DataSizeio.dropwizard.util.DataSizeio.dropwizard.util.DataSizeio.dropwizard.util.DataSizeintgetPort()org.eclipse.jetty.http.CookieComplianceorg.eclipse.jetty.http.CookieComplianceorg.eclipse.jetty.http.UriComplianceprotected StringGet name of the timer that tracks incoming HTTP connectionsbooleanbooleanbooleanbooleanbooleanbooleanvoidsetAcceptorThreads(Optional<Integer> acceptorThreads) voidsetAcceptQueueSize(Integer acceptQueueSize) voidsetBindHost(String bindHost) voidsetBufferPoolIncrement(io.dropwizard.util.DataSize bufferPoolIncrement) voidsetHeaderCacheSize(io.dropwizard.util.DataSize headerCacheSize) voidsetHttpCompliance(org.eclipse.jetty.http.HttpCompliance httpCompliance) voidsetIdleTimeout(io.dropwizard.util.Duration idleTimeout) voidsetInheritChannel(boolean inheritChannel) voidsetInputBufferSize(io.dropwizard.util.DataSize inputBufferSize) voidsetMaxBufferPoolSize(io.dropwizard.util.DataSize maxBufferPoolSize) voidsetMaxRequestHeaderSize(io.dropwizard.util.DataSize maxRequestHeaderSize) voidsetMaxResponseHeaderSize(io.dropwizard.util.DataSize maxResponseHeaderSize) voidsetMinBufferPoolSize(io.dropwizard.util.DataSize minBufferPoolSize) voidsetMinRequestDataPerSecond(io.dropwizard.util.DataSize minRequestDataPerSecond) voidsetMinResponseDataPerSecond(io.dropwizard.util.DataSize minResponseDataPerSecond) voidsetOutputBufferSize(io.dropwizard.util.DataSize outputBufferSize) voidsetPort(int port) voidsetRequestCookieCompliance(org.eclipse.jetty.http.CookieCompliance requestCookieCompliance) voidsetResponseCookieCompliance(org.eclipse.jetty.http.CookieCompliance responseCookieCompliance) voidsetReuseAddress(boolean reuseAddress) voidsetSelectorThreads(Optional<Integer> selectorThreads) voidsetUriCompliance(org.eclipse.jetty.http.UriCompliance uriCompliance) voidsetUseDateHeader(boolean useDateHeader) voidsetUseForwardedHeaders(boolean useForwardedHeaders) voidsetUseProxyProtocol(boolean useProxyProtocol) voidsetUseServerHeader(boolean useServerHeader)
-
Constructor Details
-
HttpConnectorFactory
public HttpConnectorFactory()
-
-
Method Details
-
application
-
admin
-
getPort
public int getPort() -
setPort
public void setPort(int port) -
getBindHost
-
setBindHost
-
isInheritChannel
public boolean isInheritChannel() -
setInheritChannel
public void setInheritChannel(boolean inheritChannel) -
getHeaderCacheSize
public io.dropwizard.util.DataSize getHeaderCacheSize() -
setHeaderCacheSize
public void setHeaderCacheSize(io.dropwizard.util.DataSize headerCacheSize) -
getOutputBufferSize
public io.dropwizard.util.DataSize getOutputBufferSize() -
setOutputBufferSize
public void setOutputBufferSize(io.dropwizard.util.DataSize outputBufferSize) -
getMaxRequestHeaderSize
public io.dropwizard.util.DataSize getMaxRequestHeaderSize() -
setMaxRequestHeaderSize
public void setMaxRequestHeaderSize(io.dropwizard.util.DataSize maxRequestHeaderSize) -
getMaxResponseHeaderSize
public io.dropwizard.util.DataSize getMaxResponseHeaderSize() -
setMaxResponseHeaderSize
public void setMaxResponseHeaderSize(io.dropwizard.util.DataSize maxResponseHeaderSize) -
getInputBufferSize
public io.dropwizard.util.DataSize getInputBufferSize() -
setInputBufferSize
public void setInputBufferSize(io.dropwizard.util.DataSize inputBufferSize) -
getIdleTimeout
public io.dropwizard.util.Duration getIdleTimeout() -
setIdleTimeout
public void setIdleTimeout(io.dropwizard.util.Duration idleTimeout) -
getMinBufferPoolSize
public io.dropwizard.util.DataSize getMinBufferPoolSize() -
setMinBufferPoolSize
public void setMinBufferPoolSize(io.dropwizard.util.DataSize minBufferPoolSize) -
getBufferPoolIncrement
public io.dropwizard.util.DataSize getBufferPoolIncrement() -
setBufferPoolIncrement
public void setBufferPoolIncrement(io.dropwizard.util.DataSize bufferPoolIncrement) -
getMaxBufferPoolSize
public io.dropwizard.util.DataSize getMaxBufferPoolSize() -
setMaxBufferPoolSize
public void setMaxBufferPoolSize(io.dropwizard.util.DataSize maxBufferPoolSize) -
getMinResponseDataPerSecond
public io.dropwizard.util.DataSize getMinResponseDataPerSecond() -
setMinResponseDataPerSecond
public void setMinResponseDataPerSecond(io.dropwizard.util.DataSize minResponseDataPerSecond) -
getMinRequestDataPerSecond
public io.dropwizard.util.DataSize getMinRequestDataPerSecond() -
setMinRequestDataPerSecond
public void setMinRequestDataPerSecond(io.dropwizard.util.DataSize minRequestDataPerSecond) -
getAcceptorThreads
-
setAcceptorThreads
-
getSelectorThreads
-
setSelectorThreads
-
getAcceptQueueSize
-
setAcceptQueueSize
-
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:ConnectorFactoryCreate a new connector.- Specified by:
buildin interfaceConnectorFactory- Parameters:
server- the application'sServerinstancemetrics- the application's metricsname- the application's namethreadPool- the application's thread pool- Returns:
- a
Connector
-
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()
-