diff options
author | Neil Fuller <nfuller@google.com> | 2015-11-30 21:47:09 +0000 |
---|---|---|
committer | Neil Fuller <nfuller@google.com> | 2015-11-30 21:54:13 +0000 |
commit | b701c07a57f6c8a871ed7a56860c6d0452bd740d (patch) | |
tree | 22b8945e3c9bc94ec51d41570397beb992faaead | |
parent | a51d868761c187255fdfaac767ca6a9c9345d4e8 (diff) | |
download | okhttp-b701c07a57f6c8a871ed7a56860c6d0452bd740d.tar.gz |
Fix HttpURLConnection.setFollowRedirects()
OkHttp's HttpURLConnectionImpl stopped using the static value set
on HttpURLConnection directly with commit
e78f117bcbd6b57d783737107f445ef75ecb474a
and started expecting a new value on OkHttpClient to be set
instead. This means that HttpURLConnection stopped obeying
the HttpURLConnection static setting. This change adds the necessary
behavior back.
Bug: https://code.google.com/p/android/issues/detail?id=194495
Bug: 25928343
Change-Id: Ic808f94056d1932f35e8f72746be8362452797db
-rw-r--r-- | android/main/java/com/squareup/okhttp/HttpHandler.java | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/android/main/java/com/squareup/okhttp/HttpHandler.java b/android/main/java/com/squareup/okhttp/HttpHandler.java index 22a0b15..6f69650 100644 --- a/android/main/java/com/squareup/okhttp/HttpHandler.java +++ b/android/main/java/com/squareup/okhttp/HttpHandler.java @@ -19,6 +19,7 @@ package com.squareup.okhttp; import libcore.net.NetworkSecurityPolicy; import java.io.IOException; +import java.net.HttpURLConnection; import java.net.Proxy; import java.net.ResponseCache; import java.net.URL; @@ -73,6 +74,10 @@ public class HttpHandler extends URLStreamHandler { client.setReadTimeout(0, TimeUnit.MILLISECONDS); client.setWriteTimeout(0, TimeUnit.MILLISECONDS); + // Set the default (same protocol) redirect behavior. The default can be overridden for + // each instance using HttpURLConnection.setInstanceFollowRedirects(). + client.setFollowRedirects(HttpURLConnection.getFollowRedirects()); + // Do not permit http -> https and https -> http redirects. client.setFollowSslRedirects(false); |