- java.lang.Object
-
- net.dongliu.cute.http.HTTPClientBuilder
-
public class HTTPClientBuilder extends Object
Builder to build Http Client.
-
-
构造器概要
构造器 构造器 说明 HTTPClientBuilder()
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 HTTPClientBuilderacceptCompress(boolean acceptCompress)Auto set Accept-Encoding header for request.HTTPClientBuilderauthenticator(Authenticator authenticator)Provide Authenticator for http basic or digest Authentication.HTTPClientbuild()Build a new http Client.HTTPClientBuilderconnectTimeout(Duration timeout)Set timeout for connecting phase.HTTPClientBuildercookieHandler(CookieHandler cookieHandler)Provide CookieHandler for handle cookies.If not set, will use default in-memory store CookieManager.HTTPClientBuilderexecutor(Executor executor)Set a custom executor, for asynchronous and dependent tasks.HTTPClientBuilderfollowRedirect(boolean followRedirect)If follow redirects.HTTPClientBuilderkeyStore(KeyStore keyStore)Provide KeyStore for create ssl connection, trust the server certificate.HTTPClientBuildername(String name)Set name for this http clientHTTPClientBuilderproxy(Proxy proxy)Set a proxy for this client.HTTPClientBuilderproxy(ProxySelector proxySelector)Set a proxy selector for this client.HTTPClientBuildertimeout(Duration timeout)The timeout for one request to return response, do not include connect time.HTTPClientBuilderuseHttp2(boolean useHttp2)If use http2. default trueHTTPClientBuilderuserAgent(String userAgent)The client user-agent.HTTPClientBuilderverifyCert(boolean verify)If check https certificate, default true.
-
-
-
方法详细资料
-
build
public HTTPClient build()
Build a new http Client.- 返回:
- the http client
-
name
public HTTPClientBuilder name(String name)
Set name for this 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
-
-