io.vertx.core.http

## Class RequestOptions

- java.lang.Object
- - io.vertx.core.http.RequestOptions

- Direct Known Subclasses:
    WebSocketConnectOptions

      public class RequestOptions
      extends Object

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

- - ### Field Summary

    Fields
    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 Summary

    Constructors
    Constructor and Description
    `RequestOptions()` Default constructor
    `RequestOptions(JsonObject json)` Create options from JSON
    `RequestOptions(RequestOptions other)` Copy constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    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` | `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` | `setURI(String uri)` Set the request relative URI.
    `JsonObject` | `toJson()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_PROXY_OPTIONS

          public static final ProxyOptions DEFAULT_PROXY_OPTIONS

      The default value for proxy options = `null`

    - #### DEFAULT_SERVER

          public static final SocketAddress DEFAULT_SERVER

      The default value for server method = `null`

    - #### DEFAULT_HTTP_METHOD

          public static final HttpMethod DEFAULT_HTTP_METHOD

      The default value for HTTP method = `HttpMethod.GET`

    - #### DEFAULT_HOST

          public static final String DEFAULT_HOST

      The default value for host name = `null`

    - #### DEFAULT_PORT

          public static final Integer DEFAULT_PORT

      The default value for port = `null`

    - #### DEFAULT_SSL

          public static final Boolean DEFAULT_SSL

      The default value for SSL = `null`

    - #### DEFAULT_URI

          public static final String DEFAULT_URI

      The default request URI = `"/"`
      See Also:
        Constant Field Values

    - #### DEFAULT_FOLLOW_REDIRECTS

          public static final boolean DEFAULT_FOLLOW_REDIRECTS

      Follow redirection by default = `false`
      See Also:
        Constant Field Values

    - #### DEFAULT_TIMEOUT

          public static final long DEFAULT_TIMEOUT

      The default request timeout = `0` (disabled)
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### RequestOptions

          public RequestOptions()

      Default constructor

    - #### RequestOptions

          public RequestOptions(RequestOptions other)

      Copy constructor
      Parameters:
        `other` - the options to copy

    - #### RequestOptions

          public RequestOptions(JsonObject json)

      Create options from JSON
      Parameters:
        `json` - the JSON

  - ### Method Detail

    - #### getProxyOptions

          public ProxyOptions getProxyOptions()

      Get the proxy options override for connections
      Returns:
        proxy options override

    - #### setProxyOptions

          public RequestOptions setProxyOptions(ProxyOptions proxyOptions)

      Override the `HttpClientOptions.setProxyOptions(ProxyOptions)` proxy options for connections.
      Parameters:
        `proxyOptions` - proxy options override object
      Returns:
        a reference to this, so the API can be used fluently

    - #### getServer

          public SocketAddress getServer()

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

    - #### setServer

          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:
        a reference to this, so the API can be used fluently

    - #### getMethod

          public HttpMethod getMethod()

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

    - #### setMethod

          public RequestOptions setMethod(HttpMethod method)

      Set the HTTP method to be used by the client request.
      Returns:
        a reference to this, so the API can be used fluently

    - #### getHost

          public String getHost()

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

    - #### setHost

          public RequestOptions setHost(String host)

      Set the host name to be used by the client request.
      Returns:
        a reference to this, so the API can be used fluently

    - #### getPort

          public Integer getPort()

      Get the port to be used by the client request.
      Returns:
        the port

    - #### setPort

          public RequestOptions setPort(Integer port)

      Set the port to be used by the client request.
      Returns:
        a reference to this, so the API can be used fluently

    - #### isSsl

          public Boolean isSsl()

      Returns:
        is SSL/TLS enabled?

    - #### setSsl

          public RequestOptions setSsl(Boolean ssl)

      Set whether SSL/TLS is enabled.
      Parameters:
        `ssl` - true if enabled
      Returns:
        a reference to this, so the API can be used fluently

    - #### getURI

          public String getURI()

      Returns:
        the request relative URI

    - #### setURI

          public RequestOptions setURI(String uri)

      Set the request relative URI.
      Parameters:
        `uri` - the relative uri
      Returns:
        a reference to this, so the API can be used fluently

    - #### getFollowRedirects

          public Boolean getFollowRedirects()

      Returns:
        `true` when the client should follow redirection

    - #### setFollowRedirects

          public RequestOptions setFollowRedirects(Boolean followRedirects)

      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()

      Returns:
        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.

    - #### setTimeout

          public 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.
      Parameters:
        `timeout` - the amount of time in milliseconds.
      Returns:
        a reference to this, so the API can be used fluently

    - #### setAbsoluteURI

          public RequestOptions setAbsoluteURI(String absoluteURI)

      Parse an absolute URI to use, this will update the `ssl`, `host`, `port` and `uri` fields.
      Parameters:
        `absoluteURI` - the uri to use
      Returns:
        a reference to this, so the API can be used fluently

    - #### setAbsoluteURI

          public RequestOptions setAbsoluteURI(URL url)

      Like `setAbsoluteURI(String)` but using an `URL` parameter.
      Parameters:
        `url` - the uri to use
      Returns:
        a reference to this, so the API can be used fluently

    - #### addHeader

          public RequestOptions addHeader(String key,
                                          String value)

      Add a request header.
      Parameters:
        `key` - the header key
        `value` - the header value
      Returns:
        a reference to this, so the API can be used fluently

    - #### addHeader

          public RequestOptions addHeader(CharSequence key,
                                          CharSequence value)

      Add a request header.
      Parameters:
        `key` - the header key
        `value` - the header value
      Returns:
        a reference to this, so the API can be used fluently

    - #### addHeader

          public RequestOptions addHeader(CharSequence key,
                                          Iterable<CharSequence> values)

    - #### putHeader

          public RequestOptions putHeader(String key,
                                          String value)

      Set a request header.
      Parameters:
        `key` - the header key
        `value` - the header value
      Returns:
        a reference to this, so the API can be used fluently

    - #### putHeader

          public RequestOptions putHeader(CharSequence key,
                                          CharSequence value)

      Set a request header.
      Parameters:
        `key` - the header key
        `value` - the header value
      Returns:
        a reference to this, so the API can be used fluently

    - #### putHeader

          public RequestOptions putHeader(CharSequence key,
                                          Iterable<CharSequence> values)

    - #### removeHeader

          public RequestOptions removeHeader(String key)

      Add a request header.
      Parameters:
        `key` - the header key
      Returns:
        a reference to this, so the API can be used fluently

    - #### removeHeader

          public RequestOptions removeHeader(CharSequence key)

      Add a request header.
      Parameters:
        `key` - the header key
      Returns:
        a reference to this, so the API can be used fluently

    - #### setHeaders

          public RequestOptions setHeaders(MultiMap headers)

      Set request headers from a multi-map.
      Parameters:
        `headers` - the headers
      Returns:
        a reference to this, so the API can be used fluently

    - #### getHeaders

          public MultiMap getHeaders()

      Get the request headers
      Returns:
        the headers

    - #### toJson

          public JsonObject toJson()

Copyright © 2021 Eclipse. All rights reserved.