-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from clescot/allow_proxy_and_site_authenticati…
…on_in_the_same_time - permit to cache Proxy authentication, and to combine with website authentication
- Loading branch information
Showing
17 changed files
with
674 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 13 additions & 7 deletions
20
src/main/java/com/burgstaller/okhttp/CacheKeyProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,22 @@ | ||
package com.burgstaller.okhttp; | ||
|
||
import okhttp3.Request; | ||
|
||
/** | ||
* Provides the caching key for the given request. Can be used to share passwords accross multiple subdomains. | ||
* Provides the caching key for the given request or {@link java.net.Proxy}. Can be used to share passwords accross multiple subdomains. | ||
* @see java.net.Proxy | ||
*/ | ||
public interface CacheKeyProvider { | ||
public interface CacheKeyProvider<T> { | ||
|
||
/** | ||
* | ||
* @return true if the key is forged from a {@link java.net.Proxy} Object. | ||
*/ | ||
boolean applyToProxy(); | ||
/** | ||
* Provides the caching key for the given request. Can be used to share passwords accross multiple subdomains. | ||
* Provides the caching key for the given request or {@link java.net.Proxy}. Can be used to share passwords accross multiple subdomains. | ||
* | ||
* @param request the http request. | ||
* @param request the http request, or a {@link java.net.Proxy} if the applyToProxy method returns true. | ||
* @return the cache key. | ||
*/ | ||
String getCachingKey(Request request); | ||
String getCachingKey(T request); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/java/com/burgstaller/okhttp/DefaultProxyCacheKeyProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.burgstaller.okhttp; | ||
|
||
import java.net.Proxy; | ||
|
||
/** | ||
* The default version of the cache key provider, which simply calls the {@link java.net.Proxy#toString()} method to generate key. | ||
*/ | ||
public final class DefaultProxyCacheKeyProvider implements CacheKeyProvider<Proxy> { | ||
@Override | ||
public boolean applyToProxy() { | ||
return true; | ||
} | ||
|
||
/** | ||
* | ||
* @param proxy {@link java.net.Proxy} used to get the cache key. | ||
* @return the cache key. | ||
*/ | ||
@Override | ||
public String getCachingKey(Proxy proxy) { | ||
return proxy != null ? proxy.toString() : null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.