commit | ceafaf318f1176d96d18ed04355f76fa91a8e12b | [log] [tgz] |
---|---|---|
author | Neil Fuller <nfuller@google.com> | Tue Oct 20 20:56:07 2015 +0100 |
committer | Neil Fuller <nfuller@google.com> | Fri Oct 23 16:30:29 2015 +0100 |
tree | b906a02ff7234dfc82183d6ed73027a219f115fd | |
parent | d1c79b97469b8364983ef20a8b1efe40860016ad [diff] |
Fix Http(s)URLConnectionImpl.getInstanceFollowsRedirects() 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 Change-Id: I3873cb59b8cd95aef2641d6b238ac65341eaba12
diff --git a/okhttp-tests/src/test/java/com/squareup/okhttp/URLConnectionTest.java b/okhttp-tests/src/test/java/com/squareup/okhttp/URLConnectionTest.java index 1b75090..745a372 100644 --- a/okhttp-tests/src/test/java/com/squareup/okhttp/URLConnectionTest.java +++ b/okhttp-tests/src/test/java/com/squareup/okhttp/URLConnectionTest.java
@@ -3231,6 +3231,20 @@ } } + @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 1cddd3e..e095715 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
@@ -286,6 +286,10 @@ client.setFollowRedirects(followRedirects); } + @Override public boolean getInstanceFollowRedirects() { + return client.getFollowRedirects(); + } + @Override public int getConnectTimeout() { return client.getConnectTimeout(); }