public abstract class HttpsServer extends HttpServer
HttpServer
which provides support for HTTPS. A HttpsServer
must have an associated HttpsConfigurator
object which is used to establish the SSL configuration for the SSL connections.
All other configuration is the same as for HttpServer
.
Modifier | Constructor | Description |
---|---|---|
protected |
Constructor for subclasses to call. |
Modifier and Type | Method | Description |
---|---|---|
static HttpsServer |
create() |
Creates a HttpsServer instance which is initially not bound to any local address/port. |
static HttpsServer |
create |
Create a HttpsServer instance which will bind to the specified InetSocketAddress (IP address and port number). |
static HttpsServer |
create |
Creates an HttpsServer instance with an initial context. |
abstract HttpsConfigurator |
getHttpsConfigurator() |
Gets this server's HttpsConfigurator object, if it has been set. |
abstract void |
setHttpsConfigurator |
Sets this server's HttpsConfigurator object. |
bind, createContext, createContext, getAddress, getExecutor, removeContext, removeContext, setExecutor, start, stop
protected HttpsServer()
public static HttpsServer create() throws IOException
HttpsServer
instance which is initially not bound to any local address/port. The HttpsServer
is acquired from the currently installed HttpServerProvider
. The server must be bound using HttpServer.bind(InetSocketAddress,int)
before it can be used. The server must also have a HttpsConfigurator
established with setHttpsConfigurator(HttpsConfigurator)
.HttpsServer
IOException
- if an I/O error occurspublic static HttpsServer create(InetSocketAddress addr, int backlog) throws IOException
HttpsServer
instance which will bind to the specified InetSocketAddress
(IP address and port number). A maximum backlog can also be specified. This is the maximum number of queued incoming connections to allow on the listening socket. Queued TCP connections exceeding this limit may be rejected by the TCP implementation. The HttpsServer
is acquired from the currently installed HttpServerProvider
. The server must have a HttpsConfigurator
established with setHttpsConfigurator(HttpsConfigurator)
.addr
- the address to listen on, if null
then HttpServer.bind(InetSocketAddress,int)
must be called to set the addressbacklog
- the socket backlog. If this value is less than or equal to zero, then a system default value is used.HttpsServer
BindException
- if the server cannot bind to the requested address, or if the server is already boundIOException
- if an I/O error occurspublic static HttpsServer create(InetSocketAddress addr, int backlog, String path, HttpHandler handler, Filter... filters) throws IOException
HttpsServer
instance with an initial context. The server is created with an initial context that maps the URI path
to the exchange handler
. The initial context is created as if by an invocation of createContext(path)
. The filters
, if any, are added to the initial context, in the order they are given. The returned server is not started so can be configured further if required.
The server instance will bind to the given InetSocketAddress
.
A maximum backlog can also be specified. This is the maximum number of queued incoming connections to allow on the listening socket. Queued TCP connections exceeding this limit may be rejected by the TCP implementation. The HttpsServer is acquired from the currently installed HttpServerProvider
.
The server must have an HttpsConfigurator established with setHttpsConfigurator(HttpsConfigurator)
.
addr
- the address to listen on, if null
then bind
must be called to set the addressbacklog
- the socket backlog. If this value is less than or equal to zero, then a system default value is usedpath
- the root URI path of the context, must be absolutehandler
- the HttpHandler for the contextfilters
- the Filters for the context, optionalBindException
- if the server cannot bind to the addressIOException
- if an I/O error occursIllegalArgumentException
- if path is invalidNullPointerException
- if any of: path
, handler
, filters
, or any element of filters
, are null
public abstract void setHttpsConfigurator(HttpsConfigurator config)
HttpsConfigurator
object.config
- the HttpsConfigurator
to setNullPointerException
- if config is null
public abstract HttpsConfigurator getHttpsConfigurator()
HttpsConfigurator
object, if it has been set.HttpsConfigurator
for this server, or null
if not set
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/jdk.httpserver/com/sun/net/httpserver/HttpsServer.html