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

Unified Diff: net/http/http_network_transaction_unittest.cc

Issue 284913003: Remove DCHECK in HttpStreamParser::ReadResponseHeaders. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Really remove line Created 6 years, 7 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
« no previous file with comments | « no previous file | net/http/http_stream_parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_network_transaction_unittest.cc
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc
index e3d3a59641b7fef5a0a133d07fb718af7b4ddba7..64f6fede43313ac0e9266abeee0b8a98626d0cd0 100644
--- a/net/http/http_network_transaction_unittest.cc
+++ b/net/http/http_network_transaction_unittest.cc
@@ -10159,6 +10159,56 @@ TEST_P(HttpNetworkTransactionTest, SimpleCancel) {
base::MessageLoop::current()->RunUntilIdle();
}
+// Test that if a transaction is cancelled after receiving the headers, the
+// stream is drained properly and added back to the socket pool. The main
+// purpose of this test is to make sure that an HttpStreamParser can be read
+// from after the HttpNetworkTransaction and the objects it owns have been
+// deleted.
+// See http://crbug.com/368418
+TEST_P(HttpNetworkTransactionTest, CancelAfterHeaders) {
+ MockRead data_reads[] = {
+ MockRead(ASYNC, "HTTP/1.1 200 OK\r\n"),
+ MockRead(ASYNC, "Content-Length: 2\r\n"),
+ MockRead(ASYNC, "Connection: Keep-Alive\r\n\r\n"),
+ MockRead(ASYNC, "1"),
+ // 2 async reads are necessary to trigger a ReadResponseBody call after the
+ // HttpNetworkTransaction has been deleted.
+ MockRead(ASYNC, "2"),
+ MockRead(SYNCHRONOUS, ERR_IO_PENDING), // Should never read this.
+ };
+ StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
+ session_deps_.socket_factory->AddSocketDataProvider(&data);
+
+ scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
+
+ {
+ HttpRequestInfo request;
+ request.method = "GET";
+ request.url = GURL("http://www.google.com/");
+ request.load_flags = 0;
+
+ HttpNetworkTransaction trans(DEFAULT_PRIORITY, session);
+ TestCompletionCallback callback;
+
+ int rv = trans.Start(&request, callback.callback(), BoundNetLog());
+ EXPECT_EQ(ERR_IO_PENDING, rv);
+ callback.WaitForResult();
+
+ const HttpResponseInfo* response = trans.GetResponseInfo();
+ ASSERT_TRUE(response != NULL);
+ EXPECT_TRUE(response->headers.get() != NULL);
+ EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
+
+ // The transaction and HttpRequestInfo are deleted.
+ }
+
+ // Let the HttpResponseBodyDrainer drain the socket.
+ base::MessageLoop::current()->RunUntilIdle();
+
+ // Socket should now be idle, waiting to be reused.
+ EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session));
+}
+
// Test a basic GET request through a proxy.
TEST_P(HttpNetworkTransactionTest, ProxyGet) {
session_deps_.proxy_service.reset(
« no previous file with comments | « no previous file | net/http/http_stream_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698