Class WebSocketConnectOptions
java.lang.Object
io.vertx.core.http.HttpConnectOptions
io.vertx.core.http.RequestOptions
io.vertx.core.http.WebSocketConnectOptions
Options describing how an
HttpClient connect a WebSocket.- Author:
- Julien Viet
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanThe default WebSocket allow origin header =truestatic final ProxyOptionsThe default value for proxy options =nullstatic final booleanWhether write-handlers should be registered by default = false.The default WebSocket sub protocols =nullstatic final WebSocketVersionThe default WebSocket version =WebSocketVersion.V13Fields inherited from class RequestOptions
DEFAULT_CONNECT_TIMEOUT, DEFAULT_FOLLOW_REDIRECTS, DEFAULT_HOST, DEFAULT_HTTP_METHOD, DEFAULT_IDLE_TIMEOUT, DEFAULT_PORT, DEFAULT_SERVER, DEFAULT_SSL, DEFAULT_TIMEOUT, DEFAULT_URIFields inherited from class HttpConnectOptions
DEFAULT_PROTOCOL_VERSION -
Constructor Summary
ConstructorsConstructorDescription -
Method Summary
Modifier and TypeMethodDescriptionaddHeader(CharSequence key, CharSequence value) Add a request header.addHeader(CharSequence key, Iterable<CharSequence> values) Add a request header.addSubProtocol(String subprotocol) Add a WebSocket sub protocol to use.booleanGet the proxy options override for connectionsbooleanputHeader(CharSequence key, CharSequence value) Set a request header.putHeader(CharSequence key, Iterable<CharSequence> values) Set a request header.setAbsoluteURI(String absoluteURI) Parse an absolute URI to use, this will update thessl,host,portandurifields.setAbsoluteURI(URL url) LikeRequestOptions.setAbsoluteURI(String)but using anURLparameter.setAllowOriginHeader(boolean allowOriginHeader) Set whether to add theoriginheader to the WebSocket handshake request, enabled by default.setConnectTimeout(long timeout) Sets the amount of time after which, if the request is not obtained from the client within the timeout period, theFuture<HttpClientRequest>obtained from the client is failed with aTimeoutException.setFollowRedirects(Boolean followRedirects) Set whether to follow HTTP redirectsetHeaders(MultiMap headers) Set request headers from a multi-map.Set the host name to be used by the client request.setIdleTimeout(long timeout) Sets the amount of time after which, if the request does not return any data within the timeout period, the request/response is closed and the related futures are failed with aTimeoutException, e.g.setMethod(HttpMethod method) Set the HTTP method to be used by the client request.Set the port to be used by the client request.setProtocolVersion(HttpVersion protocolVersion) Set the desired HTTP protocol version for this connection.setProxyOptions(ProxyOptions proxyOptions) Override theHttpClientOptions.setProxyOptions(ProxyOptions)proxy options for connections.setRegisterWriteHandlers(boolean registerWriteHandlers) Whether write-handlers should be registered on theEventBus.Set the server address to be used by the client request.Set whether SSL/TLS is enabled.setSslOptions(ClientSSLOptions sslOptions) Set the SSL options to use.setSubProtocols(List<String> subProtocols) Set the WebSocket sub protocols to use.setTimeout(long timeout) Sets the amount of time after which if the WebSocket handshake does not happen within the timeout period anWebSocketHandshakeExceptionwill be passed to the exception handler and the connection will be closed.Override the operation the tracer use for this request.Set the request relative URI.setVersion(WebSocketVersion version) Set the WebSocket version.toJson()Methods inherited from class RequestOptions
getFollowRedirects, getHeaders, getIdleTimeout, getMethod, getRoutingKey, getTimeout, getTraceOperation, getURI, init, removeHeader, removeHeader, setRoutingKeyMethods inherited from class HttpConnectOptions
getConnectTimeout, getHost, getPort, getProtocolVersion, getServer, getSslOptions, isSsl
-
Field Details
-
DEFAULT_PROXY_OPTIONS
The default value for proxy options =null -
DEFAULT_VERSION
The default WebSocket version =WebSocketVersion.V13 -
DEFAULT_SUB_PROTOCOLS
-
DEFAULT_ALLOW_ORIGIN_HEADER
public static final boolean DEFAULT_ALLOW_ORIGIN_HEADERThe default WebSocket allow origin header =true- See Also:
-
DEFAULT_REGISTER_WRITE_HANDLERS
public static final boolean DEFAULT_REGISTER_WRITE_HANDLERSWhether write-handlers should be registered by default = false.- See Also:
-
-
Constructor Details
-
WebSocketConnectOptions
public WebSocketConnectOptions() -
WebSocketConnectOptions
-
WebSocketConnectOptions
-
-
Method Details
-
getVersion
- Returns:
- the WebSocket version
-
setVersion
Set the WebSocket version.- Returns:
- a reference to this, so the API can be used fluently
-
getSubProtocols
-
setSubProtocols
Set the WebSocket sub protocols to use.- Returns:
- a reference to this, so the API can be used fluently
-
addSubProtocol
Add a WebSocket sub protocol to use.- Returns:
- a reference to this, so the API can be used fluently
-
getProxyOptions
Get the proxy options override for connections- Overrides:
getProxyOptionsin classHttpConnectOptions- Returns:
- proxy options override
-
setProxyOptions
Override theHttpClientOptions.setProxyOptions(ProxyOptions)proxy options for connections.- Overrides:
setProxyOptionsin classRequestOptions- Parameters:
proxyOptions- proxy options override object- Returns:
- a reference to this, so the API can be used fluently
-
getAllowOriginHeader
public boolean getAllowOriginHeader()- Returns:
- whether to add the
originheader to the WebSocket handshake request
-
setAllowOriginHeader
Set whether to add theoriginheader to the WebSocket handshake request, enabled by default.Set to
falsewhen a server does not accept WebSocket with an origin header.- Parameters:
allowOriginHeader- whether to add theoriginheader to the WebSocket handshake request- Returns:
- a reference to this, so the API can be used fluently
-
setHost
Description copied from class:HttpConnectOptionsSet the host name to be used by the client request.- Overrides:
setHostin classRequestOptions- Returns:
- a reference to this, so the API can be used fluently
-
setPort
Description copied from class:HttpConnectOptionsSet the port to be used by the client request.- Overrides:
setPortin classRequestOptions- Returns:
- a reference to this, so the API can be used fluently
-
setSsl
Description copied from class:HttpConnectOptionsSet whether SSL/TLS is enabled.- Overrides:
setSslin classRequestOptions- Parameters:
ssl- true if enabled- Returns:
- a reference to this, so the API can be used fluently
-
setSslOptions
Description copied from class:HttpConnectOptionsSet the SSL options to use.When none is provided, the client SSL options will be used instead.
- Overrides:
setSslOptionsin classRequestOptions- Parameters:
sslOptions- the SSL options to use- Returns:
- a reference to this, so the API can be used fluently
-
setURI
Description copied from class:RequestOptionsSet the request relative URI.- Overrides:
setURIin classRequestOptions- Parameters:
uri- the relative uri- Returns:
- a reference to this, so the API can be used fluently
-
setTimeout
Sets the amount of time after which if the WebSocket handshake does not happen within the timeout period anWebSocketHandshakeExceptionwill be passed to the exception handler and the connection will be closed.- Overrides:
setTimeoutin classRequestOptions- Parameters:
timeout- the amount of time in milliseconds.- Returns:
- a reference to this, so the API can be used fluently
-
setConnectTimeout
Description copied from class:HttpConnectOptionsSets the amount of time after which, if the request is not obtained from the client within the timeout period, theFuture<HttpClientRequest>obtained from the client is failed with aTimeoutException. Note this is not related to the TCPHttpClientOptions.setConnectTimeout(int)option, when a request is made against a pooled HTTP client, the timeout applies to the duration to obtain a connection from the pool to serve the request, the timeout might fire because the server does not respond in time or the pool is too busy to serve a request.- Overrides:
setConnectTimeoutin classRequestOptions- Parameters:
timeout- the amount of time in milliseconds.- Returns:
- a reference to this, so the API can be used fluently
-
setIdleTimeout
Description copied from class:RequestOptionsSets the amount of time after which, if the request does not return any data within the timeout period, the request/response is closed and the related futures are failed with aTimeoutException, e.g.Future<HttpClientResponse>orFuture<Buffer>response body. The timeout starts after a connection is obtained from the client, similar to callingHttpClientRequest.idleTimeout(long).- Overrides:
setIdleTimeoutin classRequestOptions- Parameters:
timeout- the amount of time in milliseconds.- Returns:
- a reference to this, so the API can be used fluently
-
addHeader
Description copied from class:RequestOptionsAdd a request header.- Overrides:
addHeaderin classRequestOptions- Parameters:
key- the header keyvalue- the header value- Returns:
- a reference to this, so the API can be used fluently
-
addHeader
Description copied from class:RequestOptionsAdd a request header.- Overrides:
addHeaderin classRequestOptions- Parameters:
key- the header keyvalue- the header value- Returns:
- a reference to this, so the API can be used fluently
-
addHeader
- Overrides:
addHeaderin classRequestOptions
-
putHeader
Description copied from class:RequestOptionsSet a request header.- Overrides:
putHeaderin classRequestOptions- Parameters:
key- the header keyvalue- the header value- Returns:
- a reference to this, so the API can be used fluently
-
putHeader
Description copied from class:RequestOptionsSet a request header.- Overrides:
putHeaderin classRequestOptions- Parameters:
key- the header keyvalue- the header value- Returns:
- a reference to this, so the API can be used fluently
-
putHeader
- Overrides:
putHeaderin classRequestOptions
-
setHeaders
Description copied from class:RequestOptionsSet request headers from a multi-map.- Overrides:
setHeadersin classRequestOptions- Parameters:
headers- the headers- Returns:
- a reference to this, so the API can be used fluently
-
setProtocolVersion
Description copied from class:HttpConnectOptionsSet the desired HTTP protocol version for this connection.- Overrides:
setProtocolVersionin classRequestOptions- Parameters:
protocolVersion- the desired protocol version- Returns:
- a reference to this, so the API can be used fluently
-
setServer
Description copied from class:HttpConnectOptionsSet the server address to be used by the client request.When the server address is
null, the address will be resolved after thehostproperty by the Vert.x resolver.Use this when you want to connect to a specific server address without name resolution.
- Overrides:
setServerin classRequestOptions- Returns:
- a reference to this, so the API can be used fluently
-
setMethod
Description copied from class:RequestOptionsSet the HTTP method to be used by the client request.- Overrides:
setMethodin classRequestOptions- Returns:
- a reference to this, so the API can be used fluently
-
setFollowRedirects
Description copied from class:RequestOptionsSet whether to follow HTTP redirect- Overrides:
setFollowRedirectsin classRequestOptions- Parameters:
followRedirects- whether to follow redirect- Returns:
- a reference to this, so the API can be used fluently
-
setAbsoluteURI
Description copied from class:RequestOptionsParse an absolute URI to use, this will update thessl,host,portandurifields.- Overrides:
setAbsoluteURIin classRequestOptions- Parameters:
absoluteURI- the uri to use- Returns:
- a reference to this, so the API can be used fluently
-
setAbsoluteURI
Description copied from class:RequestOptionsLikeRequestOptions.setAbsoluteURI(String)but using anURLparameter.- Overrides:
setAbsoluteURIin classRequestOptions- Parameters:
url- the uri to use- Returns:
- a reference to this, so the API can be used fluently
-
setTraceOperation
Description copied from class:RequestOptionsOverride the operation the tracer use for this request. When no operation is set, the HTTP method is used instead.- Overrides:
setTraceOperationin classRequestOptions- Parameters:
op- the override- Returns:
- a reference to this, so the API can be used fluently
-
toJson
- Overrides:
toJsonin classRequestOptions
-
isRegisterWriteHandlers
public boolean isRegisterWriteHandlers()- Returns:
trueif write-handlers should be registered on theEventBus, otherwisefalse
-
setRegisterWriteHandlers
Whether write-handlers should be registered on theEventBus.Defaults to
false.- Parameters:
registerWriteHandlers- true to register write-handlers- Returns:
- a reference to this, so the API can be used fluently
- See Also:
-