Class RequestOptions
java.lang.Object
io.vertx.core.http.HttpConnectOptions
io.vertx.core.http.RequestOptions
- Direct Known Subclasses:
WebSocketConnectOptions
Options describing how an
HttpClient will connect to make a request.- Author:
- Julien Viet
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longThe default connect timeout =-1L(disabled)static final booleanFollow redirection by default =falsestatic final StringThe default value for host name =nullstatic final HttpMethodThe default value for HTTP method =HttpMethod.GETstatic final longThe default idle timeout =-1L(disabled)static final IntegerThe default value for port =nullstatic final SocketAddressThe default value for server method =nullstatic final BooleanThe default value for SSL =nullstatic final longThe default request timeout =-1L(disabled)static final StringThe default request URI ="/"Fields inherited from class HttpConnectOptions
DEFAULT_PROTOCOL_VERSION, DEFAULT_PROXY_OPTIONS -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructorRequestOptions(RequestOptions other) Copy constructorRequestOptions(JsonObject json) Create options from JSON -
Method Summary
Modifier and TypeMethodDescriptionaddHeader(CharSequence key, CharSequence value) Add a request header.addHeader(CharSequence key, Iterable<CharSequence> values) Add a request header.Get the request headerslongGet the HTTP method to be used by the client request.Return the routing key, the routing key can be used by a Vert.x client side sticky load balancer to pin the request to a remote HTTP server.longgetURI()protected voidinit()putHeader(CharSequence key, CharSequence value) Set a request header.putHeader(CharSequence key, Iterable<CharSequence> values) Set a request header.removeHeader(CharSequence key) Add a request header.removeHeader(String key) Add a request header.setAbsoluteURI(String absoluteURI) Parse an absolute URI to use, this will update thessl,host,portandurifields.setAbsoluteURI(URL url) LikesetAbsoluteURI(String)but using anURLparameter.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.setRoutingKey(String key) Set the routing key, the routing key can be used by a Vert.x client side sticky load balancer to pin the request to a remote HTTP server.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.setTimeout(long timeout) Sets both connect and idle timeouts for the request connect timeout: if the request is not obtained from the client within the timeout period, theFuture<HttpClientRequest>obtained from the client is failed with aTimeoutException. idle timeout: 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.Override the operation the tracer use for this request.Set the request relative URI.toJson()Methods inherited from class HttpConnectOptions
getConnectTimeout, getHost, getPort, getProtocolVersion, getProxyOptions, getServer, getSslOptions, isSsl
-
Field Details
-
DEFAULT_SERVER
The default value for server method =null -
DEFAULT_HTTP_METHOD
The default value for HTTP method =HttpMethod.GET -
DEFAULT_HOST
The default value for host name =null -
DEFAULT_PORT
The default value for port =null -
DEFAULT_SSL
The default value for SSL =null -
DEFAULT_URI
-
DEFAULT_FOLLOW_REDIRECTS
public static final boolean DEFAULT_FOLLOW_REDIRECTSFollow redirection by default =false- See Also:
-
DEFAULT_TIMEOUT
public static final long DEFAULT_TIMEOUTThe default request timeout =-1L(disabled)- See Also:
-
DEFAULT_CONNECT_TIMEOUT
public static final long DEFAULT_CONNECT_TIMEOUTThe default connect timeout =-1L(disabled)- See Also:
-
DEFAULT_IDLE_TIMEOUT
public static final long DEFAULT_IDLE_TIMEOUTThe default idle timeout =-1L(disabled)- See Also:
-
-
Constructor Details
-
RequestOptions
public RequestOptions()Default constructor -
RequestOptions
Copy constructor- Parameters:
other- the options to copy
-
RequestOptions
-
-
Method Details
-
init
protected void init()- Overrides:
initin classHttpConnectOptions
-
setProtocolVersion
Description copied from class:HttpConnectOptionsSet the desired HTTP protocol version for this connection.- Overrides:
setProtocolVersionin classHttpConnectOptions- Parameters:
protocolVersion- the desired protocol version- Returns:
- a reference to this, so the API can be used fluently
-
setProxyOptions
Description copied from class:HttpConnectOptionsOverride theHttpClientOptions.setProxyOptions(ProxyOptions)proxy options for connections.- Overrides:
setProxyOptionsin classHttpConnectOptions- Parameters:
proxyOptions- proxy options override object- 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 classHttpConnectOptions- Returns:
- a reference to this, so the API can be used fluently
-
getMethod
Get the HTTP method to be used by the client request.- Returns:
- the HTTP method
-
setMethod
Set the HTTP method to be used by the client 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 classHttpConnectOptions- 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 classHttpConnectOptions- 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 classHttpConnectOptions- 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 classHttpConnectOptions- Parameters:
sslOptions- the SSL options to use- Returns:
- a reference to this, so the API can be used fluently
-
getURI
- Returns:
- the request relative URI
-
setURI
Set the request relative URI.- Parameters:
uri- the relative uri- Returns:
- a reference to this, so the API can be used fluently
-
getFollowRedirects
- Returns:
truewhen the client should follow redirection
-
setFollowRedirects
Set whether to follow HTTP redirect- Parameters:
followRedirects- whether to follow redirect- Returns:
- a reference to this, so the API can be used fluently
-
getTimeout
public long getTimeout()- See Also:
-
setTimeout
Sets both connect and idle timeouts for the request- connect timeout: if the request is not obtained from the client within the timeout period, the
Future<HttpClientRequest>obtained from the client is failed with aTimeoutException. - idle timeout: if the request does not return any data within the timeout period, the request/response is closed and the
related futures are failed with a
TimeoutException, e.g.Future<HttpClientResponse>orFuture<Buffer>response body.
setConnectTimeout(long)andsetIdleTimeout(long) - connect timeout: if the request is not obtained from the client within the timeout period, the
-
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 classHttpConnectOptions- Parameters:
timeout- the amount of time in milliseconds.- Returns:
- a reference to this, so the API can be used fluently
-
getIdleTimeout
public long getIdleTimeout()- Returns:
- 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 a
TimeoutException
-
setIdleTimeout
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.Future<HttpClientResponse>orFuture<Buffer>response body. The timeout starts after a connection is obtained from the client, similar to callingHttpClientRequest.idleTimeout(long).- Parameters:
timeout- the amount of time in milliseconds.- Returns:
- a reference to this, so the API can be used fluently
-
setAbsoluteURI
Parse an absolute URI to use, this will update thessl,host,portandurifields.- Parameters:
absoluteURI- the uri to use- Returns:
- a reference to this, so the API can be used fluently
-
setAbsoluteURI
LikesetAbsoluteURI(String)but using anURLparameter.- Parameters:
url- the uri to use- Returns:
- a reference to this, so the API can be used fluently
-
addHeader
Add a request header.- Parameters:
key- the header keyvalue- the header value- Returns:
- a reference to this, so the API can be used fluently
-
addHeader
Add a request header.- Parameters:
key- the header keyvalue- the header value- Returns:
- a reference to this, so the API can be used fluently
-
addHeader
-
putHeader
Set a request header.- Parameters:
key- the header keyvalue- the header value- Returns:
- a reference to this, so the API can be used fluently
-
putHeader
Set a request header.- Parameters:
key- the header keyvalue- the header value- Returns:
- a reference to this, so the API can be used fluently
-
putHeader
-
removeHeader
Add a request header.- Parameters:
key- the header key- Returns:
- a reference to this, so the API can be used fluently
-
removeHeader
Add a request header.- Parameters:
key- the header key- Returns:
- a reference to this, so the API can be used fluently
-
setHeaders
Set request headers from a multi-map.- Parameters:
headers- the headers- Returns:
- a reference to this, so the API can be used fluently
-
getHeaders
-
getTraceOperation
- Returns:
- the trace operation override
-
setTraceOperation
Override the operation the tracer use for this request. When no operation is set, the HTTP method is used instead.- Parameters:
op- the override- Returns:
- a reference to this, so the API can be used fluently
-
getRoutingKey
Return the routing key, the routing key can be used by a Vert.x client side sticky load balancer to pin the request to a remote HTTP server.- Returns:
- the routing key
-
setRoutingKey
Set the routing key, the routing key can be used by a Vert.x client side sticky load balancer to pin the request to a remote HTTP server.- Parameters:
key- the routing key- Returns:
- a reference to this, so the API can be used fluently
-
toJson
- Overrides:
toJsonin classHttpConnectOptions
-