aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Fuller <nfuller@google.com>2015-11-30 21:47:09 +0000
committerNeil Fuller <nfuller@google.com>2015-11-30 21:54:13 +0000
commitb701c07a57f6c8a871ed7a56860c6d0452bd740d (patch)
tree22b8945e3c9bc94ec51d41570397beb992faaead
parenta51d868761c187255fdfaac767ca6a9c9345d4e8 (diff)
downloadokhttp-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.java5
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);