public OkHttpClient build() {
    OkHttpClient.Builder builder = new OkHttpClient.Builder();
    builder.proxy(proxy);
    if (connectTimeoutMs >= 0) {
      builder.connectTimeout(connectTimeoutMs, TimeUnit.MILLISECONDS);
    }
    if (readTimeoutMs >= 0) {
      builder.readTimeout(readTimeoutMs, TimeUnit.MILLISECONDS);
    }
    if (responseTimeoutMs >= 0) {
      builder.callTimeout(responseTimeoutMs, TimeUnit.MILLISECONDS);
    }
    builder.addNetworkInterceptor(this::addHeaders);
    if (!acceptGzip) {
      builder.addNetworkInterceptor(new GzipRejectorInterceptor());
    }
    if (proxyLogin != null) {
      builder.proxyAuthenticator((route, response) -> {
        if (response.request().header(PROXY_AUTHORIZATION) != null) {
          // Give up, we've already attempted to authenticate.
          return null;
        }
        if (HttpURLConnection.HTTP_PROXY_AUTH == response.code()) {
          String credential = Credentials.basic(proxyLogin, nullToEmpty(proxyPassword), UTF_8);
          return response.request().newBuilder().header(PROXY_AUTHORIZATION, credential).build();
        }
        return null;
      });
    }
    if (followRedirects != null) {
      builder.followRedirects(followRedirects);
      builder.followSslRedirects(followRedirects);
    }

    ConnectionSpec tls = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
      .allEnabledTlsVersions()
      .allEnabledCipherSuites()
      .supportsTlsExtensions(true)
      .build();
    builder.connectionSpecs(asList(tls, ConnectionSpec.CLEARTEXT));

    X509TrustManager trustManager = sslTrustManager != null ? sslTrustManager : systemDefaultTrustManager();
    SSLSocketFactory sslFactory = sslSocketFactory != null ? sslSocketFactory : systemDefaultSslSocketFactory(trustManager);
    builder.sslSocketFactory(sslFactory, trustManager);

    builder.addInterceptor(buildLoggingInterceptor());

    return builder.build();
  }
@Test
  public void build_default_instance_of_OkHttpClient() {
    OkHttpClient okHttpClient = underTest.build();

    assertThat(okHttpClient.proxy()).isNull();
    assertThat(okHttpClient.networkInterceptors()).hasSize(2);
    assertThat(okHttpClient.sslSocketFactory()).isNotNull();
    assertThat(okHttpClient.followRedirects()).isTrue();
    assertThat(okHttpClient.followSslRedirects()).isTrue();
  }