Top Description Fields Constructors Methods
io.vertx.core.http

public Class RequestOptions

extends Object
Class Inheritance
Known Direct Subclasses
io.vertx.core.http.WebSocketConnectOptions
Annotations
@DataObject
@JsonGen
publicConverter:false
Imports
io.vertx.codegen.annotations.DataObject, .GenIgnore, io.vertx.codegen.json.annotations.JsonGen, io.vertx.core.MultiMap, .VertxException, io.vertx.core.json.JsonObject, io.vertx.core.net.ProxyOptions, .SocketAddress, java.net.MalformedURLException, .URL, java.util.List, .Map, .Objects

Options describing how an HttpClient will connect to make a request.
Author
Julien Viet

Field Summary

Modifier and TypeField and Description
private long
public static final long
DEFAULT_CONNECT_TIMEOUT

The default connect timeout = -1L (disabled)

public static final boolean
DEFAULT_FOLLOW_REDIRECTS

Follow redirection by default = false

public static final String
DEFAULT_HOST

The default value for host name = null

public static final HttpMethod
DEFAULT_HTTP_METHOD

The default value for HTTP method = HttpMethod#GET

public static final long
DEFAULT_IDLE_TIMEOUT

The default idle timeout = -1L (disabled)

public static final Integer
DEFAULT_PORT

The default value for port = null

public static final ProxyOptions
DEFAULT_PROXY_OPTIONS

The default value for proxy options = null

public static final SocketAddress
DEFAULT_SERVER

The default value for server method = null

public static final Boolean
DEFAULT_SSL

The default value for SSL = null

public static final long
DEFAULT_TIMEOUT

The default request timeout = -1L (disabled)

public static final String
DEFAULT_URI

The default request URI = "/"

private boolean
private MultiMap
private String
private long
private HttpMethod
private Integer
private ProxyOptions
private SocketAddress
private Boolean
private long
private String
private String

Constructor Summary

AccessConstructor and Description
public
RequestOptions()

Default constructor

public
RequestOptions(RequestOptions
the options to copy
other
)

Copy constructor

public
RequestOptions(JsonObject
the JSON
json
)
References Deprecated JsonObject is deprecated or references (maybe indirectly) at least one deprecated element.

Create options from JSON

Method Summary

Modifier and TypeMethod and Description
public RequestOptions

Returns:

a reference to this, so the API can be used fluently
addHeader
(String
the header key
key
,
String
the header value
value
)

Add a request header.

public RequestOptions

Returns:

a reference to this, so the API can be used fluently
addHeader
(CharSequence
the header key
key
,
CharSequence
the header value
value
)

Add a request header.

public RequestOptions
private void
public long

Returns:

the amount of time after which, if the request is not obtained from the client within the timeout period, the Future<HttpClientRequest> obtained from the client is failed with a java.util.concurrent.TimeoutException
getConnectTimeout
()

public Boolean

Returns:

true when the client should follow redirection
getFollowRedirects
()

public MultiMap

Returns:

the headers
getHeaders
()

Get the request headers

public String

Returns:

the host name
getHost
()

Get the host name to be used by the client request.

public long

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 java.util.concurrent.TimeoutException
getIdleTimeout
()

public HttpMethod

Returns:

the HTTP method
getMethod
()

Get the HTTP method to be used by the client request.

public Integer

Returns:

the port
getPort
()

Get the port to be used by the client request.

public ProxyOptions

Returns:

proxy options override
getProxyOptions
()

Get the proxy options override for connections

public SocketAddress

Returns:

the server address
getServer
()

Get the server address to be used by the client request.

public long
public String

Returns:

the trace operation override
getTraceOperation
()

public String

Returns:

the request relative URI
getURI
()

public Boolean

Returns:

is SSL/TLS enabled?
isSsl
()

private URL
public RequestOptions

Returns:

a reference to this, so the API can be used fluently
putHeader
(String
the header key
key
,
String
the header value
value
)

Set a request header.

public RequestOptions

Returns:

a reference to this, so the API can be used fluently
putHeader
(CharSequence
the header key
key
,
CharSequence
the header value
value
)

Set a request header.

public RequestOptions
public RequestOptions

Returns:

a reference to this, so the API can be used fluently
removeHeader
(String
the header key
key
)

Add a request header.

public RequestOptions

Returns:

a reference to this, so the API can be used fluently
removeHeader
(CharSequence
the header key
key
)

Add a request header.

public RequestOptions

Returns:

a reference to this, so the API can be used fluently
setAbsoluteURI
(String
the uri to use
absoluteURI
)

Parse an absolute URI to use, this will update the ssl, host, port and uri fields.

public RequestOptions

Returns:

a reference to this, so the API can be used fluently
setAbsoluteURI
(URL
the uri to use
url
)

Like setAbsoluteURI(String) but using an URL parameter.

public RequestOptions

Returns:

a reference to this, so the API can be used fluently
setConnectTimeout
(long
the amount of time in milliseconds.
timeout
)

Sets the amount of time after which, if the request is not obtained from the client within the timeout period, the Future<HttpClientRequest> obtained from the client is failed with a java.util.concurrent.TimeoutException.

public RequestOptions

Returns:

a reference to this, so the API can be used fluently
setFollowRedirects
(Boolean
whether to follow redirect
followRedirects
)

Set whether to follow HTTP redirect

public RequestOptions

Returns:

a reference to this, so the API can be used fluently
setHeaders
(MultiMap
the headers
headers
)

Set request headers from a multi-map.

public RequestOptions

Returns:

a reference to this, so the API can be used fluently
setHost
(String host)

Set the host name to be used by the client request.

public RequestOptions

Returns:

a reference to this, so the API can be used fluently
setIdleTimeout
(long
the amount of time in milliseconds.
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 a java.util.concurrent.TimeoutException, e.g. Future<HttpClientResponse> or Future<Buffer> response body.

public RequestOptions

Returns:

a reference to this, so the API can be used fluently
setMethod
(HttpMethod method)

Set the HTTP method to be used by the client request.

public RequestOptions

Returns:

a reference to this, so the API can be used fluently
setPort
(Integer port)

Set the port to be used by the client request.

public RequestOptions

Returns:

a reference to this, so the API can be used fluently
setProxyOptions
(ProxyOptions
proxy options override object
proxyOptions
)

Override the HttpClientOptions#setProxyOptions(ProxyOptions) proxy options for connections.

public RequestOptions

Returns:

a reference to this, so the API can be used fluently
setServer
(SocketAddress server)

Set the server address to be used by the client request.

public RequestOptions

Returns:

a reference to this, so the API can be used fluently
setSsl
(Boolean
true if enabled
ssl
)

Set whether SSL/TLS is enabled.

public RequestOptions
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, the Future<HttpClientRequest> obtained from the client is failed with a java.util.concurrent.TimeoutException.
  • 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 java.util.concurrent.TimeoutException, e.g. Future<HttpClientResponse> or Future<Buffer> response body.
public RequestOptions

Returns:

a reference to this, so the API can be used fluently
setTraceOperation
(String
the override
op
)

Override the operation the tracer use for this request.

public RequestOptions

Returns:

a reference to this, so the API can be used fluently
setURI
(String
the relative uri
uri
)

Set the request relative URI.

public JsonObject
toJson()
References Deprecated JsonObject is deprecated or references (maybe indirectly) at least one deprecated element.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

connectTimeoutback to summary
private long connectTimeout
DEFAULT_CONNECT_TIMEOUTback to summary
public static final long DEFAULT_CONNECT_TIMEOUT

The default connect timeout = -1L (disabled)

DEFAULT_FOLLOW_REDIRECTSback to summary
public static final boolean DEFAULT_FOLLOW_REDIRECTS

Follow redirection by default = false

DEFAULT_HOSTback to summary
public static final String DEFAULT_HOST

The default value for host name = null

DEFAULT_HTTP_METHODback to summary
public static final HttpMethod DEFAULT_HTTP_METHOD

The default value for HTTP method = HttpMethod#GET

DEFAULT_IDLE_TIMEOUTback to summary
public static final long DEFAULT_IDLE_TIMEOUT

The default idle timeout = -1L (disabled)

DEFAULT_PORTback to summary
public static final Integer DEFAULT_PORT

The default value for port = null

DEFAULT_PROXY_OPTIONSback to summary
public static final ProxyOptions DEFAULT_PROXY_OPTIONS

The default value for proxy options = null

DEFAULT_SERVERback to summary
public static final SocketAddress DEFAULT_SERVER

The default value for server method = null

DEFAULT_SSLback to summary
public static final Boolean DEFAULT_SSL

The default value for SSL = null

DEFAULT_TIMEOUTback to summary
public static final long DEFAULT_TIMEOUT

The default request timeout = -1L (disabled)

DEFAULT_URIback to summary
public static final String DEFAULT_URI

The default request URI = "/"

followRedirectsback to summary
private boolean followRedirects
headersback to summary
private MultiMap headers
hostback to summary
private String host
idleTimeoutback to summary
private long idleTimeout
methodback to summary
private HttpMethod method
portback to summary
private Integer port
proxyOptionsback to summary
private ProxyOptions proxyOptions
serverback to summary
private SocketAddress server
sslback to summary
private Boolean ssl
timeoutback to summary
private long timeout
traceOperationback to summary
private String traceOperation
uriback to summary
private String uri

Constructor Detail

RequestOptionsback to summary
public RequestOptions()

Default constructor

RequestOptionsback to summary
public RequestOptions(RequestOptions other)

Copy constructor

Parameters
other:RequestOptions

the options to copy

RequestOptionsback to summary
public RequestOptions(JsonObject json)

References Deprecated

JsonObject is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Create options from JSON

Parameters
json:JsonObject

the JSON

Method Detail

addHeaderback to summary
public RequestOptions addHeader(String key, String value)

Add a request header.

Parameters
key:String

the header key

value:String

the header value

Returns:RequestOptions

a reference to this, so the API can be used fluently

Annotations
@GenIgnore
addHeaderback to summary
public RequestOptions addHeader(CharSequence key, CharSequence value)

Add a request header.

Parameters
key:CharSequence

the header key

value:CharSequence

the header value

Returns:RequestOptions

a reference to this, so the API can be used fluently

Annotations
@GenIgnore
addHeaderback to summary
public RequestOptions addHeader(CharSequence key, Iterable<CharSequence> values)
Annotations
@GenIgnore
checkHeadersback to summary
private void checkHeaders()
getConnectTimeoutback to summary
public long getConnectTimeout()
Returns:long

the amount of time after which, if the request is not obtained from the client within the timeout period, the Future<HttpClientRequest> obtained from the client is failed with a java.util.concurrent.TimeoutException

getFollowRedirectsback to summary
public Boolean getFollowRedirects()
Returns:Boolean

true when the client should follow redirection

getHeadersback to summary
public MultiMap getHeaders()

Get the request headers

Returns:MultiMap

the headers

Annotations
@GenIgnore
getHostback to summary
public String getHost()

Get the host name to be used by the client request.

Returns:String

the host name

getIdleTimeoutback to summary
public long getIdleTimeout()
Returns:long

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 java.util.concurrent.TimeoutException

getMethodback to summary
public HttpMethod getMethod()

Get the HTTP method to be used by the client request.

Returns:HttpMethod

the HTTP method

Annotations
@GenIgnore
getPortback to summary
public Integer getPort()

Get the port to be used by the client request.

Returns:Integer

the port

getProxyOptionsback to summary
public ProxyOptions getProxyOptions()

Get the proxy options override for connections

Returns:ProxyOptions

proxy options override

getServerback to summary
public SocketAddress getServer()

Get the server address to be used by the client request.

Returns:SocketAddress

the server address

getTimeoutback to summary
public long getTimeout()
See Also
setTimeout(long)
getTraceOperationback to summary
public String getTraceOperation()
Returns:String

the trace operation override

getURIback to summary
public String getURI()
Returns:String

the request relative URI

isSslback to summary
public Boolean isSsl()
Returns:Boolean

is SSL/TLS enabled?

parseUrlback to summary
private URL parseUrl(String surl)
putHeaderback to summary
public RequestOptions putHeader(String key, String value)

Set a request header.

Parameters
key:String

the header key

value:String

the header value

Returns:RequestOptions

a reference to this, so the API can be used fluently

Annotations
@GenIgnore
putHeaderback to summary
public RequestOptions putHeader(CharSequence key, CharSequence value)

Set a request header.

Parameters
key:CharSequence

the header key

value:CharSequence

the header value

Returns:RequestOptions

a reference to this, so the API can be used fluently

Annotations
@GenIgnore
putHeaderback to summary
public RequestOptions putHeader(CharSequence key, Iterable<CharSequence> values)
Annotations
@GenIgnore
removeHeaderback to summary
public RequestOptions removeHeader(String key)

Add a request header.

Parameters
key:String

the header key

Returns:RequestOptions

a reference to this, so the API can be used fluently

Annotations
@GenIgnore
removeHeaderback to summary
public RequestOptions removeHeader(CharSequence key)

Add a request header.

Parameters
key:CharSequence

the header key

Returns:RequestOptions

a reference to this, so the API can be used fluently

Annotations
@GenIgnore
setAbsoluteURIback to summary
public RequestOptions setAbsoluteURI(String absoluteURI)

Parse an absolute URI to use, this will update the ssl, host, port and uri fields.

Parameters
absoluteURI:String

the uri to use

Returns:RequestOptions

a reference to this, so the API can be used fluently

setAbsoluteURIback to summary
public RequestOptions setAbsoluteURI(URL url)

Like setAbsoluteURI(String) but using an URL parameter.

Parameters
url:URL

the uri to use

Returns:RequestOptions

a reference to this, so the API can be used fluently

Annotations
@GenIgnore:permitted-type
setConnectTimeoutback to summary
public RequestOptions setConnectTimeout(long timeout)

Sets the amount of time after which, if the request is not obtained from the client within the timeout period, the Future<HttpClientRequest> obtained from the client is failed with a java.util.concurrent.TimeoutException. Note this is not related to the TCP HttpClientOptions#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.

Parameters
timeout:long

the amount of time in milliseconds.

Returns:RequestOptions

a reference to this, so the API can be used fluently

setFollowRedirectsback to summary
public RequestOptions setFollowRedirects(Boolean followRedirects)

Set whether to follow HTTP redirect

Parameters
followRedirects:Boolean

whether to follow redirect

Returns:RequestOptions

a reference to this, so the API can be used fluently

setHeadersback to summary
public RequestOptions setHeaders(MultiMap headers)

Set request headers from a multi-map.

Parameters
headers:MultiMap

the headers

Returns:RequestOptions

a reference to this, so the API can be used fluently

Annotations
@GenIgnore
setHostback to summary
public RequestOptions setHost(String host)

Set the host name to be used by the client request.

Returns:RequestOptions

a reference to this, so the API can be used fluently

setIdleTimeoutback to summary
public RequestOptions 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 a java.util.concurrent.TimeoutException, e.g. Future<HttpClientResponse> or Future<Buffer> response body.

The timeout starts after a connection is obtained from the client, similar to calling HttpClientRequest#idleTimeout(long).

Parameters
timeout:long

the amount of time in milliseconds.

Returns:RequestOptions

a reference to this, so the API can be used fluently

setMethodback to summary
public RequestOptions setMethod(HttpMethod method)

Set the HTTP method to be used by the client request.

Returns:RequestOptions

a reference to this, so the API can be used fluently

Annotations
@GenIgnore
setPortback to summary
public RequestOptions setPort(Integer port)

Set the port to be used by the client request.

Returns:RequestOptions

a reference to this, so the API can be used fluently

setProxyOptionsback to summary
public RequestOptions setProxyOptions(ProxyOptions proxyOptions)

Override the HttpClientOptions#setProxyOptions(ProxyOptions) proxy options for connections.

Parameters
proxyOptions:ProxyOptions

proxy options override object

Returns:RequestOptions

a reference to this, so the API can be used fluently

setServerback to summary
public RequestOptions setServer(SocketAddress server)

Set the server address to be used by the client request.

When the server address is null, the address will be resolved after the host property by the Vert.x resolver.

Use this when you want to connect to a specific server address without name resolution.

Returns:RequestOptions

a reference to this, so the API can be used fluently

setSslback to summary
public RequestOptions setSsl(Boolean ssl)

Set whether SSL/TLS is enabled.

Parameters
ssl:Boolean

true if enabled

Returns:RequestOptions

a reference to this, so the API can be used fluently

setTimeoutback to summary
public RequestOptions 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, the Future<HttpClientRequest> obtained from the client is failed with a java.util.concurrent.TimeoutException.
  • 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 java.util.concurrent.TimeoutException, e.g. Future<HttpClientResponse> or Future<Buffer> response body.
The connect and idle timeouts can be set separately using setConnectTimeout(long) and setIdleTimeout(long)
setTraceOperationback to summary
public RequestOptions setTraceOperation(String op)

Override the operation the tracer use for this request. When no operation is set, the HTTP method is used instead.

Parameters
op:String

the override

Returns:RequestOptions

a reference to this, so the API can be used fluently

setURIback to summary
public RequestOptions setURI(String uri)

Set the request relative URI.

Parameters
uri:String

the relative uri

Returns:RequestOptions

a reference to this, so the API can be used fluently

toJsonback to summary
public JsonObject toJson()

References Deprecated

JsonObject is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.