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

Unified Diff: net/http/http_network_transaction_unittest.cc

Issue 4264: If we read nothing (EOF) after sending a request on a... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 3 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 | « net/http/http_network_transaction.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_network_transaction_unittest.cc
===================================================================
--- net/http/http_network_transaction_unittest.cc (revision 2563)
+++ net/http/http_network_transaction_unittest.cc (working copy)
@@ -491,3 +491,69 @@
MessageLoop::current()->RunAllPending();
}
}
+
+// TODO(wtc): share code with KeepAliveConnectionReset. These two tests
+// differ only in data1_reads[2].
+TEST_F(HttpNetworkTransactionTest, KeepAliveConnectionEOF) {
+ scoped_refptr<net::HttpNetworkSession> session = CreateSession();
+
+ net::HttpRequestInfo request;
+ request.method = "GET";
+ request.url = GURL("http://www.foo.com/");
+ request.load_flags = 0;
+
+ MockRead data1_reads[] = {
+ { true, 0, "HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n", -1 },
+ { true, 0, "hello", -1 },
+ { false, net::OK, NULL, 0 },
+ };
+ MockSocket data1;
+ data1.connect.async = true;
+ data1.connect.result = net::OK;
+ data1.reads = data1_reads;
+ mock_sockets[0] = &data1;
+
+ MockRead data2_reads[] = {
+ { true, 0, "HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n", -1 },
+ { true, 0, "world", -1 },
+ { true, net::OK, NULL, 0 },
+ };
+ MockSocket data2;
+ data2.connect.async = true;
+ data2.connect.result = net::OK;
+ data2.reads = data2_reads;
+ mock_sockets[1] = &data2;
+
+ const char* kExpectedResponseData[] = {
+ "hello", "world"
+ };
+
+ for (int i = 0; i < 2; ++i) {
+ TestCompletionCallback callback;
+
+ net::HttpTransaction* trans =
+ new net::HttpNetworkTransaction(session, &mock_socket_factory);
+
+ int rv = trans->Start(&request, &callback);
+ EXPECT_EQ(net::ERR_IO_PENDING, rv);
+
+ rv = callback.WaitForResult();
+ EXPECT_EQ(net::OK, rv);
+
+ const net::HttpResponseInfo* response = trans->GetResponseInfo();
+ EXPECT_TRUE(response != NULL);
+
+ EXPECT_TRUE(response->headers != NULL);
+ EXPECT_TRUE(response->headers->GetStatusLine() == "HTTP/1.1 200 OK");
+
+ std::string response_data;
+ rv = ReadTransaction(trans, &response_data);
+ EXPECT_EQ(net::OK, rv);
+ EXPECT_TRUE(response_data == kExpectedResponseData[i]);
+
+ trans->Destroy();
+
+ // Empty the current queue.
+ MessageLoop::current()->RunAllPending();
+ }
+}
« no previous file with comments | « net/http/http_network_transaction.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698