diff --git a/okhttp-tests/src/test/java/com/squareup/okhttp/CallTest.java b/okhttp-tests/src/test/java/com/squareup/okhttp/CallTest.java index cefb681be..0f0852f4d 100644 --- a/okhttp-tests/src/test/java/com/squareup/okhttp/CallTest.java +++ b/okhttp-tests/src/test/java/com/squareup/okhttp/CallTest.java @@ -1393,8 +1393,7 @@ public final class CallTest { .matches("okhttp/\\d\\.\\d\\.\\d(-SNAPSHOT)?")); } - @Test - public void setFollowRedirectsFalse() throws Exception { + @Test public void setFollowRedirectsFalse() throws Exception { server.enqueue(new MockResponse() .setResponseCode(302) .addHeader("Location: /b") diff --git a/okhttp-tests/src/test/java/com/squareup/okhttp/OkHttpClientTest.java b/okhttp-tests/src/test/java/com/squareup/okhttp/OkHttpClientTest.java index 7ecd2a1ff..41cdcf43e 100644 --- a/okhttp-tests/src/test/java/com/squareup/okhttp/OkHttpClientTest.java +++ b/okhttp-tests/src/test/java/com/squareup/okhttp/OkHttpClientTest.java @@ -35,6 +35,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; public final class OkHttpClientTest { private static final ProxySelector DEFAULT_PROXY_SELECTOR = ProxySelector.getDefault(); @@ -164,4 +165,13 @@ public final class OkHttpClientTest { Response actualResponse = mockClient.newCall(request).execute(); assertSame(response, actualResponse); } + + @Test public void setProtocolsRejectsHttp10() throws Exception { + OkHttpClient client = new OkHttpClient(); + try { + client.setProtocols(Arrays.asList(Protocol.HTTP_1_0, Protocol.HTTP_1_1)); + fail(); + } catch (IllegalArgumentException expected) { + } + } } diff --git a/okhttp/src/main/java/com/squareup/okhttp/OkHttpClient.java b/okhttp/src/main/java/com/squareup/okhttp/OkHttpClient.java index 69029dfa4..d99a961cc 100644 --- a/okhttp/src/main/java/com/squareup/okhttp/OkHttpClient.java +++ b/okhttp/src/main/java/com/squareup/okhttp/OkHttpClient.java @@ -427,14 +427,22 @@ public class OkHttpClient implements Cloneable { * ALPN * will be used to negotiate a transport. * + *
{@link Protocol#HTTP_1_0} is not supported in this set. Requests are
+ * initiated with {@code HTTP/1.1} only. If the server responds with {@code
+ * HTTP/1.0}, that will be exposed by {@link Response#protocol()}.
+ *
* @param protocols the protocols to use, in order of preference. The list
- * must contain {@link Protocol#HTTP_1_1}. It must not contain null.
+ * must contain {@link Protocol#HTTP_1_1}. It must not contain null or
+ * {@link Protocol#HTTP_1_0}.
*/
public final OkHttpClient setProtocols(List