Class HttpsServer
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic HttpsServercreate()Creates aHttpsServerinstance which is initially not bound to any local address/port.static HttpsServercreate(InetSocketAddress addr, int backlog) Create aHttpsServerinstance which will bind to the specifiedInetSocketAddress(IP address and port number).static HttpsServercreate(InetSocketAddress addr, int backlog, String path, HttpHandler handler, Filter... filters) Creates anHttpsServerinstance with an initial context.abstract HttpsConfiguratorGets this server'sHttpsConfiguratorobject, if it has been set.abstract voidSets this server'sHttpsConfiguratorobject.Methods declared in class HttpServer
bind, createContext, createContext, getAddress, getExecutor, removeContext, removeContext, setExecutor, start, stopModifier and TypeMethodDescriptionabstract voidbind(InetSocketAddress addr, int backlog) Binds a currently unboundHttpServerto the given address and port number.abstract HttpContextcreateContext(String path) Creates a HttpContext without initially specifying a handler.abstract HttpContextcreateContext(String path, HttpHandler handler) Creates aHttpContext.abstract InetSocketAddressReturns the address this server is listening onabstract ExecutorReturns this server'sExecutorobject if one was specified withHttpServer.setExecutor(Executor), ornullif none was specified.abstract voidremoveContext(HttpContext context) Removes the given context from the server.abstract voidremoveContext(String path) Removes the context identified by the given path from the server.abstract voidsetExecutor(Executor executor) Sets this server'sExecutorobject.abstract voidstart()Starts this server in a new background thread.abstract voidstop(int delay) 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, waitModifier and TypeMethodDescriptionprotected Objectclone()Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.booleanCompares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.inthashCode()Answers an integer hash code for the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.toString()Answers a string containing a concise, human-readable description of the receiver.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.
-
Constructor Details
-
HttpsServer
protected HttpsServer()Constructor for subclasses to call.
-
-
Method Details
-
create
Creates aHttpsServerinstance which is initially not bound to any local address/port. TheHttpsServeris acquired from the currently installedHttpServerProvider. The server must be bound usingHttpServer.bind(InetSocketAddress, int)before it can be used. The server must also have aHttpsConfiguratorestablished withsetHttpsConfigurator(HttpsConfigurator).- Returns:
- an instance of
HttpsServer - Throws:
IOException- if an I/O error occurs
-
create
Create aHttpsServerinstance 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. TheHttpsServeris acquired from the currently installedHttpServerProvider. The server must have aHttpsConfiguratorestablished withsetHttpsConfigurator(HttpsConfigurator).- Parameters:
addr- the address to listen on, ifnullthenHttpServer.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 anHttpsServerinstance with an initial context.The server is created with an initial context that maps the URI
pathto 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, ifnullthenbindmust 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'sHttpsConfiguratorobject.- Parameters:
config- theHttpsConfiguratorto set- Throws:
NullPointerException- if config isnull
-
getHttpsConfigurator
Gets this server'sHttpsConfiguratorobject, if it has been set.- Returns:
- the
HttpsConfiguratorfor this server, ornullif not set
-