Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2030)

Unified Diff: components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetFixedModeOutputStreamTest.java

Issue 2173923002: [Cronet] Mark request as complete when OutputStream fails (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetFixedModeOutputStreamTest.java
diff --git a/components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetFixedModeOutputStreamTest.java b/components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetFixedModeOutputStreamTest.java
index 72f74ae14823bc0c15c03bd96cbe0127dac86a15..d7765f1e260da2874de39bfd41852e40a05fbb24 100644
--- a/components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetFixedModeOutputStreamTest.java
+++ b/components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetFixedModeOutputStreamTest.java
@@ -97,6 +97,46 @@ public class CronetFixedModeOutputStreamTest extends CronetTestBase {
@SmallTest
@Feature({"Cronet"})
@CompareDefaultWithCronet
+ public void testGetResponseAfterWriteFailed() throws Exception {
+ URL url = new URL(NativeTestServer.getEchoBodyURL());
+ NativeTestServer.shutdownNativeTestServer();
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ connection.setDoOutput(true);
+ connection.setRequestMethod("POST");
+ // Set content-length as 1 byte, so Cronet will upload once that 1 byte
+ // is passed to it.
+ connection.setFixedLengthStreamingMode(1);
+ try {
+ OutputStream out = connection.getOutputStream();
+ out.write(1);
+ fail();
+ } catch (IOException e) {
+ if (!testingSystemHttpURLConnection()) {
+ UrlRequestException requestException = (UrlRequestException) e;
+ assertEquals(UrlRequestException.ERROR_CONNECTION_REFUSED,
+ requestException.getErrorCode());
+ }
+ }
+ // Make sure IOException is reported again when trying to read response
+ // from the connection.
+ try {
+ connection.getResponseCode();
+ fail();
+ } catch (IOException e) {
+ // Expected.
+ if (!testingSystemHttpURLConnection()) {
+ UrlRequestException requestException = (UrlRequestException) e;
+ assertEquals(UrlRequestException.ERROR_CONNECTION_REFUSED,
+ requestException.getErrorCode());
+ }
+ }
+ // Restarting server to run the test for a second time.
+ assertTrue(NativeTestServer.startNativeTestServer(getContext()));
+ }
+
+ @SmallTest
+ @Feature({"Cronet"})
+ @CompareDefaultWithCronet
public void testFixedLengthStreamingModeZeroContentLength() throws Exception {
// Check content length is set.
URL echoLength = new URL(NativeTestServer.getEchoHeaderURL("Content-Length"));

Powered by Google App Engine
This is Rietveld 408576698