Search in sources :

Example 71 with Authenticator

use of okhttp3.Authenticator in project codekvast by crispab.

the class AgentConfig method getHttpClient.

public OkHttpClient getHttpClient() {
    if (httpClient == null) {
        validate();
        OkHttpClient.Builder builder = new OkHttpClient.Builder().connectTimeout(httpConnectTimeoutSeconds, TimeUnit.SECONDS).writeTimeout(httpWriteTimeoutSeconds, TimeUnit.SECONDS).readTimeout(httpReadTimeoutSeconds, TimeUnit.SECONDS);
        Proxy proxy = createHttpProxy();
        if (proxy != null) {
            builder.proxy(proxy);
        }
        Authenticator proxyAuthenticator = createProxyAuthenticator();
        if (proxyAuthenticator != null) {
            builder.proxyAuthenticator(proxyAuthenticator);
        }
        httpClient = builder.build();
    }
    return httpClient;
}
Also used : Proxy(java.net.Proxy) OkHttpClient(okhttp3.OkHttpClient) Authenticator(okhttp3.Authenticator)

Aggregations

Test (org.junit.Test)37 Request (okhttp3.Request)27 OkHttpClient (okhttp3.OkHttpClient)26 Response (okhttp3.Response)24 MockResponse (okhttp3.mockwebserver.MockResponse)23 Authenticator (okhttp3.Authenticator)20 IOException (java.io.IOException)15 RecordingOkAuthenticator (okhttp3.internal.RecordingOkAuthenticator)15 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)13 Route (okhttp3.Route)12 BasicAuthenticator (com.burgstaller.okhttp.basic.BasicAuthenticator)9 DigestAuthenticator (com.burgstaller.okhttp.digest.DigestAuthenticator)8 CachingAuthenticator (com.burgstaller.okhttp.digest.CachingAuthenticator)7 InetSocketAddress (java.net.InetSocketAddress)7 RecordingAuthenticator (okhttp3.internal.RecordingAuthenticator)6 Credentials (com.burgstaller.okhttp.digest.Credentials)5 InetAddress (java.net.InetAddress)5 Proxy (java.net.Proxy)5 Interceptor (okhttp3.Interceptor)5 HttpLoggingInterceptor (okhttp3.logging.HttpLoggingInterceptor)5