Interface MuServer
-
public interface MuServerA web server handler. Create and start a web server by usingMuServerBuilder.httpsServer()orMuServerBuilder.httpServer()
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.util.Set<HttpConnection>activeConnections()java.net.InetSocketAddressaddress()static java.lang.StringartifactVersion()voidchangeHttpsConfig(HttpsConfigBuilder newHttpsConfig)Changes the HTTPS certificate.booleangzipEnabled()Specifies whether GZIP is on or not.java.net.URIhttpsUri()java.net.URIhttpUri()intmaxRequestHeadersSize()The maximum allowed size of request headers.longmaxRequestSize()The maximum allowed size of a request body.intmaxUrlSize()The maximum allowed size of the URI sent in a request line.java.util.Set<java.lang.String>mimeTypesToGzip()Specifies the mime-types that GZIP should be applied to.longminimumGzipSize()The size a response body must be before GZIP is enabled, ifgzipEnabled()is true and the mime type is inmimeTypesToGzip()java.util.List<RateLimiter>rateLimiters()longrequestIdleTimeoutMillis()The maximum idle timeout for reading request bodies.SSLInfosslInfo()Gets the SSL info of the server, or null if SSL is not enabled.MuStatsstats()default voidstop()Shuts down the serverbooleanstop(long duration, java.util.concurrent.TimeUnit unit)Gracefully shuts down the server with a timeout.java.net.URIuri()
-
-
-
Method Detail
-
stop
default void stop()
Shuts down the server
-
stop
boolean stop(long duration, java.util.concurrent.TimeUnit unit)Gracefully shuts down the server with a timeout. During the graceful shutdown period, the server will stop accepting new connections and wait for in-flight requests to complete. When timeout is reached and there are still in-flight requests, all the http connections will be aborted, no exception will be thrown.This is a blocking call and will not return until the server is fully stopped or the timeout is reached.
- Parameters:
duration- The duration of the graceful timeout period, or 0 to shut down immediately.unit- The time unit of the duration.- Returns:
- false if there were in-flight requests not completed.
-
uri
java.net.URI uri()
- Returns:
- The HTTPS (or if unavailable the HTTP) URI of the web server.
-
httpUri
java.net.URI httpUri()
- Returns:
- The HTTP URI of the web server, if HTTP is supported; otherwise null
-
httpsUri
java.net.URI httpsUri()
- Returns:
- The HTTPS URI of the web server, if HTTPS is supported; otherwise null
-
stats
MuStats stats()
- Returns:
- Provides stats about the server
-
activeConnections
java.util.Set<HttpConnection> activeConnections()
- Returns:
- The current HTTP connections between this server and its clients.
-
address
java.net.InetSocketAddress address()
- Returns:
- The address of the server. To get the ip address, use
InetSocketAddress.getAddress()and on that callInetAddress.getHostAddress(). To get the hostname, useInetSocketAddress.getHostName()orInetSocketAddress.getHostString().
-
artifactVersion
static java.lang.String artifactVersion()
- Returns:
- Returns the current version of MuServer, or 0.x if unknown
-
minimumGzipSize
long minimumGzipSize()
The size a response body must be before GZIP is enabled, ifgzipEnabled()is true and the mime type is inmimeTypesToGzip()This can only be set at point of server creation with
MuServerBuilder.withGzip(long, Set)- Returns:
- Size in bytes.
-
maxRequestHeadersSize
int maxRequestHeadersSize()
The maximum allowed size of request headers.This can only be set at point of server creation with
MuServerBuilder.withMaxHeadersSize(int)- Returns:
- Size in bytes.
-
requestIdleTimeoutMillis
long requestIdleTimeoutMillis()
The maximum idle timeout for reading request bodies.This can only be set at point of server creation with
MuServerBuilder.withIdleTimeout(long, TimeUnit)- Returns:
- Timeout in milliseconds.
-
maxRequestSize
long maxRequestSize()
The maximum allowed size of a request body.This can only be set at point of server creation with
MuServerBuilder.withMaxRequestSize(long)- Returns:
- Size in bytes.
-
maxUrlSize
int maxUrlSize()
The maximum allowed size of the URI sent in a request line.This can only be set at point of server creation with
MuServerBuilder.withMaxUrlSize(int)- Returns:
- Length of allowed URI string.
-
gzipEnabled
boolean gzipEnabled()
Specifies whether GZIP is on or not.This can only be set at point of server creation with
MuServerBuilder.withGzipEnabled(boolean)orMuServerBuilder.withGzip(long, Set)- Returns:
- True if gzip is enabled for responses that match gzip criteria; otherwise false.
-
mimeTypesToGzip
java.util.Set<java.lang.String> mimeTypesToGzip()
Specifies the mime-types that GZIP should be applied to.This can only be set at point of server creation with
MuServerBuilder.withGzip(long, Set)- Returns:
- A set of mime-types.
-
changeHttpsConfig
void changeHttpsConfig(HttpsConfigBuilder newHttpsConfig)
Changes the HTTPS certificate. This can be changed without restarting the server.- Parameters:
newHttpsConfig- The new SSL Context to use.
-
sslInfo
SSLInfo sslInfo()
Gets the SSL info of the server, or null if SSL is not enabled.- Returns:
- A description of the actual SSL settings used, or null.
-
rateLimiters
java.util.List<RateLimiter> rateLimiters()
- Returns:
- The rate limiters added to the server with
MuServerBuilder.withRateLimiter(RateLimitSelector), in the order they are applied.
-
-