| Index: components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetHttpURLConnectionTest.java
|
| diff --git a/components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetHttpURLConnectionTest.java b/components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetHttpURLConnectionTest.java
|
| index bc8ef9873c3d469884bf32c6cd2cc343154c5dc0..c66b4fdbe24289e177b1d027a935970b75d76648 100644
|
| --- a/components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetHttpURLConnectionTest.java
|
| +++ b/components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetHttpURLConnectionTest.java
|
| @@ -846,20 +846,11 @@ public class CronetHttpURLConnectionTest extends CronetTestBase {
|
| @Feature({"Cronet"})
|
| @CompareDefaultWithCronet
|
| public void testServerHangsUp() throws Exception {
|
| - URL url = new URL(NativeTestServer.getEchoBodyURL());
|
| + URL url = new URL(NativeTestServer.getExabyteResponseURL());
|
| final HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
| - // Make the server echo a large request body, so it exceeds the internal
|
| - // read buffer.
|
| - connection.setDoOutput(true);
|
| - connection.setRequestMethod("POST");
|
| - byte[] largeData = TestUtil.getLargeData();
|
| - connection.setFixedLengthStreamingMode(largeData.length);
|
| - OutputStream out = connection.getOutputStream();
|
| - out.write(largeData);
|
| -
|
| InputStream in = connection.getInputStream();
|
| // Read one byte and shut down the server.
|
| - assertTrue(in.read() != 1);
|
| + assertTrue(in.read() != -1);
|
| NativeTestServer.shutdownNativeTestServer();
|
| // Continue reading, and make sure the message loop will not block.
|
| try {
|
| @@ -867,24 +858,32 @@ public class CronetHttpURLConnectionTest extends CronetTestBase {
|
| while (b != -1) {
|
| b = in.read();
|
| }
|
| - // Server closes the connection before EOF can be received.
|
| - fail();
|
| + // On KitKat, the default implementation doesn't throw an error.
|
| + if (!testingSystemHttpURLConnection()) {
|
| + // Server closes the connection before EOF can be received.
|
| + fail();
|
| + }
|
| } catch (IOException e) {
|
| // Expected.
|
| // Cronet gives a net::ERR_CONTENT_LENGTH_MISMATCH while the
|
| - // default implementation gives a java.net.ProtocolException with
|
| - // "unexpected end of stream" message.
|
| + // default implementation sometimes gives a
|
| + // java.net.ProtocolException with "unexpected end of stream"
|
| + // message.
|
| }
|
|
|
| // Read once more, and make sure exception is thrown.
|
| try {
|
| in.read();
|
| - fail();
|
| + // On KitKat, the default implementation doesn't throw an error.
|
| + if (!testingSystemHttpURLConnection()) {
|
| + fail();
|
| + }
|
| } catch (IOException e) {
|
| // Expected.
|
| // Cronet gives a net::ERR_CONTENT_LENGTH_MISMATCH while the
|
| - // default implementation gives a java.net.ProtocolException with
|
| - // "unexpected end of stream" message.
|
| + // default implementation sometimes gives a
|
| + // java.net.ProtocolException with "unexpected end of stream"
|
| + // message.
|
| }
|
| // Spins up server to avoid crash when shutting it down in tearDown().
|
| assertTrue(NativeTestServer.startNativeTestServer(getContext()));
|
|
|