ServerProperties class final
The settings of the HTTP server, read from the server.* properties.
Applications set the properties; the starter reads them with
ServerProperties.of into the webServerFactory bean. Code meets
this class in a WebServerFactoryCustomizer, to change a setting
with copyWith.
| Property | Default |
|---|---|
server.port |
8080 (0: a random free port) |
server.address |
all interfaces (127.0.0.1 in Flutter apps) |
server.shutdown |
graceful |
server.ssl.enabled, server.ssl.certificate, server.ssl.certificate-private-key, server.ssl.key-password, server.ssl.trust-certificate, server.ssl.client-auth |
no TLS |
server.context-path |
none: a prefix of every mapping |
server.max-http-request-body-size |
10MB (-1: no limit) |
server.http2.enabled |
ignored (dart:io speaks HTTP/1.1) |
server.compression.enabled |
false; true gzips the responses of mime-types from min-response-size on, for clients that accept gzip |
server.compression.mime-types |
Spring Boot's: text/html, text/xml, text/plain, text/css, text/javascript, application/javascript, application/json, application/xml |
server.compression.min-response-size |
2KB |
server.forward-headers-strategy |
none; native or framework applies the headers of trusted proxies (ForwardedHeaderFilter) |
server.forward-headers.trusted-proxies |
loopback and private networks (addresses and CIDR ranges) |
server.connection-timeout |
60s (-1, 0 or less: none): a request body that sends nothing for this long is a 408; also how long an idle connection stays open |
server.request-timeout |
none (0 or less: none): the longest the filters and the handler may take to answer, else a 503; a deadline for the calls the request makes too (an extension: Spring has no such key) |
server.websocket.max-text-message-size, server.websocket.max-binary-message-size |
8KB each (-1: no limit); a larger message closes the session with 1009 |
server.websocket.send-buffer-size-limit |
512KB (-1: no limit): more waiting to be sent drops the connection (4500) |
server.websocket.send-time-limit |
10s (-1: no limit): what was sent and has not left by then drops the connection (4500) |
Constructors
-
ServerProperties({int port = 8080, String? address, Shutdown shutdown = Shutdown.graceful, SslSettings? ssl, String contextPath = '', int maxRequestBodySize = 10 * 1024 * 1024, bool compression = false, List<
String> compressionMimeTypes = defaultCompressionMimeTypes, int compressionMinResponseSize = 2048, int webSocketMaxTextMessageSize = 8192, int webSocketMaxBinaryMessageSize = 8192, int webSocketSendBufferSizeLimit = 512 * 1024, Duration? webSocketSendTimeLimit = const Duration(seconds: 10), Duration? connectionTimeout = const Duration(seconds: 60), Duration? requestTimeout}) -
Settings with the defaults of the table above.
const
- ServerProperties.of(PropertyResolver environment, {String? defaultAddress})
-
Reads
server.*fromenvironment.defaultAddressapplies whenserver.addressis not set; the starter passes127.0.0.1in Flutter apps, so they open no port to the network by accident.factory
Properties
- address → String?
-
The address to listen on, an IP address or a host name
(
localhostis127.0.0.1);nulllistens on every interface.final - compression → bool
-
Whether responses are gzip-compressed for clients that accept it
(
Accept-Encoding: gzip);falseby default. Only responses of compressionMimeTypes and of at least compressionMinResponseSize bytes (or of unknown length) are compressed, never partial content or a response that already has aContent-Encoding.final -
compressionMimeTypes
→ List<
String> -
The media types compressed when compression is on, without
parameters (
text/*matches every text type); defaultCompressionMimeTypes by default. Event streams are not in it, as in Spring Boot; addtext/event-streamto compress them too.final - compressionMinResponseSize → int
-
The smallest
Content-Lengthcompressed, in bytes; 2 KB by default.final - connectionTimeout → Duration?
-
How long a request body may send nothing before the request is
answered with 408 (Request Timeout) and the connection closed; also
how long an idle keep-alive connection stays open. 60 seconds by
default, Tomcat's
connectionTimeout;null, zero or a negative duration for no limit, as Tomcat takes-1and0(server.connection-timeout, the key Spring Boot 2.0 had).final - contextPath → String
-
A prefix every request path must have, such as
/shop; it is removed before routing, so@GetMapping('/books')answers/shop/books. Empty for none.final - effectiveConnectionTimeout → Duration?
-
connectionTimeout as the server applies it:
null(no limit) for zero or a negative duration.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- maxRequestBodySize → int
-
The largest request body accepted, in bytes; 10 MB by default,
-1for no limit. A larger body is a 413, whatever itsContent-Type. Only the multipart resolver reads uploads with its own limit (spring.web.multipart.max-request-size), through maxRequestBodySizeAttribute.final - port → int
-
The port to listen on; 8080 by default,
0for a free port chosen by the system (read it from WebServer.port or thelocal.server.portproperty).final - requestTimeout → Duration?
-
The longest the filters and the handler of a request may take to
answer (
server.request-timeout);null, the default, for no limit, and zero or a negative duration mean none too. When it passes before the answer starts, the request is answered with a 503 (anAsyncRequestTimeoutException) and what the handler returns later is dropped. The request runs under aRequestDeadlineof this length, so the Feign calls it makes stop at it.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shutdown → Shutdown
-
How the server stops; Shutdown.graceful by default.
final
- ssl → SslSettings?
-
The TLS settings, or
nullfor plain HTTP.final - webSocketMaxBinaryMessageSize → int
-
The largest binary message a WebSocket session accepts, in bytes; as
webSocketMaxTextMessageSize.
final
- webSocketMaxTextMessageSize → int
-
The largest text message a WebSocket session accepts, in bytes; 8 KB
by default (Tomcat's default in Spring),
-1for no limit. A larger message is not read: the session is closed with 1009 (message too big). This starter's own key; Spring sets it on the container (ServletServerContainerFactoryBean).final - webSocketSendBufferSizeLimit → int
-
How many bytes a WebSocket session may keep waiting to be sent, for
a client that reads slowly or not at all; 512 KB by default,
-1for no limit. Past it the connection is dropped and the session's close status is 4500 (CloseStatus.sessionNotReliable), as Spring'sConcurrentWebSocketSessionDecoratordoes with itssendBufferSizeLimit. This starter's own key (server.websocket.send-buffer-size-limit); Spring sets it in code.final - webSocketSendTimeLimit → Duration?
-
How long what a WebSocket session sent may take to leave; 10 seconds
by default,
nullfor no limit. Past it the connection is dropped, as for webSocketSendBufferSizeLimit (Spring'ssendTimeLimit).final
Methods
-
copyWith(
{int? port, String? address, Shutdown? shutdown, SslSettings? ssl, String? contextPath, int? maxRequestBodySize, bool? compression, List< String> ? compressionMimeTypes, int? compressionMinResponseSize, int? webSocketMaxTextMessageSize, int? webSocketMaxBinaryMessageSize, int? webSocketSendBufferSizeLimit, Duration? webSocketSendTimeLimit, Duration? connectionTimeout, Duration? requestTimeout}) → ServerProperties -
A copy with the given settings changed and the others kept. A
nullargument keeps the old value, soaddress,ssl,webSocketSendTimeLimit,connectionTimeoutandrequestTimeoutcannot be reset tonullthis way. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
-
defaultCompressionMimeTypes
→ const List<
String> -
The media types compressed by default (
server.compression.mime-types), Spring Boot's list.