public class RequestOptions extends Object
HttpClient
will connect to make a request.Modifier and Type | Field and Description |
---|---|
static boolean |
DEFAULT_FOLLOW_REDIRECTS
Follow redirection by default =
false |
static String |
DEFAULT_HOST
The default value for host name =
null |
static HttpMethod |
DEFAULT_HTTP_METHOD
The default value for HTTP method =
HttpMethod.GET |
static Integer |
DEFAULT_PORT
The default value for port =
null |
static ProxyOptions |
DEFAULT_PROXY_OPTIONS
The default value for proxy options =
null |
static SocketAddress |
DEFAULT_SERVER
The default value for server method =
null |
static Boolean |
DEFAULT_SSL
The default value for SSL =
null |
static long |
DEFAULT_TIMEOUT
The default request timeout =
0 (disabled) |
static String |
DEFAULT_URI
The default request URI =
"/" |
Constructor and Description |
---|
RequestOptions()
Default constructor
|
RequestOptions(JsonObject json)
Create options from JSON
|
RequestOptions(RequestOptions other)
Copy constructor
|
Modifier and Type | Method and Description |
---|---|
RequestOptions |
addHeader(CharSequence key,
CharSequence value)
Add a request header.
|
RequestOptions |
addHeader(CharSequence key,
Iterable<CharSequence> values) |
RequestOptions |
addHeader(String key,
String value)
Add a request header.
|
Boolean |
getFollowRedirects() |
MultiMap |
getHeaders()
Get the request headers
|
String |
getHost()
Get the host name to be used by the client request.
|
HttpMethod |
getMethod()
Get the HTTP method to be used by the client request.
|
Integer |
getPort()
Get the port to be used by the client request.
|
ProxyOptions |
getProxyOptions()
Get the proxy options override for connections
|
SocketAddress |
getServer()
Get the server address to be used by the client request.
|
long |
getTimeout() |
String |
getTraceOperation() |
String |
getURI() |
Boolean |
isSsl() |
RequestOptions |
putHeader(CharSequence key,
CharSequence value)
Set a request header.
|
RequestOptions |
putHeader(CharSequence key,
Iterable<CharSequence> values) |
RequestOptions |
putHeader(String key,
String value)
Set a request header.
|
RequestOptions |
removeHeader(CharSequence key)
Add a request header.
|
RequestOptions |
removeHeader(String key)
Add a request header.
|
RequestOptions |
setAbsoluteURI(String absoluteURI)
Parse an absolute URI to use, this will update the
ssl , host ,
port and uri fields. |
RequestOptions |
setAbsoluteURI(URL url)
Like
setAbsoluteURI(String) but using an URL parameter. |
RequestOptions |
setFollowRedirects(Boolean followRedirects)
Set whether to follow HTTP redirect
|
RequestOptions |
setHeaders(MultiMap headers)
Set request headers from a multi-map.
|
RequestOptions |
setHost(String host)
Set the host name to be used by the client request.
|
RequestOptions |
setMethod(HttpMethod method)
Set the HTTP method to be used by the client request.
|
RequestOptions |
setPort(Integer port)
Set the port to be used by the client request.
|
RequestOptions |
setProxyOptions(ProxyOptions proxyOptions)
Override the
HttpClientOptions.setProxyOptions(ProxyOptions) proxy options
for connections. |
RequestOptions |
setServer(SocketAddress server)
Set the server address to be used by the client request.
|
RequestOptions |
setSsl(Boolean ssl)
Set whether SSL/TLS is enabled.
|
RequestOptions |
setTimeout(long timeout)
Sets the amount of time after which if the request does not return any data within the timeout period an
TimeoutException will be passed to the exception handler and
the request will be closed. |
RequestOptions |
setTraceOperation(String op)
Override the operation the tracer use for this request.
|
RequestOptions |
setURI(String uri)
Set the request relative URI.
|
JsonObject |
toJson() |
public static final ProxyOptions DEFAULT_PROXY_OPTIONS
null
public static final SocketAddress DEFAULT_SERVER
null
public static final HttpMethod DEFAULT_HTTP_METHOD
HttpMethod.GET
public static final String DEFAULT_HOST
null
public static final Integer DEFAULT_PORT
null
public static final Boolean DEFAULT_SSL
null
public static final String DEFAULT_URI
"/"
public static final boolean DEFAULT_FOLLOW_REDIRECTS
false
public static final long DEFAULT_TIMEOUT
0
(disabled)public RequestOptions()
public RequestOptions(RequestOptions other)
other
- the options to copypublic RequestOptions(JsonObject json)
json
- the JSONpublic ProxyOptions getProxyOptions()
public RequestOptions setProxyOptions(ProxyOptions proxyOptions)
HttpClientOptions.setProxyOptions(ProxyOptions)
proxy options
for connections.proxyOptions
- proxy options override objectpublic SocketAddress getServer()
public RequestOptions setServer(SocketAddress server)
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.
public HttpMethod getMethod()
public RequestOptions setMethod(HttpMethod method)
public String getHost()
public RequestOptions setHost(String host)
public Integer getPort()
public RequestOptions setPort(Integer port)
public Boolean isSsl()
public RequestOptions setSsl(Boolean ssl)
ssl
- true if enabledpublic String getURI()
public RequestOptions setURI(String uri)
uri
- the relative uripublic Boolean getFollowRedirects()
true
when the client should follow redirectionpublic RequestOptions setFollowRedirects(Boolean followRedirects)
followRedirects
- whether to follow redirectpublic long getTimeout()
TimeoutException
will be passed to the exception handler and
the request will be closed.public RequestOptions setTimeout(long timeout)
TimeoutException
will be passed to the exception handler and
the request will be closed.timeout
- the amount of time in milliseconds.public RequestOptions setAbsoluteURI(String absoluteURI)
ssl
, host
,
port
and uri
fields.absoluteURI
- the uri to usepublic RequestOptions setAbsoluteURI(URL url)
setAbsoluteURI(String)
but using an URL
parameter.url
- the uri to usepublic RequestOptions addHeader(String key, String value)
key
- the header keyvalue
- the header valuepublic RequestOptions addHeader(CharSequence key, CharSequence value)
key
- the header keyvalue
- the header valuepublic RequestOptions addHeader(CharSequence key, Iterable<CharSequence> values)
public RequestOptions putHeader(String key, String value)
key
- the header keyvalue
- the header valuepublic RequestOptions putHeader(CharSequence key, CharSequence value)
key
- the header keyvalue
- the header valuepublic RequestOptions putHeader(CharSequence key, Iterable<CharSequence> values)
public RequestOptions removeHeader(String key)
key
- the header keypublic RequestOptions removeHeader(CharSequence key)
key
- the header keypublic RequestOptions setHeaders(MultiMap headers)
headers
- the headerspublic MultiMap getHeaders()
public String getTraceOperation()
public RequestOptions setTraceOperation(String op)
op
- the overridepublic JsonObject toJson()
Copyright © 2024 Eclipse. All rights reserved.