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 b1c80b01f..b9c679332 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 @@ -2570,7 +2570,6 @@ public final class URLConnectionTest { reusedConnectionFailsWithPost(TransferKind.END_OF_STREAM, 1024); } - // This test is ignored because we don't (yet) reliably recover for large request bodies. @Test public void postFailsWithBufferedRequestForLargeRequest() throws Exception { reusedConnectionFailsWithPost(TransferKind.END_OF_STREAM, 16384); } @@ -2603,14 +2602,24 @@ public final class URLConnectionTest { byte[] requestBody = new byte[requestSize]; new Random(0).nextBytes(requestBody); - connection = client.open(server.getUrl("/b")); - connection.setRequestMethod("POST"); - transferKind.setForRequest(connection, requestBody.length); - for (int i = 0; i < requestBody.length; i += 1024) { - connection.getOutputStream().write(requestBody, i, 1024); + for (int j = 0; j < 2; j++) { + try { + connection = client.open(server.getUrl("/b")); + connection.setRequestMethod("POST"); + transferKind.setForRequest(connection, requestBody.length); + for (int i = 0; i < requestBody.length; i += 1024) { + connection.getOutputStream().write(requestBody, i, 1024); + } + connection.getOutputStream().close(); + assertContent("B", connection); + break; + } catch (IOException socketException) { + // If there's a socket exception, this must have a streamed request body. + assertEquals(0, j); + assertTrue(transferKind == TransferKind.CHUNKED + || transferKind == TransferKind.FIXED_LENGTH); + } } - connection.getOutputStream().close(); - assertContent("B", connection); RecordedRequest requestA = server.takeRequest(); assertEquals("/a", requestA.getPath());