java.lang.Object
com.sun.net.httpserver.HttpServer
com.sun.net.httpserver.HttpsServer
dev.katsute.simplehttpserver.SimpleHttpsServer
A
HttpsServer
with additional extensions to simplify usage. See SimpleHttpServer
for setup documentation.- Since:
- 5.0.0
- Version:
- 5.0.0
- Author:
- Katsute
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbind
(int port) Binds the server to a port.bind
(int port, int backlog) Binds the server to a port.static SimpleHttpsServer
create()
Creates an unbounded https server.static SimpleHttpsServer
create
(int port) Creates an https server bounded to a port.static SimpleHttpsServer
create
(int port, int backlog) Creates an https server bounded to a port.getContextHandler
(HttpContext context) Returns the handler for a given context.getContextHandler
(String context) Returns the handler for a given context.Returns a map of all the contexts registered to the server.abstract HttpsServer
Returns the underlying http server.Returns a random context that doesn't yet exist on the server.getRandomContext
(String context) Returns a random context prefixed by a set context.getSession
(HttpExchange exchange) Returns the session for a given exchange.void
setSessionHandler
(HttpSessionHandler sessionHandler) Sets as session handler to use for the server.void
stop()
Stops the server immediately without waiting.Methods inherited from class com.sun.net.httpserver.HttpsServer
create, create, getHttpsConfigurator, setHttpsConfigurator
Methods inherited from class com.sun.net.httpserver.HttpServer
bind, createContext, createContext, getAddress, getExecutor, removeContext, removeContext, setExecutor, start, stop
-
Method Details
-
create
Creates an unbounded https server.- Returns:
- http server
- Throws:
IOException
- IO exception- Since:
- 5.0.0
- See Also:
-
create
Creates an https server bounded to a port.- Parameters:
port
- to bind to- Returns:
- http server
- Throws:
IOException
- IO exceptionBindException
- if server could not be bounded- Since:
- 5.0.0
- See Also:
-
create
Creates an https server bounded to a port.- Parameters:
port
- to bind tobacklog
- maximum amount of inbound connections at any given time- Returns:
- http server
- Throws:
IOException
- IO exceptionBindException
- if server could not be bounded- Since:
- 5.0.0
- See Also:
-
getHttpsServer
Returns the underlying http server.- Returns:
- http server
- Since:
- 5.0.0
- See Also:
-
bind
Binds the server to a port.- Parameters:
port
- port to bind to- Returns:
- server address
- Throws:
IOException
- internal errorBindException
- if server could not be bounded- Since:
- 5.0.0
- See Also:
-
bind
Binds the server to a port.- Parameters:
port
- port to bind tobacklog
- maximum amount of inbound connections at any given time- Returns:
- server address
- Throws:
IOException
- internal errorBindException
- if server could not be bounded- Since:
- 5.0.0
- See Also:
-
setSessionHandler
Sets as session handler to use for the server.- Parameters:
sessionHandler
- session handler- Since:
- 5.0.0
- See Also:
-
getSessionHandler
HttpSessionHandler getSessionHandler() -
getSession
Returns the session for a given exchange.- Parameters:
exchange
- http exchange- Returns:
- session associated with an exchange
- Since:
- 5.0.0
- See Also:
-
getContextHandler
Returns the handler for a given context.- Parameters:
context
- context- Returns:
- handler for context
- Since:
- 5.0.0
- See Also:
-
getContextHandler
Returns the handler for a given context.- Parameters:
context
- http context- Returns:
- handler for context
- Since:
- 5.0.0
- See Also:
-
getContexts
Map<HttpContext,HttpHandler> getContexts()Returns a map of all the contexts registered to the server.- Returns:
- map of contexts
- Since:
- 5.0.0
- See Also:
-
getRandomContext
String getRandomContext()Returns a random context that doesn't yet exist on the server.- Returns:
- random unused context
- Since:
- 5.0.0
- See Also:
-
getRandomContext
Returns a random context prefixed by a set context.- Parameters:
context
- context to prefix- Returns:
- random unused context with prefix
- Since:
- 5.0.0
- See Also:
-
stop
void stop()Stops the server immediately without waiting.- Since:
- 5.0.0
- See Also:
-