public interface HttpServer extends ServerSSLSupport<HttpServer>, ServerTCPSupport<HttpServer>
If an instance is instantiated from an event loop then the handlers of the instance will always be called on that same event loop. If an instance is instantiated from some other arbitrary Java thread then an event loop will be assigned to the instance and used when any of its handlers are called.
Instances of HttpServer are thread-safe.
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the server.
|
void |
close(Handler<AsyncResult<java.lang.Void>> doneHandler)
Close the server.
|
int |
getMaxWebSocketFrameSize()
Get the maximum websocket frame size in bytes.
|
java.util.Set<java.lang.String> |
getWebSocketSubProtocols()
Returns a immutable
Set which holds all the supported subprotocols. |
boolean |
isCompressionSupported()
Returns
true if the HttpServer should compress the http response if the connected client supports it. |
HttpServer |
listen(int port)
Tell the server to start listening on all available interfaces and port
port . |
HttpServer |
listen(int port,
Handler<AsyncResult<HttpServer>> listenHandler)
Tell the server to start listening on all available interfaces and port
port |
HttpServer |
listen(int port,
java.lang.String host)
Tell the server to start listening on port
port and hostname or ip address given by host . |
HttpServer |
listen(int port,
java.lang.String host,
Handler<AsyncResult<HttpServer>> listenHandler)
Tell the server to start listening on port
port and hostname or ip address given by host . |
Handler<HttpServerRequest> |
requestHandler()
Get the request handler
|
HttpServer |
requestHandler(Handler<HttpServerRequest> requestHandler)
Set the request handler for the server to
requestHandler . |
HttpServer |
setCompressionSupported(boolean compressionSupported)
Set if the
HttpServer should compress the http response if the connected client supports it. |
HttpServer |
setMaxWebSocketFrameSize(int maxSize)
Sets the maximum websocket frame size in bytes.
|
HttpServer |
setWebSocketSubProtocols(java.lang.String... subProtocols)
Set the supported websocket subprotocols.
|
Handler<ServerWebSocket> |
websocketHandler()
Get the websocket handler
|
HttpServer |
websocketHandler(Handler<ServerWebSocket> wsHandler)
Set the websocket handler for the server to
wsHandler . |
isClientAuthRequired, setClientAuthRequired
getKeyStorePassword, getKeyStorePath, getTrustStorePassword, getTrustStorePath, isSSL, setKeyStorePassword, setKeyStorePath, setSSL, setSSLContext, setTrustStorePassword, setTrustStorePath
getAcceptBacklog, setAcceptBacklog
getSoLinger, isTCPKeepAlive, isTCPNoDelay, isUsePooledBuffers, setSoLinger, setTCPKeepAlive, setTCPNoDelay, setUsePooledBuffers
getReceiveBufferSize, getSendBufferSize, getTrafficClass, isReuseAddress, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setTrafficClass
HttpServer requestHandler(Handler<HttpServerRequest> requestHandler)
requestHandler
. As HTTP requests are received by the server,
instances of HttpServerRequest
will be created and passed to this handler.Handler<HttpServerRequest> requestHandler()
HttpServer websocketHandler(Handler<ServerWebSocket> wsHandler)
wsHandler
. If a websocket connect handshake is successful a
new ServerWebSocket
instance will be created and passed to the handler.Handler<ServerWebSocket> websocketHandler()
HttpServer listen(int port)
port
. Be aware this is an
async operation and the server may not bound on return of the method.HttpServer listen(int port, Handler<AsyncResult<HttpServer>> listenHandler)
port
HttpServer listen(int port, java.lang.String host)
port
and hostname or ip address given by host
. Be aware this is an
async operation and the server may not bound on return of the method.HttpServer listen(int port, java.lang.String host, Handler<AsyncResult<HttpServer>> listenHandler)
port
and hostname or ip address given by host
.void close()
void close(Handler<AsyncResult<java.lang.Void>> doneHandler)
doneHandler
will be called when the close
is complete.HttpServer setCompressionSupported(boolean compressionSupported)
HttpServer
should compress the http response if the connected client supports it.boolean isCompressionSupported()
true
if the HttpServer
should compress the http response if the connected client supports it.HttpServer setMaxWebSocketFrameSize(int maxSize)
maxSize
- The size in bytesint getMaxWebSocketFrameSize()
HttpServer setWebSocketSubProtocols(java.lang.String... subProtocols)
java.util.Set<java.lang.String> getWebSocketSubProtocols()
Set
which holds all the supported subprotocols. An empty set is returned if
non are supported. This is the default.