类 ClientBuilder


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

      • ClientBuilder

        public ClientBuilder()
    • 方法详细资料

      • build

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

        public ClientBuilder 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 ClientBuilder 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 ClientBuilder useHttp2​(boolean useHttp2)
        If use http2. default true
      • verifyCert

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

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

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

        public ClientBuilder 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 ClientBuilder userAgent​(String userAgent)
        The client user-agent. Note: The can be override by request setting.
      • acceptCompressed

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

        public ClientBuilder 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 ClientBuilder cookieHandler​(CookieHandler cookieHandler)
        Provide CookieHandler for handle cookies.If not set, will use default in-memory store CookieManager.
        参数:
        cookieHandler - the cookieManager
        返回:
        self
      • keyStore

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

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

        public ClientBuilder jsonMarshaller​(JsonMarshaller jsonMarshaller)
        Set json marshaller for this http client. If not set, will try to find available JsonMarshaller implementation by spi; If no spi implementation was found, a JsonMarshallerNotFoundException would be thrown when handle with json.
        参数:
        jsonMarshaller - the JsonMarshaller