// Path: src/main/java/com/burgstaller/okhttp/digest/CachingAuthenticator.java
// public interface CachingAuthenticator extends Authenticator {
//     /**
//      * Authenticate the new request using cached information already established from an earlier
//      * authentication.
//      *
//      * @param route   the route to use
//      * @param request the new request to be authenticated.
//      * @return the modified request with updated auth headers.
//      * @throws IOException in case of a communication problem
//      */
//     Request authenticateWithState(Route route, Request request) throws IOException;
// }


import com.burgstaller.okhttp.digest.CachingAuthenticator;
import java.io.IOException;
import java.util.Map;
import okhttp3.Connection;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.Route;
import okhttp3.internal.platform.Platform;
import static java.net.HttpURLConnection.HTTP_PROXY_AUTH;
import static java.net.HttpURLConnection.HTTP_UNAUTHORIZED;
package com.burgstaller.okhttp;





/**
 * An HTTP Request interceptor that adds previous auth headers in to the same host. This enables the
 * client to reduce the number of 401 auth request/response cycles.
 */
public class AuthenticationCacheInterceptor implements Interceptor {
    private final Map<String, CachingAuthenticator> authCache;
    private final CacheKeyProvider cacheKeyProvider;

    public AuthenticationCacheInterceptor(Map<String, CachingAuthenticator> authCache, CacheKeyProvider cacheKeyProvider) {
        this.authCache = authCache;
        this.cacheKeyProvider = cacheKeyProvider;
    }

// Path: src/main/java/com/burgstaller/okhttp/digest/CachingAuthenticator.java
// public interface CachingAuthenticator extends Authenticator {
//     /**
//      * Authenticate the new request using cached information already established from an earlier
//      * authentication.
//      *
//      * @param route   the route to use
//      * @param request the new request to be authenticated.
//      * @return the modified request with updated auth headers.
//      * @throws IOException in case of a communication problem
//      */
//     Request authenticateWithState(Route route, Request request) throws IOException;
// }


// Path: src/main/java/com/burgstaller/okhttp/AuthenticationCacheInterceptor.java
import com.burgstaller.okhttp.digest.CachingAuthenticator;
import java.io.IOException;
import java.util.Map;
import okhttp3.Connection;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.Route;
import okhttp3.internal.platform.Platform;
import static java.net.HttpURLConnection.HTTP_PROXY_AUTH;
import static java.net.HttpURLConnection.HTTP_UNAUTHORIZED;

package com.burgstaller.okhttp;





/**
 * An HTTP Request interceptor that adds previous auth headers in to the same host. This enables the
 * client to reduce the number of 401 auth request/response cycles.
 */
public class AuthenticationCacheInterceptor implements Interceptor {
    private final Map<String, CachingAuthenticator> authCache;
    private final CacheKeyProvider cacheKeyProvider;

    public AuthenticationCacheInterceptor(Map<String, CachingAuthenticator> authCache, CacheKeyProvider cacheKeyProvider) {
        this.authCache = authCache;
        this.cacheKeyProvider = cacheKeyProvider;
    }

    public AuthenticationCacheInterceptor(Map<String, CachingAuthenticator> authCache) {