Class WebClientOptions

    • Field Detail

      • DEFAULT_USER_AGENT_ENABLED

        public static final boolean DEFAULT_USER_AGENT_ENABLED
        The default value of whether the Web Client should send a user agent header = true.
        See Also:
        Constant Field Values
      • DEFAULT_USER_AGENT

        public static final String DEFAULT_USER_AGENT
        The default user agent string = Vert.x-WebClient/<version>.
      • DEFAULT_FOLLOW_REDIRECTS

        public static final boolean DEFAULT_FOLLOW_REDIRECTS
        The default value of whether the Web Client should follow redirects = true.
        See Also:
        Constant Field Values
      • DEFAULT_EXPAND_OPTIONS

        public static final ExpandOptions DEFAULT_EXPAND_OPTIONS
    • Constructor Detail

      • WebClientOptions

        public WebClientOptions()
      • WebClientOptions

        public WebClientOptions​(WebClientOptions other)
        Copy constructor.
        Parameters:
        other - the options to copy
      • WebClientOptions

        public WebClientOptions​(JsonObject json)
        Creates a new instance from JSON.
        Parameters:
        json - the JSON object
    • Method Detail

      • isUserAgentEnabled

        public boolean isUserAgentEnabled()
        Returns:
        true if the Web Client should send a user agent header, false otherwise
      • setUserAgentEnabled

        public WebClientOptions setUserAgentEnabled​(boolean userAgentEnabled)
        Sets whether the Web Client should send a user agent header. Defaults to true.
        Parameters:
        userAgentEnabled - true to send a user agent header, false otherwise
        Returns:
        a reference to this, so the API can be used fluently
      • getUserAgent

        public String getUserAgent()
        Returns:
        the user agent header string
      • setUserAgent

        public WebClientOptions setUserAgent​(String userAgent)
        Sets the Web Client user agent header. Defaults to Vert.x-WebClient/<version>.
        Parameters:
        userAgent - user agent header value
        Returns:
        a reference to this, so the API can be used fluently
      • isFollowRedirects

        public boolean isFollowRedirects()
        Returns:
        the default behavior of the client for following HTTP 30x redirections
      • setFollowRedirects

        public WebClientOptions setFollowRedirects​(boolean followRedirects)
        Configure the default behavior of the client to follow HTTP 30x redirections.
        Parameters:
        followRedirects - true when a redirect is followed
        Returns:
        a reference to this, so the API can be used fluently
      • getTemplateExpandOptions

        public ExpandOptions getTemplateExpandOptions()
      • setMaxRedirects

        public WebClientOptions setMaxRedirects​(int maxRedirects)
        Description copied from class: HttpClientOptions
        Set to maxRedirects the maximum number of redirection a request can follow.
        Overrides:
        setMaxRedirects in class HttpClientOptions
        Parameters:
        maxRedirects - the maximum number of redirection
        Returns:
        a reference to this, so the API can be used fluently
      • setSendBufferSize

        public WebClientOptions setSendBufferSize​(int sendBufferSize)
        Description copied from class: NetworkOptions
        Set the TCP send buffer size
        Overrides:
        setSendBufferSize in class HttpClientOptions
        Parameters:
        sendBufferSize - the buffers size, in bytes
        Returns:
        a reference to this, so the API can be used fluently
      • setReceiveBufferSize

        public WebClientOptions setReceiveBufferSize​(int receiveBufferSize)
        Description copied from class: NetworkOptions
        Set the TCP receive buffer size
        Overrides:
        setReceiveBufferSize in class HttpClientOptions
        Parameters:
        receiveBufferSize - the buffers size, in bytes
        Returns:
        a reference to this, so the API can be used fluently
      • setReuseAddress

        public WebClientOptions setReuseAddress​(boolean reuseAddress)
        Description copied from class: NetworkOptions
        Set the value of reuse address
        Overrides:
        setReuseAddress in class HttpClientOptions
        Parameters:
        reuseAddress - the value of reuse address
        Returns:
        a reference to this, so the API can be used fluently
      • setTrafficClass

        public WebClientOptions setTrafficClass​(int trafficClass)
        Description copied from class: NetworkOptions
        Set the value of traffic class
        Overrides:
        setTrafficClass in class HttpClientOptions
        Parameters:
        trafficClass - the value of traffic class
        Returns:
        a reference to this, so the API can be used fluently
      • setTcpNoDelay

        public WebClientOptions setTcpNoDelay​(boolean tcpNoDelay)
        Description copied from class: TCPSSLOptions
        Set whether TCP no delay is enabled
        Overrides:
        setTcpNoDelay in class HttpClientOptions
        Parameters:
        tcpNoDelay - true if TCP no delay is enabled (Nagle disabled)
        Returns:
        a reference to this, so the API can be used fluently
      • setTcpKeepAlive

        public WebClientOptions setTcpKeepAlive​(boolean tcpKeepAlive)
        Description copied from class: TCPSSLOptions
        Set whether TCP keep alive is enabled
        Overrides:
        setTcpKeepAlive in class HttpClientOptions
        Parameters:
        tcpKeepAlive - true if TCP keep alive is enabled
        Returns:
        a reference to this, so the API can be used fluently
      • setSoLinger

        public WebClientOptions setSoLinger​(int soLinger)
        Description copied from class: TCPSSLOptions
        Set whether SO_linger keep alive is enabled
        Overrides:
        setSoLinger in class HttpClientOptions
        Parameters:
        soLinger - true if SO_linger is enabled
        Returns:
        a reference to this, so the API can be used fluently
      • setIdleTimeout

        public WebClientOptions setIdleTimeout​(int idleTimeout)
        Description copied from class: TCPSSLOptions
        Set the idle timeout, default time unit is seconds. Zero means don't timeout. This determines if a connection will timeout and be closed if no data is received nor sent within the timeout. If you want change default time unit, use TCPSSLOptions.setIdleTimeoutUnit(TimeUnit)
        Overrides:
        setIdleTimeout in class HttpClientOptions
        Parameters:
        idleTimeout - the timeout
        Returns:
        a reference to this, so the API can be used fluently
      • setIdleTimeoutUnit

        public WebClientOptions setIdleTimeoutUnit​(TimeUnit idleTimeoutUnit)
        Description copied from class: TCPSSLOptions
        Set the idle timeout unit. If not specified, default is seconds.
        Overrides:
        setIdleTimeoutUnit in class HttpClientOptions
        Parameters:
        idleTimeoutUnit - specify time unit.
        Returns:
        a reference to this, so the API can be used fluently
      • setSsl

        public WebClientOptions setSsl​(boolean ssl)
        Description copied from class: TCPSSLOptions
        Set whether SSL/TLS is enabled
        Overrides:
        setSsl in class HttpClientOptions
        Parameters:
        ssl - true if enabled
        Returns:
        a reference to this, so the API can be used fluently
      • setTrustAll

        public WebClientOptions setTrustAll​(boolean trustAll)
        Description copied from class: ClientOptionsBase
        Set whether all server certificates should be trusted
        Overrides:
        setTrustAll in class HttpClientOptions
        Parameters:
        trustAll - true if all should be trusted
        Returns:
        a reference to this, so the API can be used fluently
      • setHttp2MultiplexingLimit

        public WebClientOptions setHttp2MultiplexingLimit​(int limit)
        Description copied from class: HttpClientOptions
        Set a client limit of the number concurrent streams for each HTTP/2 connection, this limits the number of streams the client can create for a connection. The effective number of streams for a connection is the min of this value and the server's initial settings.

        Setting the value to -1 means to use the value sent by the server's initial settings. -1 is the default value.

        Overrides:
        setHttp2MultiplexingLimit in class HttpClientOptions
        Parameters:
        limit - the maximum concurrent for an HTTP/2 connection
        Returns:
        a reference to this, so the API can be used fluently
      • setHttp2ConnectionWindowSize

        public WebClientOptions setHttp2ConnectionWindowSize​(int http2ConnectionWindowSize)
        Description copied from class: HttpClientOptions
        Set the default HTTP/2 connection window size. It overrides the initial window size set by Http2Settings.getInitialWindowSize(), so the connection window size is greater than for its streams, in order the data throughput.

        A value of -1 reuses the initial window size setting.

        Overrides:
        setHttp2ConnectionWindowSize in class HttpClientOptions
        Parameters:
        http2ConnectionWindowSize - the window size applied to the connection
        Returns:
        a reference to this, so the API can be used fluently
      • setKeepAlive

        public WebClientOptions setKeepAlive​(boolean keepAlive)
        Description copied from class: HttpClientOptions
        Set whether keep alive is enabled on the client
        Overrides:
        setKeepAlive in class HttpClientOptions
        Parameters:
        keepAlive - true if enabled
        Returns:
        a reference to this, so the API can be used fluently
      • setPipelining

        public WebClientOptions setPipelining​(boolean pipelining)
        Description copied from class: HttpClientOptions
        Set whether pipe-lining is enabled on the client
        Overrides:
        setPipelining in class HttpClientOptions
        Parameters:
        pipelining - true if enabled
        Returns:
        a reference to this, so the API can be used fluently
      • setPipeliningLimit

        public WebClientOptions setPipeliningLimit​(int limit)
        Description copied from class: HttpClientOptions
        Set the limit of pending requests a pipe-lined HTTP/1 connection can send.
        Overrides:
        setPipeliningLimit in class HttpClientOptions
        Parameters:
        limit - the limit of pending requests
        Returns:
        a reference to this, so the API can be used fluently
      • setVerifyHost

        public WebClientOptions setVerifyHost​(boolean verifyHost)
        Description copied from class: HttpClientOptions
        Set whether hostname verification is enabled
        Overrides:
        setVerifyHost in class HttpClientOptions
        Parameters:
        verifyHost - true if enabled
        Returns:
        a reference to this, so the API can be used fluently
      • setDecompressionSupported

        public WebClientOptions setDecompressionSupported​(boolean tryUseCompression)
        Description copied from class: HttpClientOptions
        Whether the client should send requests with an accepting-encoding header set to a compression algorithm.
        Overrides:
        setDecompressionSupported in class HttpClientOptions
        Parameters:
        tryUseCompression - true if the client should send a request with an accepting-encoding header set to a compression algorithm, false otherwise
        Returns:
        a reference to this, so the API can be used fluently
      • setDefaultHost

        public WebClientOptions setDefaultHost​(String defaultHost)
        Description copied from class: HttpClientOptions
        Set the default host name to be used by this client in requests if none is provided when making the request.
        Overrides:
        setDefaultHost in class HttpClientOptions
        Returns:
        a reference to this, so the API can be used fluently
      • setDefaultPort

        public WebClientOptions setDefaultPort​(int defaultPort)
        Description copied from class: HttpClientOptions
        Set the default port to be used by this client in requests if none is provided when making the request.
        Overrides:
        setDefaultPort in class HttpClientOptions
        Returns:
        a reference to this, so the API can be used fluently
      • setMaxChunkSize

        public WebClientOptions setMaxChunkSize​(int maxChunkSize)
        Description copied from class: HttpClientOptions
        Set the maximum HTTP chunk size
        Overrides:
        setMaxChunkSize in class HttpClientOptions
        Parameters:
        maxChunkSize - the maximum chunk size
        Returns:
        a reference to this, so the API can be used fluently
      • setMaxHeaderSize

        public WebClientOptions setMaxHeaderSize​(int maxHeaderSize)
        Description copied from class: HttpClientOptions
        Set the maximum length of all headers for HTTP/1.x .
        Overrides:
        setMaxHeaderSize in class HttpClientOptions
        Parameters:
        maxHeaderSize - the new maximum length
        Returns:
        a reference to this, so the API can be used fluently
      • setHttp2ClearTextUpgrade

        public WebClientOptions setHttp2ClearTextUpgrade​(boolean value)
        Description copied from class: HttpClientOptions
        Set to true when an h2c connection is established using an HTTP/1.1 upgrade request, and false when an h2c connection is established directly (with prior knowledge).
        Overrides:
        setHttp2ClearTextUpgrade in class HttpClientOptions
        Parameters:
        value - the upgrade value
        Returns:
        a reference to this, so the API can be used fluently
      • setMetricsName

        public WebClientOptions setMetricsName​(String metricsName)
        Description copied from class: ClientOptionsBase
        Set the metrics name identifying the reported metrics, useful for grouping metrics with the same name.
        Overrides:
        setMetricsName in class HttpClientOptions
        Parameters:
        metricsName - the metrics name
        Returns:
        a reference to this, so the API can be used fluently
      • setProxyOptions

        public WebClientOptions setProxyOptions​(ProxyOptions proxyOptions)
        Description copied from class: ClientOptionsBase
        Set proxy options for connections via CONNECT proxy (e.g. Squid) or a SOCKS proxy.
        Overrides:
        setProxyOptions in class HttpClientOptions
        Parameters:
        proxyOptions - proxy options object
        Returns:
        a reference to this, so the API can be used fluently
      • setLocalAddress

        public WebClientOptions setLocalAddress​(String localAddress)
        Description copied from class: ClientOptionsBase
        Set the local interface to bind for network connections. When the local address is null, it will pick any local address, the default local address is null.
        Overrides:
        setLocalAddress in class HttpClientOptions
        Parameters:
        localAddress - the local address
        Returns:
        a reference to this, so the API can be used fluently
      • setLogActivity

        public WebClientOptions setLogActivity​(boolean logEnabled)
        Description copied from class: NetworkOptions
        Set to true to enabled network activity logging: Netty's pipeline is configured for logging on Netty's logger.
        Overrides:
        setLogActivity in class HttpClientOptions
        Parameters:
        logEnabled - true for logging the network activity
        Returns:
        a reference to this, so the API can be used fluently
      • setEnabledSecureTransportProtocols

        public WebClientOptions setEnabledSecureTransportProtocols​(Set<String> enabledSecureTransportProtocols)
        Description copied from class: TCPSSLOptions
        Sets the list of enabled SSL/TLS protocols.
        Overrides:
        setEnabledSecureTransportProtocols in class HttpClientOptions
        Parameters:
        enabledSecureTransportProtocols - the SSL/TLS protocols to enable
        Returns:
        a reference to this, so the API can be used fluently
      • setReusePort

        public WebClientOptions setReusePort​(boolean reusePort)
        Description copied from class: NetworkOptions
        Set the value of reuse port.

        This is only supported by native transports.

        Overrides:
        setReusePort in class HttpClientOptions
        Parameters:
        reusePort - the value of reuse port
        Returns:
        a reference to this, so the API can be used fluently
      • setHttp2KeepAliveTimeout

        public WebClientOptions setHttp2KeepAliveTimeout​(int keepAliveTimeout)
        Description copied from class: HttpClientOptions
        Set the keep alive timeout for HTTP/2 connections, in seconds.

        This value determines how long a connection remains unused in the pool before being evicted and closed.

        A timeout of 0 means there is no timeout.

        Overrides:
        setHttp2KeepAliveTimeout in class HttpClientOptions
        Parameters:
        keepAliveTimeout - the timeout, in seconds
        Returns:
        a reference to this, so the API can be used fluently
      • setForceSni

        public WebClientOptions setForceSni​(boolean forceSni)
        Description copied from class: HttpClientOptions
        By default, the server name is only sent for Fully Qualified Domain Name (FQDN), setting this property to true forces the server name to be always sent.
        Overrides:
        setForceSni in class HttpClientOptions
        Parameters:
        forceSni - true when the client should always use SNI on TLS/SSL connections
        Returns:
        a reference to this, so the API can be used fluently
      • setDecoderInitialBufferSize

        public WebClientOptions setDecoderInitialBufferSize​(int decoderInitialBufferSize)
        Description copied from class: HttpClientOptions
        set to initialBufferSizeHttpDecoder the initial buffer of the HttpDecoder.
        Overrides:
        setDecoderInitialBufferSize in class HttpClientOptions
        Parameters:
        decoderInitialBufferSize - the initial buffer size
        Returns:
        a reference to this, so the API can be used fluently
      • setKeepAliveTimeout

        public WebClientOptions setKeepAliveTimeout​(int keepAliveTimeout)
        Description copied from class: HttpClientOptions
        Set the keep alive timeout for HTTP/1.x, in seconds.

        This value determines how long a connection remains unused in the pool before being evicted and closed.

        A timeout of 0 means there is no timeout.

        Overrides:
        setKeepAliveTimeout in class HttpClientOptions
        Parameters:
        keepAliveTimeout - the timeout, in seconds
        Returns:
        a reference to this, so the API can be used fluently
      • setMaxInitialLineLength

        public WebClientOptions setMaxInitialLineLength​(int maxInitialLineLength)
        Description copied from class: HttpClientOptions
        Set the maximum length of the initial line for HTTP/1.x (e.g. "HTTP/1.1 200 OK")
        Overrides:
        setMaxInitialLineLength in class HttpClientOptions
        Parameters:
        maxInitialLineLength - the new maximum initial length
        Returns:
        a reference to this, so the API can be used fluently
      • setSslHandshakeTimeout

        public WebClientOptions setSslHandshakeTimeout​(long sslHandshakeTimeout)
        Description copied from class: TCPSSLOptions
        Set the SSL handshake timeout, default time unit is seconds.
        Overrides:
        setSslHandshakeTimeout in class HttpClientOptions
        Parameters:
        sslHandshakeTimeout - the SSL handshake timeout to set, in milliseconds
        Returns:
        a reference to this, so the API can be used fluently
      • setSslHandshakeTimeoutUnit

        public WebClientOptions setSslHandshakeTimeoutUnit​(TimeUnit sslHandshakeTimeoutUnit)
        Description copied from class: TCPSSLOptions
        Set the SSL handshake timeout unit. If not specified, default is seconds.
        Overrides:
        setSslHandshakeTimeoutUnit in class HttpClientOptions
        Parameters:
        sslHandshakeTimeoutUnit - specify time unit.
        Returns:
        a reference to this, so the API can be used fluently
      • setReadIdleTimeout

        public WebClientOptions setReadIdleTimeout​(int idleTimeout)
        Description copied from class: TCPSSLOptions
        Set the read idle timeout, default time unit is seconds. Zero means don't timeout. This determines if a connection will timeout and be closed if no data is received within the timeout. If you want change default time unit, use TCPSSLOptions.setIdleTimeoutUnit(TimeUnit)
        Overrides:
        setReadIdleTimeout in class HttpClientOptions
        Parameters:
        idleTimeout - the read timeout
        Returns:
        a reference to this, so the API can be used fluently
      • setWriteIdleTimeout

        public WebClientOptions setWriteIdleTimeout​(int idleTimeout)
        Description copied from class: TCPSSLOptions
        Set the write idle timeout, default time unit is seconds. Zero means don't timeout. This determines if a connection will timeout and be closed if no data is sent within the timeout. If you want change default time unit, use TCPSSLOptions.setIdleTimeoutUnit(TimeUnit)
        Overrides:
        setWriteIdleTimeout in class HttpClientOptions
        Parameters:
        idleTimeout - the write timeout
        Returns:
        a reference to this, so the API can be used fluently
      • setNonProxyHosts

        public WebClientOptions setNonProxyHosts​(List<String> nonProxyHosts)
        Description copied from class: ClientOptionsBase
        Set a list of remote hosts that are not proxied when the client is configured to use a proxy. This list serves the same purpose than the JVM nonProxyHosts configuration.

        Entries can use the * wildcard character for pattern matching, e.g *.example.com matches www.example.com.

        Overrides:
        setNonProxyHosts in class HttpClientOptions
        Parameters:
        nonProxyHosts - the list of non proxies hosts
        Returns:
        a reference to this, so the API can be used fluently
      • setName

        public WebClientOptions setName​(String name)
        Description copied from class: HttpClientOptions
        Set the client name, used when the client is shared, otherwise ignored.
        Overrides:
        setName in class HttpClientOptions
        Parameters:
        name - the new name
        Returns:
        a reference to this, so the API can be used fluently
      • loadUserAgent

        public static String loadUserAgent()