- java.lang.Object
-
- io.helidon.webserver.SocketConfiguration.Builder
-
- All Implemented Interfaces:
Builder<SocketConfiguration>
,SocketConfiguration.SocketConfigurationBuilder<SocketConfiguration.Builder>
,Supplier<SocketConfiguration>
- Enclosing interface:
- SocketConfiguration
public static final class SocketConfiguration.Builder extends Object implements SocketConfiguration.SocketConfigurationBuilder<SocketConfiguration.Builder>, Builder<SocketConfiguration>
TheSocketConfiguration
builder class.
-
-
Field Summary
-
Fields inherited from interface io.helidon.webserver.SocketConfiguration.SocketConfigurationBuilder
REQUESTED_URI_DISCOVERY_CONFIG_KEY_PREFIX
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description SocketConfiguration.Builder
addRequestedUriDiscoveryType(SocketConfiguration.RequestedUriDiscoveryType type)
Adds a type of front-end URI discovery Helidon should use for this socket.SocketConfiguration.Builder
backlog(int backlog)
Configures a maximum length of the queue of incoming connections on the server socket.SocketConfiguration.Builder
backpressureBufferSize(long size)
Maximum length of the response data sending buffer can keep without flushing.SocketConfiguration.Builder
backpressureStrategy(BackpressureStrategy backpressureStrategy)
Sets a backpressure strategy for the server to apply against user provided response upstream.SocketConfiguration.Builder
bindAddress(InetAddress bindAddress)
Configures local address where the server listens on with the server socket.SocketConfiguration
build()
Build the instance from this builder.SocketConfiguration.Builder
config(Config config)
Update this socket configuration from aConfig
.SocketConfiguration.Builder
connectionIdleTimeout(int seconds)
Sets the number of seconds after which an idle connection will be automatically closed by the server.SocketConfiguration.Builder
continueImmediately(boolean continueImmediately)
When true WebServer answers to expect continue with 100 continue immediately, not waiting for user to actually request the data.SocketConfiguration.Builder
enableCompression(boolean value)
Configure whether to enable content negotiation for compression.SocketConfiguration.Builder
enabled(boolean enabled)
Set this socket builder to enabled or disabled.SocketConfiguration.Builder
enabledSSlProtocols(String... protocols)
Deprecated.since 2.0.0, please useWebServerTls.Builder.enabledProtocols(String...)
insteadSocketConfiguration.Builder
enabledSSlProtocols(List<String> protocols)
Deprecated.SocketConfiguration.Builder
initialBufferSize(int size)
Configure initial size of the buffer used to parse HTTP line and headers.SocketConfiguration.Builder
maxChunkSize(int size)
Configure maximal size of a chunk to be read from incoming requests.SocketConfiguration.Builder
maxHeaderSize(int size)
Maximal number of bytes of all header values combined.SocketConfiguration.Builder
maxInitialLineLength(int length)
Maximal number of characters in the initial HTTP line.SocketConfiguration.Builder
maxPayloadSize(long size)
Set a maximum payload size for a client request.SocketConfiguration.Builder
name(String name)
Configure a socket name, to bind named routings to.SocketConfiguration.Builder
port(int port)
Configures a server port to listen on with the server socket.SocketConfiguration.Builder
receiveBufferSize(int receiveBufferSize)
Configures proposed value of the TCP receive window that is advertised to the remote peer on the server socket.SocketConfiguration.Builder
requestedUriDiscoveryEnabled(boolean enabled)
Sets whether requested URI discovery is enabled for the socket.SocketConfiguration.Builder
requestedUriDiscoveryTypes(List<SocketConfiguration.RequestedUriDiscoveryType> types)
Assigns the front-end URI discovery type(s) this socket should use.SocketConfiguration.Builder
ssl(Supplier<? extends SSLContext> sslContextBuilder)
Deprecated.since 2.0.0, please useSocketConfiguration.SocketConfigurationBuilder.tls(Supplier)
insteadSocketConfiguration.Builder
ssl(SSLContext sslContext)
Deprecated.since 2.0.0, please usetls(WebServerTls)
insteadSocketConfiguration.Builder
timeout(long amount, TimeUnit unit)
Configures a server socket timeout.SocketConfiguration.Builder
timeoutMillis(int timeoutMillis)
Deprecated.since 2.0.0 please usetimeout(long, java.util.concurrent.TimeUnit)
insteadSocketConfiguration.Builder
tls(WebServerTls webServerTls)
Configures SSL for this socket.SocketConfiguration.Builder
trustedProxies(AllowList trustedProxies)
Configure the trusted proxy settings.SocketConfiguration.Builder
validateHeaders(boolean validate)
Configure whether to validate header names.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.helidon.webserver.SocketConfiguration.SocketConfigurationBuilder
bindAddress, host, tls
-
-
-
-
Method Detail
-
build
public SocketConfiguration build()
Description copied from interface:Builder
Build the instance from this builder.- Specified by:
build
in interfaceBuilder<SocketConfiguration>
- Returns:
- instance of the built type
-
port
public SocketConfiguration.Builder port(int port)
Description copied from interface:SocketConfiguration.SocketConfigurationBuilder
Configures a server port to listen on with the server socket. If port is0
then any available ephemeral port will be used.- Specified by:
port
in interfaceSocketConfiguration.SocketConfigurationBuilder<SocketConfiguration.Builder>
- Parameters:
port
- the server port of the server socket- Returns:
- this builder
-
bindAddress
public SocketConfiguration.Builder bindAddress(InetAddress bindAddress)
Description copied from interface:SocketConfiguration.SocketConfigurationBuilder
Configures local address where the server listens on with the server socket. If not configured, then listens an all local addresses.- Specified by:
bindAddress
in interfaceSocketConfiguration.SocketConfigurationBuilder<SocketConfiguration.Builder>
- Parameters:
bindAddress
- an address to bind with the server socket- Returns:
- this builder
-
backlog
public SocketConfiguration.Builder backlog(int backlog)
Configures a maximum length of the queue of incoming connections on the server socket.Default value is
SocketConfiguration.DEFAULT_BACKLOG_SIZE
.- Specified by:
backlog
in interfaceSocketConfiguration.SocketConfigurationBuilder<SocketConfiguration.Builder>
- Parameters:
backlog
- a maximum length of the queue of incoming connections- Returns:
- this builder
-
timeoutMillis
@Deprecated public SocketConfiguration.Builder timeoutMillis(int timeoutMillis)
Deprecated.since 2.0.0 please usetimeout(long, java.util.concurrent.TimeUnit)
insteadConfigures a server socket timeout in milliseconds or0
for an infinite timeout.- Parameters:
timeoutMillis
- a server socket timeout in milliseconds or0
- Returns:
- this builder
-
receiveBufferSize
public SocketConfiguration.Builder receiveBufferSize(int receiveBufferSize)
Configures proposed value of the TCP receive window that is advertised to the remote peer on the server socket.If
0
then use implementation default.- Specified by:
receiveBufferSize
in interfaceSocketConfiguration.SocketConfigurationBuilder<SocketConfiguration.Builder>
- Parameters:
receiveBufferSize
- a buffer size in bytes of the server socket or0
- Returns:
- this builder
-
ssl
@Deprecated public SocketConfiguration.Builder ssl(SSLContext sslContext)
Deprecated.since 2.0.0, please usetls(WebServerTls)
insteadConfigures aSSLContext
to use with the server socket. If notnull
then the server enforces an SSL communication.- Parameters:
sslContext
- a SSL context to use- Returns:
- this builder
-
ssl
@Deprecated public SocketConfiguration.Builder ssl(Supplier<? extends SSLContext> sslContextBuilder)
Deprecated.since 2.0.0, please useSocketConfiguration.SocketConfigurationBuilder.tls(Supplier)
insteadConfigures aSSLContext
to use with the server socket. If notnull
then the server enforces an SSL communication.- Parameters:
sslContextBuilder
- a SSL context builder to use; will be built as a first step of this method execution- Returns:
- this builder
-
enabledSSlProtocols
@Deprecated public SocketConfiguration.Builder enabledSSlProtocols(String... protocols)
Deprecated.since 2.0.0, please useWebServerTls.Builder.enabledProtocols(String...)
insteadConfigures the SSL protocols to enable with the server socket.- Parameters:
protocols
- protocols to enable, ifnull
enables the default protocols- Returns:
- this builder
-
enabledSSlProtocols
@Deprecated public SocketConfiguration.Builder enabledSSlProtocols(List<String> protocols)
Deprecated.Configures the SSL protocols to enable with the server socket.- Parameters:
protocols
- protocols to enable, ifnull
or empty enables the default protocols- Returns:
- this builder
-
timeout
public SocketConfiguration.Builder timeout(long amount, TimeUnit unit)
Description copied from interface:SocketConfiguration.SocketConfigurationBuilder
Configures a server socket timeout.- Specified by:
timeout
in interfaceSocketConfiguration.SocketConfigurationBuilder<SocketConfiguration.Builder>
- Parameters:
amount
- an amount of time to configure the timeout, use0
for infinite timeoutunit
- time unit to use with the configured amount- Returns:
- this builder
-
tls
public SocketConfiguration.Builder tls(WebServerTls webServerTls)
Description copied from interface:SocketConfiguration.SocketConfigurationBuilder
Configures SSL for this socket. When configured, the server enforces SSL configuration. If this method is called, any other method except forSocketConfiguration.SocketConfigurationBuilder.tls(java.util.function.Supplier)
ยจ and repeated invocation of this method would be ignored.If this method is called again, the previous configuration would be ignored.
- Specified by:
tls
in interfaceSocketConfiguration.SocketConfigurationBuilder<SocketConfiguration.Builder>
- Parameters:
webServerTls
- ssl configuration to use with this socket- Returns:
- this builder
-
maxHeaderSize
public SocketConfiguration.Builder maxHeaderSize(int size)
Description copied from interface:SocketConfiguration.SocketConfigurationBuilder
Maximal number of bytes of all header values combined. When a bigger value is received, aHttp.Status.BAD_REQUEST_400
is returned.Default is
16384
- Specified by:
maxHeaderSize
in interfaceSocketConfiguration.SocketConfigurationBuilder<SocketConfiguration.Builder>
- Parameters:
size
- maximal number of bytes of combined header values- Returns:
- this builder
-
maxInitialLineLength
public SocketConfiguration.Builder maxInitialLineLength(int length)
Description copied from interface:SocketConfiguration.SocketConfigurationBuilder
Maximal number of characters in the initial HTTP line.Default is
4096
- Specified by:
maxInitialLineLength
in interfaceSocketConfiguration.SocketConfigurationBuilder<SocketConfiguration.Builder>
- Parameters:
length
- maximal number of characters- Returns:
- this builder
-
maxPayloadSize
public SocketConfiguration.Builder maxPayloadSize(long size)
Description copied from interface:SocketConfiguration.SocketConfigurationBuilder
Set a maximum payload size for a client request. Can prevent DoS attacks.- Specified by:
maxPayloadSize
in interfaceSocketConfiguration.SocketConfigurationBuilder<SocketConfiguration.Builder>
- Parameters:
size
- maximum payload size- Returns:
- this builder
-
backpressureBufferSize
public SocketConfiguration.Builder backpressureBufferSize(long size)
Description copied from interface:SocketConfiguration.SocketConfigurationBuilder
Maximum length of the response data sending buffer can keep without flushing. Depends on `backpressure-policy` what happens if max buffer size is reached.- Specified by:
backpressureBufferSize
in interfaceSocketConfiguration.SocketConfigurationBuilder<SocketConfiguration.Builder>
- Parameters:
size
- maximum non-flushed data Netty can buffer until backpressure is applied- Returns:
- this builder
-
backpressureStrategy
public SocketConfiguration.Builder backpressureStrategy(BackpressureStrategy backpressureStrategy)
Description copied from interface:SocketConfiguration.SocketConfigurationBuilder
Sets a backpressure strategy for the server to apply against user provided response upstream.- LINEAR - Data are requested one-by-one, in case buffer reaches watermark, no other data is requested.
- AUTO_FLUSH - Data are requested one-by-one, in case buffer reaches watermark, no other data is requested.
- PREFETCH - After first data chunk arrives, probable number of chunks needed to fill the buffer up to watermark is calculated and requested.
- NONE - No backpressure is applied, Long.MAX_VALUE(unbounded) is requested from upstream.
- Specified by:
backpressureStrategy
in interfaceSocketConfiguration.SocketConfigurationBuilder<SocketConfiguration.Builder>
- Parameters:
backpressureStrategy
- One of NONE, PREFETCH, LINEAR or AUTO_FLUSH, default is AUTO_FLUSH- Returns:
- this builder
-
continueImmediately
public SocketConfiguration.Builder continueImmediately(boolean continueImmediately)
Description copied from interface:SocketConfiguration.SocketConfigurationBuilder
When true WebServer answers to expect continue with 100 continue immediately, not waiting for user to actually request the data.Default is
false
- Specified by:
continueImmediately
in interfaceSocketConfiguration.SocketConfigurationBuilder<SocketConfiguration.Builder>
- Parameters:
continueImmediately
- , answer with 100 continue immediately after expect continue, default is false- Returns:
- this builder
-
name
public SocketConfiguration.Builder name(String name)
Configure a socket name, to bind named routings to.- Parameters:
name
- name of the socket- Returns:
- updated builder instance
-
enabled
public SocketConfiguration.Builder enabled(boolean enabled)
Set this socket builder to enabled or disabled.- Parameters:
enabled
- when set tofalse
, the socket is not going to be opened by the server- Returns:
- updated builder instance
-
maxChunkSize
public SocketConfiguration.Builder maxChunkSize(int size)
Configure maximal size of a chunk to be read from incoming requests. Defaults to8192
.- Parameters:
size
- maximal chunk size- Returns:
- updated builder instance
-
validateHeaders
public SocketConfiguration.Builder validateHeaders(boolean validate)
Configure whether to validate header names. Defaults totrue
to make sure header names are valid strings.- Parameters:
validate
- set tofalse
to ignore header validation- Returns:
- updated builder instance
-
initialBufferSize
public SocketConfiguration.Builder initialBufferSize(int size)
Configure initial size of the buffer used to parse HTTP line and headers. Defaults to128
.- Parameters:
size
- initial buffer size- Returns:
- updated builder instance
-
enableCompression
public SocketConfiguration.Builder enableCompression(boolean value)
Configure whether to enable content negotiation for compression.- Specified by:
enableCompression
in interfaceSocketConfiguration.SocketConfigurationBuilder<SocketConfiguration.Builder>
- Parameters:
value
- compression flag- Returns:
- updated builder instance
-
trustedProxies
public SocketConfiguration.Builder trustedProxies(AllowList trustedProxies)
Configure the trusted proxy settings.- Specified by:
trustedProxies
in interfaceSocketConfiguration.SocketConfigurationBuilder<SocketConfiguration.Builder>
- Parameters:
trustedProxies
- prescribing proxies to be trusted- Returns:
- updated builder instance
- See Also:
ServerRequest.requestedUri()
-
config
public SocketConfiguration.Builder config(Config config)
Description copied from interface:SocketConfiguration.SocketConfigurationBuilder
Update this socket configuration from aConfig
.- Specified by:
config
in interfaceSocketConfiguration.SocketConfigurationBuilder<SocketConfiguration.Builder>
- Parameters:
config
- configuration on the node of a socket- Returns:
- updated builder instance
-
addRequestedUriDiscoveryType
public SocketConfiguration.Builder addRequestedUriDiscoveryType(SocketConfiguration.RequestedUriDiscoveryType type)
Description copied from interface:SocketConfiguration.SocketConfigurationBuilder
Adds a type of front-end URI discovery Helidon should use for this socket. Adding a discovery type automatically enables discovery for the socket.- Specified by:
addRequestedUriDiscoveryType
in interfaceSocketConfiguration.SocketConfigurationBuilder<SocketConfiguration.Builder>
- Parameters:
type
- type to add- Returns:
- updated builder
-
requestedUriDiscoveryTypes
public SocketConfiguration.Builder requestedUriDiscoveryTypes(List<SocketConfiguration.RequestedUriDiscoveryType> types)
Description copied from interface:SocketConfiguration.SocketConfigurationBuilder
Assigns the front-end URI discovery type(s) this socket should use. This setting automatically enables discovery for the socket.- Specified by:
requestedUriDiscoveryTypes
in interfaceSocketConfiguration.SocketConfigurationBuilder<SocketConfiguration.Builder>
- Parameters:
types
-SocketConfiguration.RequestedUriDiscoveryType
values to assign- Returns:
- updated builder
- See Also:
SocketConfiguration.SocketConfigurationBuilder.addRequestedUriDiscoveryType(io.helidon.webserver.SocketConfiguration.RequestedUriDiscoveryType)
,SocketConfiguration.SocketConfigurationBuilder.requestedUriDiscoveryEnabled(boolean)
,ServerRequest.requestedUri()
-
requestedUriDiscoveryEnabled
public SocketConfiguration.Builder requestedUriDiscoveryEnabled(boolean enabled)
Description copied from interface:SocketConfiguration.SocketConfigurationBuilder
Sets whether requested URI discovery is enabled for the socket.- Specified by:
requestedUriDiscoveryEnabled
in interfaceSocketConfiguration.SocketConfigurationBuilder<SocketConfiguration.Builder>
- Parameters:
enabled
- whether to enable discovery- Returns:
- updated builder
- See Also:
ServerRequest.requestedUri()
-
connectionIdleTimeout
public SocketConfiguration.Builder connectionIdleTimeout(int seconds)
Description copied from interface:SocketConfiguration.SocketConfigurationBuilder
Sets the number of seconds after which an idle connection will be automatically closed by the server.- Specified by:
connectionIdleTimeout
in interfaceSocketConfiguration.SocketConfigurationBuilder<SocketConfiguration.Builder>
- Parameters:
seconds
- time in seconds- Returns:
- updated builder
-
-