public class DefaultHttpServer extends java.lang.Object implements HttpServer, Closeable
| Modifier and Type | Class and Description |
|---|---|
class |
DefaultHttpServer.ServerHandler |
| Constructor and Description |
|---|
DefaultHttpServer(VertxInternal vertx) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the server.
|
void |
close(Handler<AsyncResult<java.lang.Void>> done)
Close the server.
|
int |
getAcceptBacklog() |
java.lang.String |
getKeyStorePassword() |
java.lang.String |
getKeyStorePath() |
int |
getReceiveBufferSize() |
int |
getSendBufferSize() |
int |
getSoLinger() |
int |
getTrafficClass() |
java.lang.String |
getTrustStorePassword() |
java.lang.String |
getTrustStorePath() |
boolean |
isClientAuthRequired()
Is client auth required?
|
boolean |
isReuseAddress() |
boolean |
isSSL() |
boolean |
isTCPKeepAlive() |
boolean |
isTCPNoDelay() |
boolean |
isUsePooledBuffers() |
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 |
setAcceptBacklog(int backlog)
Set the accept backlog
|
HttpServer |
setClientAuthRequired(boolean required)
Set
required to true if you want the server to request client authentication from any connecting clients. |
HttpServer |
setKeyStorePassword(java.lang.String pwd)
Set the password for the SSL key store.
|
HttpServer |
setKeyStorePath(java.lang.String path)
Set the path to the SSL key store.
|
HttpServer |
setReceiveBufferSize(int size)
Set the TCP receive buffer size for connections created by this instance to
size in bytes. |
HttpServer |
setReuseAddress(boolean reuse)
Set the TCP reuseAddress setting for connections created by this instance to
reuse. |
HttpServer |
setSendBufferSize(int size)
Set the TCP send buffer size for connections created by this instance to
size in bytes. |
HttpServer |
setSoLinger(int linger)
Set the TCP soLinger setting for connections created by this instance to
linger. |
HttpServer |
setSSL(boolean ssl)
If
ssl is true, this signifies that any connections will be SSL connections. |
HttpServer |
setTCPKeepAlive(boolean keepAlive)
Set the TCP keepAlive setting for connections created by this instance to
keepAlive. |
HttpServer |
setTCPNoDelay(boolean tcpNoDelay)
If
tcpNoDelay is set to true then Nagle's algorithm
will turned off for the TCP connections created by this instance. |
HttpServer |
setTrafficClass(int trafficClass)
Set the TCP trafficClass setting for connections created by this instance to
trafficClass. |
HttpServer |
setTrustStorePassword(java.lang.String pwd)
Set the password for the SSL trust store.
|
HttpServer |
setTrustStorePath(java.lang.String path)
Set the path to the SSL trust store.
|
HttpServer |
setUsePooledBuffers(boolean pooledBuffers)
Set if vertx should use pooled buffers for performance reasons.
|
Handler<ServerWebSocket> |
websocketHandler()
Get the websocket handler
|
HttpServer |
websocketHandler(Handler<ServerWebSocket> wsHandler)
Set the websocket handler for the server to
wsHandler. |
public DefaultHttpServer(VertxInternal vertx)
public HttpServer requestHandler(Handler<HttpServerRequest> requestHandler)
HttpServerrequestHandler. As HTTP requests are received by the server,
instances of HttpServerRequest will be created and passed to this handler.requestHandler in interface HttpServerpublic Handler<HttpServerRequest> requestHandler()
HttpServerrequestHandler in interface HttpServerpublic HttpServer websocketHandler(Handler<ServerWebSocket> wsHandler)
HttpServerwsHandler. If a websocket connect handshake is successful a
new ServerWebSocket instance will be created and passed to the handler.websocketHandler in interface HttpServerpublic Handler<ServerWebSocket> websocketHandler()
HttpServerwebsocketHandler in interface HttpServerpublic HttpServer listen(int port)
HttpServerport. Be aware this is an
async operation and the server may not bound on return of the method.listen in interface HttpServerpublic HttpServer listen(int port, java.lang.String host)
HttpServerport 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.listen in interface HttpServerpublic HttpServer listen(int port, Handler<AsyncResult<HttpServer>> listenHandler)
HttpServerportlisten in interface HttpServerpublic HttpServer listen(int port, java.lang.String host, Handler<AsyncResult<HttpServer>> listenHandler)
HttpServerport and hostname or ip address given by host.listen in interface HttpServerpublic void close()
HttpServerclose in interface HttpServerpublic void close(Handler<AsyncResult<java.lang.Void>> done)
HttpServerdoneHandler will be called when the close
is complete.close in interface HttpServerclose in interface Closeablepublic HttpServer setSSL(boolean ssl)
SSLSupportssl is true, this signifies that any connections will be SSL connections.setSSL in interface SSLSupport<HttpServer>public HttpServer setKeyStorePath(java.lang.String path)
SSLSupportSSLSupport.setSSL(boolean)
has been set to true.The SSL key store is a standard Java Key Store, and will contain the client certificate. Client certificates are only required if the server requests client authentication.
setKeyStorePath in interface SSLSupport<HttpServer>public HttpServer setKeyStorePassword(java.lang.String pwd)
SSLSupportSSLSupport.setSSL(boolean)
has been set to true.setKeyStorePassword in interface SSLSupport<HttpServer>public HttpServer setTrustStorePath(java.lang.String path)
SSLSupportSSLSupport.setSSL(boolean)
has been set to true.The trust store is a standard Java Key Store, and should contain the certificates of any servers that the client trusts.
setTrustStorePath in interface SSLSupport<HttpServer>public HttpServer setTrustStorePassword(java.lang.String pwd)
SSLSupportSSLSupport.setSSL(boolean)
has been set to true.setTrustStorePassword in interface SSLSupport<HttpServer>public HttpServer setClientAuthRequired(boolean required)
ServerSSLSupportrequired to true if you want the server to request client authentication from any connecting clients. This
is an extra level of security in SSL, and requires clients to provide client certificates. Those certificates must be added
to the server trust store.setClientAuthRequired in interface ServerSSLSupport<HttpServer>public HttpServer setTCPNoDelay(boolean tcpNoDelay)
TCPSupporttcpNoDelay is set to true then Nagle's algorithm
will turned off for the TCP connections created by this instance.setTCPNoDelay in interface TCPSupport<HttpServer>public HttpServer setSendBufferSize(int size)
TCPSupportsize in bytes.setSendBufferSize in interface TCPSupport<HttpServer>public HttpServer setReceiveBufferSize(int size)
TCPSupportsize in bytes.setReceiveBufferSize in interface TCPSupport<HttpServer>public HttpServer setTCPKeepAlive(boolean keepAlive)
TCPSupportkeepAlive.setTCPKeepAlive in interface TCPSupport<HttpServer>public HttpServer setReuseAddress(boolean reuse)
TCPSupportreuse.setReuseAddress in interface TCPSupport<HttpServer>public HttpServer setSoLinger(int linger)
TCPSupportlinger.
Using a negative value will disable soLinger.setSoLinger in interface TCPSupport<HttpServer>public HttpServer setTrafficClass(int trafficClass)
TCPSupporttrafficClass.setTrafficClass in interface TCPSupport<HttpServer>public HttpServer setAcceptBacklog(int backlog)
ServerTCPSupportsetAcceptBacklog in interface ServerTCPSupport<HttpServer>public boolean isTCPNoDelay()
isTCPNoDelay in interface TCPSupport<HttpServer>public int getSendBufferSize()
getSendBufferSize in interface TCPSupport<HttpServer>public int getReceiveBufferSize()
getReceiveBufferSize in interface TCPSupport<HttpServer>public boolean isTCPKeepAlive()
isTCPKeepAlive in interface TCPSupport<HttpServer>public boolean isReuseAddress()
isReuseAddress in interface TCPSupport<HttpServer>public int getSoLinger()
getSoLinger in interface TCPSupport<HttpServer>public int getTrafficClass()
getTrafficClass in interface TCPSupport<HttpServer>public int getAcceptBacklog()
getAcceptBacklog in interface ServerTCPSupport<HttpServer>public boolean isSSL()
isSSL in interface SSLSupport<HttpServer>public java.lang.String getKeyStorePath()
getKeyStorePath in interface SSLSupport<HttpServer>public java.lang.String getKeyStorePassword()
getKeyStorePassword in interface SSLSupport<HttpServer>public java.lang.String getTrustStorePath()
getTrustStorePath in interface SSLSupport<HttpServer>public java.lang.String getTrustStorePassword()
getTrustStorePassword in interface SSLSupport<HttpServer>public boolean isClientAuthRequired()
ServerSSLSupportisClientAuthRequired in interface ServerSSLSupport<HttpServer>public HttpServer setUsePooledBuffers(boolean pooledBuffers)
TCPSupportsetUsePooledBuffers in interface TCPSupport<HttpServer>public boolean isUsePooledBuffers()
isUsePooledBuffers in interface TCPSupport<HttpServer>true if pooled buffers are used