diff options
author | Neil Fuller <nfuller@google.com> | 2015-10-20 20:56:07 +0100 |
---|---|---|
committer | Neil Fuller <nfuller@google.com> | 2015-10-23 16:51:14 +0100 |
commit | 083b407508308128f49a9923b84b8615b5d9e957 (patch) | |
tree | d7671c30869f36cfdd9ee85a7d10e47d56615351 | |
parent | 140534546b7082fc034c5d0f642557ec12e9ff1a (diff) | |
download | okhttp-marshmallow-mr1-dev.tar.gz |
Fix Http(s)URLConnectionImpl.getInstanceFollowsRedirects()marshmallow-mr1-dev
This is the proposed upstream PR:
https://github.com/square/okhttp/pull/1939
Bug: 25138800
Bug: https://code.google.com/p/android/issues/detail?id=190998
(cherry-picked from commit ceafaf318f1176d96d18ed04355f76fa91a8e12b)
Change-Id: I8101d6d7b89cb931a76d79caa5fbc36470c80024
2 files changed, 18 insertions, 0 deletions
diff --git a/okhttp-tests/src/test/java/com/squareup/okhttp/internal/http/URLConnectionTest.java b/okhttp-tests/src/test/java/com/squareup/okhttp/internal/http/URLConnectionTest.java index f541c31..431461b 100644 --- a/okhttp-tests/src/test/java/com/squareup/okhttp/internal/http/URLConnectionTest.java +++ b/okhttp-tests/src/test/java/com/squareup/okhttp/internal/http/URLConnectionTest.java @@ -3119,6 +3119,20 @@ public final class URLConnectionTest { assertContent("abc", client.open(server.getUrl("/"))); } + @Test void instanceFollowsRedirects() throws Exception { + testInstanceFollowsRedirects("http://www.google.com/"); + testInstanceFollowsRedirects("https://www.google.com/"); + } + + private void testInstanceFollowsRedirects(String spec) throws Exception { + URL url = new URL(spec); + HttpURLConnection urlConnection = client.open(url); + urlConnection.setInstanceFollowRedirects(true); + assertTrue(urlConnection.getInstanceFollowRedirects()); + urlConnection.setInstanceFollowRedirects(false); + assertFalse(urlConnection.getInstanceFollowRedirects()); + } + /** Returns a gzipped copy of {@code bytes}. */ public Buffer gzip(String data) throws IOException { Buffer result = new Buffer(); diff --git a/okhttp-urlconnection/src/main/java/com/squareup/okhttp/internal/huc/HttpURLConnectionImpl.java b/okhttp-urlconnection/src/main/java/com/squareup/okhttp/internal/huc/HttpURLConnectionImpl.java index d09e971..0a014ac 100644 --- a/okhttp-urlconnection/src/main/java/com/squareup/okhttp/internal/huc/HttpURLConnectionImpl.java +++ b/okhttp-urlconnection/src/main/java/com/squareup/okhttp/internal/huc/HttpURLConnectionImpl.java @@ -279,6 +279,10 @@ public class HttpURLConnectionImpl extends HttpURLConnection { client.setFollowRedirects(followRedirects); } + @Override public boolean getInstanceFollowRedirects() { + return client.getFollowRedirects(); + } + @Override public int getConnectTimeout() { return client.getConnectTimeout(); } |