-
Notifications
You must be signed in to change notification settings - Fork 9.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add basic URLFilter for HttpURLConnection #2275
Conversation
Sorry, this use case is too obscure to warrant extra API. If you really need this behavior, write your own URLStreamHandler that delegates to OkHttp’s UrlStreamHandler. |
@@ -148,6 +149,30 @@ public void setInstanceFollowRedirectsFalse() throws Exception { | |||
assertResponseCode(connection, 302); | |||
} | |||
|
|||
@Test | |||
public void testURLFilter() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wanna test redirect from HTTPS to HTTP ? I think we have some tests like that lying around somewhere!
Is there a way we can make this UrlFilter interface non-public and expose this behavior only to AOSP? |
We can make it package private to keep it AOSP only. |
b82e2a8
to
c95b901
Compare
I made the OkUrlFactory.setUrlFilter method package private, that works fine for AOSP but will keep it from being publicly usable. The interface is still public since it is referenced by HttpURLConnectionImpl but I could move it into okhttp3.internal as well. |
Awesome, yes please do. |
c95b901
to
37baf47
Compare
Done |
This optional filter can be used to allow for blocking HTTP traffic to certain URLs, for example in order to prevent accessing sensitive content over HTTP instead of HTTPS.
37baf47
to
2b1f9a2
Compare
Fixed an unused import that I missed when moving the interface to internal. |
Add basic URLFilter for HttpURLConnection
Neat! Thanks for jumping through all the hoops for me! |
Thanks! Sorry for not being clearer on the usage from the start. On Tue, Jan 26, 2016, 18:10 Jesse Wilson notifications@github.com wrote:
|
This was previously commit to AOSP as 27c8053 The upstream commit was contained in OkHttp 3.0 but not 2.7.5. Previous commit message: This optional filter can be used to allow for blocking HTTP traffic to certain URLs, for example in order to prevent accessing sensitive content over HTTP instead of HTTPS. square/okhttp#2275 (cherry-picked from upstream commit 2b1f9a20bac5d99acf5a8be36754e5a1dadaf448) Change-Id: Icb6057e9d32752c948d92c3973a4d67fd48cb43d
This optional filter can be used to allow for blocking HTTP traffic to
certain URLs, for example in order to prevent accessing sensitive
content over HTTP instead of HTTPS.
This behavior is already possible for clients of OkHttpClient, this patch allows legacy clients using the HttpUrlConnection APIs to do basic blocking.
See #2269