Package org.sonarqube.ws.client
Class OkHttpClientBuilder
java.lang.Object
org.sonarqube.ws.client.OkHttpClientBuilder
Helper to build an instance of
OkHttpClient
that
correctly supports HTTPS and proxy authentication. It also handles
sending of User-Agent header.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionokhttp3.OkHttpClient
build()
setConnectTimeoutMs
(long l) Sets the default connect timeout for new connections.setCredentials
(String credentials) Set credentials that will be passed on every requestsetFollowRedirects
(Boolean followRedirects) Set if redirects should be followed or not.Optional proxy.Login required for proxy authentication.Password used for proxy authentication.setReadTimeoutMs
(long l) Sets the default read timeout for new connections.setSSLSocketFactory
(SSLSocketFactory sslSocketFactory) Optional SSL socket factory with which SSL sockets will be created to establish SSL connections.setTrustManager
(X509TrustManager sslTrustManager) Optional SSL trust manager used to validate certificates.Optional User-Agent.
-
Constructor Details
-
OkHttpClientBuilder
public OkHttpClientBuilder()
-
-
Method Details
-
setUserAgent
Optional User-Agent. If set, then all the requests sent by theOkHttpClient
will include the header "User-Agent". -
setSSLSocketFactory
Optional SSL socket factory with which SSL sockets will be created to establish SSL connections. If not set, a default SSL socket factory will be used, base d on the JVM's default key store. -
setTrustManager
Optional SSL trust manager used to validate certificates. If not set, a default system trust manager will be used, based on the JVM's default truststore. -
setProxy
Optional proxy. If set, then all the requests sent by theOkHttpClient
will reach the proxy. If not set, then the system-wide proxy is used. -
setProxyLogin
Login required for proxy authentication. -
setProxyPassword
Password used for proxy authentication. It is ignored if proxy login is not defined (seesetProxyLogin(String)
). It can be null or empty when login is defined. -
setConnectTimeoutMs
Sets the default connect timeout for new connections. A value of 0 means no timeout. Default is defined by OkHttp (10 seconds in OkHttp 3.3). -
setCredentials
Set credentials that will be passed on every request -
setReadTimeoutMs
Sets the default read timeout for new connections. A value of 0 means no timeout. Default is defined by OkHttp (10 seconds in OkHttp 3.3). -
setFollowRedirects
Set if redirects should be followed or not. Default is defined by OkHttp (true, follow redirects). -
build
public okhttp3.OkHttpClient build()
-