类 HTTPClientBuilder


  • public class HTTPClientBuilder
    extends Object
    Builder to build Http Client.
    • 构造器详细资料

      • HTTPClientBuilder

        public HTTPClientBuilder()
    • 方法详细资料

      • build

        public HTTPClient build()
        Build a new http Client.
        返回:
        the http client
      • proxy

        public HTTPClientBuilder proxy​(ProxySelector proxySelector)
        Set a proxy selector for this client. If not set, will use no proxy. Note: seems JDK HttpClient Only support http proxy.
      • proxy

        public HTTPClientBuilder proxy​(Proxy proxy)
        Set a proxy for this client. If not set, will use no proxy. Note: seems JDK HttpClient Only support http proxy.
      • useHttp2

        public HTTPClientBuilder useHttp2​(boolean useHttp2)
        If use http2. default true
      • verifyCert

        public HTTPClientBuilder verifyCert​(boolean verify)
        If check https certificate, default true.
      • followRedirect

        public HTTPClientBuilder followRedirect​(boolean followRedirect)
        If follow redirects. Default true
      • connectTimeout

        public HTTPClientBuilder connectTimeout​(Duration timeout)
        Set timeout for connecting phase. The timeout include ssl handshake, etc. Default is 5 secs.
      • timeout

        public HTTPClientBuilder timeout​(Duration timeout)
        The timeout for one request to return response, do not include connect time. Default is 10 secs. Note: The can be override by request setting.
      • userAgent

        public HTTPClientBuilder userAgent​(String userAgent)
        The client user-agent. Note: The can be override by request setting.
      • acceptCompress

        public HTTPClientBuilder acceptCompress​(boolean acceptCompress)
        Auto set Accept-Encoding header for request. Default is true. Note: This setting can be override by per request setting.
      • authenticator

        public HTTPClientBuilder authenticator​(Authenticator authenticator)
        Provide Authenticator for http basic or digest Authentication. If not set, will use system default Authenticator.
        参数:
        authenticator - the authenticator
        返回:
        self
      • cookieHandler

        public HTTPClientBuilder cookieHandler​(CookieHandler cookieHandler)
        Provide CookieHandler for handle cookies.If not set, will use default in-memory store CookieManager.
        参数:
        cookieHandler - the cookieManager
        返回:
        self
      • keyStore

        public HTTPClientBuilder keyStore​(KeyStore keyStore)
        Provide KeyStore for create ssl connection, trust the server certificate.
        参数:
        keyStore - the keyStore
        返回:
        self
      • executor

        public HTTPClientBuilder executor​(Executor executor)
        Set a custom executor, for asynchronous and dependent tasks.
        参数:
        executor - the executor
        返回:
        self