Class OkHttpClientBuilder
java.lang.Object
com.amilesend.client.connection.http.OkHttpClientBuilder
Utility to configure and build a 
OkHttpClient with the option of default configuration for this client.
This supports configuring a client that:
- Customizes the SSL trust manager and hostname verifier
- Configures a proxy with username and password
- Configures support to follow redirects
- Configures connection and read/write timeouts (default is disabled)
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionaddInterceptor(okhttp3.Interceptor interceptor) Adds an interceptor for the client.okhttp3.OkHttpClientbuild()Builds a newOkHttpClientinstance.connectTimeout(Duration connectTimeout) Sets the connection timeout for the HTTP client.hostnameVerifier(HostnameVerifier hostnameVerifier) Sets the hostname verifier to use with the HTTP client.isForTest(boolean isForTest) Sets the flag to allow for non-SSL/TLS based requests used for testing.isRedirectsAllowed(boolean isRedirectsAllowed) Sets the flag to allow for automatic URL redirects when responses return 300-based HTTP responses.Sets the proxy and associated username plus password to use with the HTTP client.Sets the proxy and associated authenticator to use with the HTTP client.readTimeout(Duration readTimeout) Sets the read timeout for the HTTP client.trustManager(X509TrustManager trustManager) Sets the SSL/TLS trust manager to use with the HTTP client.writeTimeout(Duration writeTimeout) Sets the write timeout for the HTTP client.
- 
Constructor Details- 
OkHttpClientBuilderpublic OkHttpClientBuilder()
 
- 
- 
Method Details- 
trustManagerSets the SSL/TLS trust manager to use with the HTTP client.- Parameters:
- trustManager- the trust manager
- Returns:
- the builder instance
- See Also:
 
- 
hostnameVerifierSets the hostname verifier to use with the HTTP client.- Parameters:
- hostnameVerifier- the trust manager
- Returns:
- the builder instance
- See Also:
 
- 
proxySets the proxy and associated username plus password to use with the HTTP client. Note: ifusernameandpasswordis undefined, then no credential-based authentication will be configured.- Parameters:
- proxy- the proxy settings
- username- the username
- password- the password
- Returns:
- the builder instance
 
- 
proxySets the proxy and associated authenticator to use with the HTTP client.- Parameters:
- proxy- the proxy settings
- proxyAuthenticator- the proxy authenticator
- Returns:
- the builder instance
 
- 
connectTimeoutSets the connection timeout for the HTTP client.- Parameters:
- connectTimeout- the connection timeout
- Returns:
- the builder instance
 
- 
readTimeoutSets the read timeout for the HTTP client.- Parameters:
- readTimeout- the read timeout
- Returns:
- the builder instance
 
- 
writeTimeoutSets the write timeout for the HTTP client.- Parameters:
- writeTimeout- the write timeout.
- Returns:
- the builder instance
 
- 
isRedirectsAllowedSets the flag to allow for automatic URL redirects when responses return 300-based HTTP responses.- Parameters:
- isRedirectsAllowed- If- true, then the client will automatically invoke the redirected URL; else,- false
- Returns:
- the builder instance
 
- 
isForTestSets the flag to allow for non-SSL/TLS based requests used for testing. Note: Should not be set for normal use with real calls to the Graph API.- Parameters:
- isForTest- If- true, then the client will allow HTTP-based invocations; else,- false.
- Returns:
- the builder instance
 
- 
addInterceptorAdds an interceptor for the client.- Parameters:
- interceptor- the interceptor
- Returns:
- the builder instance
 
- 
buildpublic okhttp3.OkHttpClient build()Builds a newOkHttpClientinstance.- Returns:
- the configured HTTP client
 
 
-