Interface AsyncHttpClientConfig

    • Method Detail

      • getAhcVersion

        String getAhcVersion()
        Returns:
        the version of AHC
      • getThreadPoolName

        String getThreadPoolName()
        Return the name of AsyncHttpClient, which is used for thread naming and debugging.
        Returns:
        the name.
      • getMaxConnections

        int getMaxConnections()
        Return the maximum number of connections an AsyncHttpClient can handle.
        Returns:
        the maximum number of connections an AsyncHttpClient can handle.
      • getMaxConnectionsPerHost

        int getMaxConnectionsPerHost()
        Return the maximum number of connections per hosts an AsyncHttpClient can handle.
        Returns:
        the maximum number of connections per host an AsyncHttpClient can handle.
      • getAcquireFreeChannelTimeout

        int getAcquireFreeChannelTimeout()
        Return the maximum duration in milliseconds an AsyncHttpClient can wait to acquire a free channel
        Returns:
        Return the maximum duration in milliseconds an AsyncHttpClient can wait to acquire a free channel
      • getConnectTimeout

        Duration getConnectTimeout()
        Return the maximum time an AsyncHttpClient can wait when connecting to a remote host
        Returns:
        the maximum time an AsyncHttpClient can wait when connecting to a remote host
      • getPooledConnectionIdleTimeout

        Duration getPooledConnectionIdleTimeout()
        Return the maximum time an AsyncHttpClient will keep connection in pool.
        Returns:
        the maximum time an AsyncHttpClient will keep connection in pool.
      • getConnectionPoolCleanerPeriod

        Duration getConnectionPoolCleanerPeriod()
        Returns:
        the period to clean the pool of dead and idle connections.
      • getRequestTimeout

        Duration getRequestTimeout()
        Return the maximum time an AsyncHttpClient waits until the response is completed.

        By default this bounds each attempt within an exchange rather than the exchange as a whole: a redirect, a retry and an auth replay each start it again, so a chain of n hops may run for n times this value. Set isUseAbsoluteRequestDeadline() to bound the exchange instead.

        Returns:
        the maximum time an AsyncHttpClient waits until the response is completed.
      • isUseEventLoopTimeouts

        default boolean isUseEventLoopTimeouts()
        Whether request and read timeouts are armed on an event loop rather than on getNettyTimer().

        The timer is a hashed wheel: it fires on the first tick at or after the deadline, so a deadline near or below getHashedWheelTimerTickDuration() is rounded up to it, and one thread carries every expiry for the whole client. An event loop instead schedules by deadline and derives its own select timeout from the nearest one, so nothing is rounded up, and the loops share the load rather than funnelling it through a single thread. Both effects matter most to short deadlines, where a tick is a large fraction of the budget and a burst of expiries has no headroom to absorb.

        The cost is where the expiry runs. On the timer it runs on the timer thread; on an event loop it runs on an I/O thread, and so does whatever the caller chained onto the response future, because that future is completed from there. Blocking an I/O thread stalls every connection it serves, so a caller enabling this should hand its own work off with handleAsync or an AsyncHandler that does the same. That is why this is opt-in rather than the default.

        The loop is always the one that owns the exchange's channel. Until there is a channel -- while an address is being resolved and a connection made -- the timer carries the timeout, and the exchange moves it onto the loop once the connection succeeds.

        The connection-pool cleaner stays on the timer either way.

        Returns:
        true to arm request and read timeouts on an event loop
      • isUseAbsoluteRequestDeadline

        default boolean isUseAbsoluteRequestDeadline()
        Whether getRequestTimeout() is a deadline for the whole exchange rather than for each attempt within it.

        A redirect, a retry and an auth replay all continue the same exchange on the same response future, but each builds its own timeout state. Anchoring the deadline on that state gives every hop a fresh budget, which is why a five-redirect chain can legitimately take six times the configured timeout today. Enabling this anchors it on when the exchange was submitted instead, so a later hop gets whatever is left and the caller's total wait is bounded by the one value.

        Off by default because turning it on shortens exchanges that rely on the per-attempt behaviour. A caller working to an end-to-end budget wants it on; Request.getUseAbsoluteRequestDeadline() sets it for a single request.

        As with every option on this interface, the org.asynchttpclient.useAbsoluteRequestDeadline property is read by DefaultAsyncHttpClientConfig.Builder, not here: an implementation of this interface that does not override this method gets false whatever the property says.

        Returns:
        true to treat the request timeout as a deadline for the whole exchange
      • isFollowRedirect

        boolean isFollowRedirect()
        Is HTTP redirect enabled
        Returns:
        true if enabled.
      • getMaxRedirects

        int getMaxRedirects()
        Get the maximum number of HTTP redirect
        Returns:
        the maximum number of HTTP redirect
      • isRefuseSchemeDowngradeOnRedirect

        default boolean isRefuseSchemeDowngradeOnRedirect()
        Whether to refuse a redirect that leaves an https or wss exchange for an unsecured scheme. The redirected request is never sent; the exchange fails with a RedirectRefusedException.

        Applies to every hop, bodies or not, and is judged against the scheme of the request sent on that hop, so a cleartext hop has no downgrade to refuse but a later secured one in the same exchange still does.

        Request.getRefuseSchemeDowngradeOnRedirect() can refuse a hop this allows, but cannot permit one this refuses. An implementation that wraps another configuration has to forward this, or the operator's setting on the wrapped one is lost to the false default here.

        Returns:
        true to refuse such a hop, false to follow it
      • isRefuseCrossOriginBodyOnRedirect

        default boolean isRefuseCrossOriginBodyOnRedirect()
        Whether to refuse a redirect that would resend this request's content to a different origin. It applies only to a hop that keeps the body and only when the request carries content, so a bodyless cross-origin hop and a same-origin hop are untouched, while a GET carrying content is refused like any other. Moving the same host onto TLS is exempt, keeping the port or moving between the two scheme defaults. The exempted hop keeps the host, not the path: the target path and query are the server's choice.

        The hop is refused rather than stripped of its body, because a PUT arriving empty would overwrite the target with nothing. Weigh that against what it blocks: an upload answered with a redirect to another host stops working.

        The hop is still not same-base, so credentials are stripped from it as they always were.

        Request.getRefuseCrossOriginBodyOnRedirect() can refuse a hop this allows, but cannot permit one this refuses. An implementation that wraps another configuration has to forward this, or the operator's setting on the wrapped one is lost to the false default here.

        Returns:
        true to refuse such a hop, false to follow it
      • isKeepAlive

        boolean isKeepAlive()
        Is the ChannelPool support enabled.
        Returns:
        true if keep-alive is enabled
      • getUserAgent

        String getUserAgent()
        Return the USER_AGENT header value
        Returns:
        the USER_AGENT header value
      • isCompressionEnforced

        boolean isCompressionEnforced()
        Is HTTP compression enforced.
        Returns:
        true if compression is enforced
      • isEnableAutomaticDecompression

        boolean isEnableAutomaticDecompression()
        If automatic content decompression is enabled.
        Returns:
        true if content decompression is enabled
      • getMaxDecompressedResponseSize

        default long getMaxDecompressedResponseSize()
        Returns:
        the maximum number of bytes a single HTTP/1.1 response body may decompress to before the exchange is failed. Guards against decompression-bomb responses — a tiny compressed body that inflates to gigabytes and can OOM the client (the limit is enforced transparently when automatic decompression is enabled). 0 disables the limit. Defaults to 256 MiB. HTTP/2 has its own ceiling, see getHttp2MaxDecompressedResponseSize().
      • getSslContext

        @Nullable
        @Nullable io.netty.handler.ssl.SslContext getSslContext()
        Return an instance of SslContext used for SSL connection.
        Returns:
        an instance of SslContext used for SSL connection.
      • getRealm

        @Nullable
        @Nullable Realm getRealm()
        Return the current Realm
        Returns:
        the current Realm
      • getCookieStore

        CookieStore getCookieStore()
        Return cookie store that is used to store and retrieve cookies
        Returns:
        CookieStore object
      • expiredCookieEvictionDelay

        int expiredCookieEvictionDelay()
        Return the delay in milliseconds to evict expired cookies from CookieStore
        Returns:
        the delay in milliseconds to evict expired cookies from CookieStore
      • getMaxRequestRetry

        int getMaxRequestRetry()
        Return the number of time the library will retry when an IOException is throw by the remote server

        A refused TCP connect is retried too. A connect timeout is not retried on the first attempt, but once a request is being retried any failure is. Retries are immediate and re-resolve the host.

        Returns:
        the number of time the library will retry when an IOException is throw by the remote server
      • getLoadBalance

        default LoadBalance getLoadBalance()
        Returns:
        how requests are dispatched to a host that resolves to several IP addresses; never null.
        See Also:
        LoadBalance
      • isFailedIpCooldownEnabled

        default boolean isFailedIpCooldownEnabled()
        Whether a recently-failed IP is briefly deprioritized when ordering a host's resolved addresses for a new connection. When enabled, a TCP connect failure to an address moves it to the back of the failover order for getFailedIpCooldownPeriod() (it is never dropped, only re-ordered, and is re-probed once the window elapses). This applies regardless of getLoadBalance() mode and bounds the cost of an IP that silently black-holes packets.
        Returns:
        true if the failed-IP cooldown is enabled
      • getFailedIpCooldownPeriod

        default Duration getFailedIpCooldownPeriod()
        Returns:
        how long a failed IP is deprioritized before it is re-probed; only used when isFailedIpCooldownEnabled() is true
      • isDisableUrlEncodingForBoundRequests

        boolean isDisableUrlEncodingForBoundRequests()
        Returns:
        the disableUrlEncodingForBoundRequests
      • isUseLaxCookieEncoder

        boolean isUseLaxCookieEncoder()
        Returns:
        true if AHC is to use a LAX cookie encoder, e.g. accept illegal chars in cookie value
      • isStrict302Handling

        boolean isStrict302Handling()
        In the case of a POST/Redirect/Get scenario where the server uses a 302 for the redirect, should AHC respond to the redirect with a GET or whatever the original method was. Unless configured otherwise, for a 302, AHC, will use a GET for this case.
        Returns:
        true if strict 302 handling is to be used, otherwise false.
      • getConnectionTtl

        Duration getConnectionTtl()
        Returns:
        the maximum time an AsyncHttpClient will keep connection in the pool, or negative value to keep connection while possible.
      • isUseOpenSsl

        boolean isUseOpenSsl()
      • isUseInsecureTrustManager

        boolean isUseInsecureTrustManager()
      • isDisableHttpsEndpointIdentificationAlgorithm

        boolean isDisableHttpsEndpointIdentificationAlgorithm()
        Returns:
        true to disable all HTTPS behaviors AT ONCE, such as hostname verification and SNI
      • getEnabledProtocols

        @Nullable
        @Nullable String[] getEnabledProtocols()
        Returns:
        the array of enabled protocols
      • getEnabledCipherSuites

        @Nullable
        @Nullable String[] getEnabledCipherSuites()
        Returns:
        the array of enabled cipher suites
      • isFilterInsecureCipherSuites

        boolean isFilterInsecureCipherSuites()
        Returns:
        if insecure cipher suites must be filtered out (only used when not explicitly passing enabled cipher suites)
      • isHttp2Enabled

        default boolean isHttp2Enabled()
        Returns:
        true if HTTP/2 is enabled (negotiated via ALPN for HTTPS connections)
      • getHttp2InitialWindowSize

        default int getHttp2InitialWindowSize()
        This is also the per-stream flow-control bound for response data queued while a ResponseBodyControl is suspended. Aggregate queued data can scale with the number of concurrent suspended streams; use getHttp2MaxConcurrentStreams() to bound that concurrency.
        Returns:
        the HTTP/2 initial window size in bytes, defaults to 16777216 (16 MiB)
      • getHttp2MaxFrameSize

        default int getHttp2MaxFrameSize()
        Returns:
        the HTTP/2 max frame size in bytes, must be between 16384 and 16777215 per RFC 7540 §4.2
      • getHttp2HeaderTableSize

        default int getHttp2HeaderTableSize()
        Returns:
        the HTTP/2 HPACK header table size in bytes, defaults to 4096
      • getHttp2MaxHeaderListSize

        default int getHttp2MaxHeaderListSize()
        Returns:
        the HTTP/2 max header list size in bytes, defaults to 8192
      • getHttp2MaxConcurrentStreams

        default int getHttp2MaxConcurrentStreams()
        This setting can be combined with getHttp2InitialWindowSize() to bound response data queued for concurrently suspended HTTP/2 streams.
        Returns:
        the HTTP/2 max concurrent streams per connection, -1 means unlimited (server-controlled)
      • getHttp2MaxDecompressedResponseSize

        default long getHttp2MaxDecompressedResponseSize()
        Returns:
        the maximum number of bytes a single HTTP/2 response body may decompress to before the stream is failed. Guards against decompression-bomb responses — a tiny compressed body that inflates to gigabytes and can OOM the client (the limit is enforced transparently when automatic decompression is enabled). 0 disables the limit. Defaults to 256 MiB.
      • getHttp2PingInterval

        default Duration getHttp2PingInterval()
        Returns:
        the interval between HTTP/2 PING keepalive frames, Duration.ZERO disables pinging
      • isHttp2CleartextEnabled

        default boolean isHttp2CleartextEnabled()
        Returns:
        true if cleartext HTTP/2 (h2c) via prior knowledge is enabled for non-TLS connections
      • getSslSessionCacheSize

        int getSslSessionCacheSize()
        Returns:
        the size of the SSL session cache, 0 means using the default value
      • getSslSessionTimeout

        int getSslSessionTimeout()
        Returns:
        the SSL session timeout in seconds, 0 means using the default value
      • getHttpClientCodecMaxInitialLineLength

        int getHttpClientCodecMaxInitialLineLength()
      • getHttpClientCodecMaxHeaderSize

        int getHttpClientCodecMaxHeaderSize()
      • getHttpClientCodecMaxChunkSize

        int getHttpClientCodecMaxChunkSize()
      • getHttpClientCodecInitialBufferSize

        int getHttpClientCodecInitialBufferSize()
      • isDisableZeroCopy

        boolean isDisableZeroCopy()
      • getHandshakeTimeout

        int getHandshakeTimeout()
      • getSslEngineFactory

        @Nullable
        @Nullable SslEngineFactory getSslEngineFactory()
      • getChunkedFileChunkSize

        int getChunkedFileChunkSize()
      • getWebSocketMaxBufferSize

        int getWebSocketMaxBufferSize()
      • getWebSocketMaxDecompressedFrameSize

        default int getWebSocketMaxDecompressedFrameSize()
        Returns:
        the most bytes one permessage-deflate message may inflate to before the connection is failed, or 0 for no limit; each frame, if fragments are not aggregated. The frame and buffer limits only bound compressed bytes.
      • getWebSocketMaxFrameSize

        int getWebSocketMaxFrameSize()
      • isKeepEncodingHeader

        boolean isKeepEncodingHeader()
      • getShutdownQuietPeriod

        Duration getShutdownQuietPeriod()
      • getShutdownTimeout

        Duration getShutdownTimeout()
      • getChannelOptions

        Map<io.netty.channel.ChannelOption<Object>,​Object> getChannelOptions()
      • getEventLoopGroup

        @Nullable
        @Nullable io.netty.channel.EventLoopGroup getEventLoopGroup()
      • getAddressResolverGroup

        @Nullable
        default @Nullable io.netty.resolver.AddressResolverGroup<InetSocketAddress> getAddressResolverGroup()
        Return the AddressResolverGroup used for asynchronous DNS resolution.

        When non-null, this resolver group is used for hostname resolution instead of the per-request NameResolver. For example, Netty's DnsAddressResolverGroup provides non-blocking DNS lookups with inflight coalescing across concurrent requests for the same hostname.

        By default this returns null, preserving the legacy per-request name resolver behavior. Set via DefaultAsyncHttpClientConfig.Builder.setAddressResolverGroup(AddressResolverGroup).

        Returns:
        the AddressResolverGroup or null to use per-request resolvers
      • isUseNativeTransport

        boolean isUseNativeTransport()
        Whether a native transport was explicitly requested. Note that false no longer forces NIO: a native transport is auto-selected whenever its library is on the classpath. Set -Dio.netty.transport.noNative=true to force NIO.
        Returns:
        true if a native transport was explicitly requested
      • isUseOnlyEpollNativeTransport

        boolean isUseOnlyEpollNativeTransport()
      • getHttpAdditionalChannelInitializer

        @Nullable
        @Nullable Consumer<io.netty.channel.Channel> getHttpAdditionalChannelInitializer()
      • getWsAdditionalChannelInitializer

        @Nullable
        @Nullable Consumer<io.netty.channel.Channel> getWsAdditionalChannelInitializer()
      • getChannelPool

        @Nullable
        @Nullable ChannelPool getChannelPool()
      • getNettyTimer

        @Nullable
        @Nullable io.netty.util.Timer getNettyTimer()
      • getHashedWheelTimerTickDuration

        long getHashedWheelTimerTickDuration()
        Returns:
        the duration between tick of HashedWheelTimer
      • getHashedWheelTimerSize

        int getHashedWheelTimerSize()
        Returns:
        the size of the hashed wheel HashedWheelTimer
      • isValidateResponseHeaders

        boolean isValidateResponseHeaders()
      • isAggregateWebSocketFrameFragments

        boolean isAggregateWebSocketFrameFragments()
      • isEnableWebSocketCompression

        boolean isEnableWebSocketCompression()
      • isTcpNoDelay

        boolean isTcpNoDelay()
      • isSoReuseAddress

        boolean isSoReuseAddress()
      • isSoKeepAlive

        boolean isSoKeepAlive()
      • getSoLinger

        int getSoLinger()
      • getSoSndBuf

        int getSoSndBuf()
      • getSoRcvBuf

        int getSoRcvBuf()
      • getAllocator

        @Nullable
        @Nullable io.netty.buffer.ByteBufAllocator getAllocator()
      • getIoThreadsCount

        int getIoThreadsCount()
      • isStripAuthorizationOnRedirect

        default boolean isStripAuthorizationOnRedirect()
        Indicates whether the Authorization header should be stripped during redirects to a different domain.
        Returns:
        true if the Authorization header should be stripped, false otherwise.