Class HttpsServer
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.
- Since:
- 1.6
Constructor Summary
| Modifier | Constructor | Description |
|---|---|---|
protected |
Constructor for subclasses to call. |
Method Summary
| 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. |
Methods declared in class HttpServer
bind, createContext, createContext, getAddress, getExecutor, removeContext, removeContext, setExecutor, start, stop | Modifier and Type | Method | Description |
|---|---|---|
abstract void |
bind |
Binds a currently unbound HttpServer to the given address and port number. |
abstract HttpContext |
createContext |
Creates a HttpContext without initially specifying a handler. |
abstract HttpContext |
createContext |
Creates a HttpContext. |
abstract InetSocketAddress |
getAddress() |
Returns the address this server is listening on |
abstract Executor |
getExecutor() |
Returns this server's Executor object if one was specified with HttpServer.setExecutor(Executor), or null if none was specified. |
abstract void |
removeContext |
Removes the given context from the server. |
abstract void |
removeContext |
Removes the context identified by the given path from the server. |
abstract void |
setExecutor |
Sets this server's Executor object. |
abstract void |
start() |
Starts this server in a new background thread. |
abstract void |
stop |
Stops this server by closing the listening socket and disallowing any new exchanges from being processed. |
Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | Modifier and Type | Method | Description |
|---|---|---|
protected Object |
clone() |
Creates and returns a copy of this object. |
boolean |
equals |
Indicates whether some other object is "equal to" this one. |
protected void |
finalize() |
Deprecated, for removal: This API element is subject to removal in a future version. Finalization is deprecated and subject to removal in a future release. |
final Class |
getClass() |
Returns the runtime class of this Object. |
int |
hashCode() |
Returns a hash code value for this object. |
final void |
notify() |
Wakes up a single thread that is waiting on this object's monitor. |
final void |
notifyAll() |
Wakes up all threads that are waiting on this object's monitor. |
String |
toString() |
Returns a string representation of the object. |
final void |
wait() |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted. |
final void |
wait |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed. |
final void |
wait |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed. |
Constructor Details
HttpsServer
protected HttpsServer()
Method Details
create
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).- Returns:
- an instance of
HttpsServer - Throws:
-
IOException- if an I/O error occurs
create
public 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).- Parameters:
-
addr- the address to listen on, ifnullthenHttpServer.bind(InetSocketAddress, int)must be called to set the address -
backlog- the socket backlog. If this value is less than or equal to zero, then a system default value is used. - Returns:
- an instance of
HttpsServer - Throws:
-
BindException- if the server cannot bind to the requested address, or if the server is already bound -
IOException- if an I/O error occurs
create
public 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).
- Parameters:
-
addr- the address to listen on, ifnullthenbindmust be called to set the address -
backlog- the socket backlog. If this value is less than or equal to zero, then a system default value is used -
path- the root URI path of the context, must be absolute -
handler- the HttpHandler for the context -
filters- the Filters for the context, optional - Returns:
- the HttpsServer
- Throws:
-
BindException- if the server cannot bind to the address -
IOException- if an I/O error occurs -
IllegalArgumentException- if path is invalid -
NullPointerException- if any of:path,handler,filters, or any element offilters, arenull - Since:
- 18
setHttpsConfigurator
public abstract void setHttpsConfigurator(HttpsConfigurator config)
HttpsConfigurator object.- Parameters:
-
config- theHttpsConfiguratorto set - Throws:
-
NullPointerException- if config isnull
getHttpsConfigurator
public abstract HttpsConfigurator getHttpsConfigurator()
HttpsConfigurator object, if it has been set.- Returns:
- the
HttpsConfiguratorfor this server, ornullif not set
© 1993, 2025, 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.