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
-
Method Summary
Modifier and TypeMethodDescriptionstatic HttpsServer
create()
Creates aHttpsServer
instance which is initially not bound to any local address/port.static HttpsServer
create
(InetSocketAddress addr, int backlog) Create aHttpsServer
instance which will bind to the specifiedInetSocketAddress
(IP address and port number).static HttpsServer
create
(InetSocketAddress addr, int backlog, String path, HttpHandler handler, Filter... filters) Creates anHttpsServer
instance with an initial context.abstract HttpsConfigurator
Gets this server'sHttpsConfigurator
object, if it has been set.abstract void
Sets this server'sHttpsConfigurator
object.Methods declared in class com.sun.net.httpserver.HttpServer
bind, createContext, createContext, getAddress, getExecutor, removeContext, removeContext, setExecutor, start, stop
-
Constructor Details
-
HttpsServer
protected HttpsServer()Constructor for subclasses to call.
-
-
Method Details
-
create
Creates aHttpsServer
instance which is initially not bound to any local address/port. TheHttpsServer
is acquired from the currently installedHttpServerProvider
. The server must be bound usingHttpServer.bind(InetSocketAddress,int)
before it can be used. The server must also have aHttpsConfigurator
established withsetHttpsConfigurator(HttpsConfigurator)
.- Returns:
- an instance of
HttpsServer
- Throws:
IOException
- if an I/O error occurs
-
create
Create aHttpsServer
instance which will bind to the specifiedInetSocketAddress
(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. TheHttpsServer
is acquired from the currently installedHttpServerProvider
. The server must have aHttpsConfigurator
established withsetHttpsConfigurator(HttpsConfigurator)
.- Parameters:
addr
- the address to listen on, ifnull
thenHttpServer.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.- Returns:
- an instance of
HttpsServer
- Throws:
BindException
- if the server cannot bind to the requested address, or if the server is already boundIOException
- if an I/O error occurs
-
create
public static HttpsServer create(InetSocketAddress addr, int backlog, String path, HttpHandler handler, Filter... filters) throws IOException Creates anHttpsServer
instance with an initial context.The server is created with an initial context that maps the URI
path
to the exchangehandler
. The initial context is created as if by an invocation ofcreateContext(path)
. Thefilters
, 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, ifnull
thenbind
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, optional- Returns:
- the HttpsServer
- Throws:
BindException
- 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 offilters
, arenull
- Since:
- 18
-
setHttpsConfigurator
Sets this server'sHttpsConfigurator
object.- Parameters:
config
- theHttpsConfigurator
to set- Throws:
NullPointerException
- if config isnull
-
getHttpsConfigurator
Gets this server'sHttpsConfigurator
object, if it has been set.- Returns:
- the
HttpsConfigurator
for this server, ornull
if not set
-