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

Unified Diff: net/http/http_network_transaction_unittest.cc

Issue 8775044: Resend requests when we only learn a connection has closed while (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Response to comments Created 9 years 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 112998)
+++ net/http/http_network_transaction_unittest.cc (working copy)
@@ -174,7 +174,12 @@
MessageLoop::current()->RunAllPending();
}
- void KeepAliveConnectionResendRequestTest(const MockRead& read_failure);
+ // Either |write_failure| specifies a write failure or |read_failure|
+ // specifies a read failure when using a reused socket. In either case, the
+ // failure should cause the network transaction to resend the request, and the
+ // other argument should be NULL.
+ void KeepAliveConnectionResendRequestTest(const MockWrite* write_failure,
+ const MockRead* read_failure);
SimpleGetHelperResult SimpleGetHelperForData(StaticSocketDataProvider* data[],
size_t data_count) {
@@ -1006,10 +1011,9 @@
EXPECT_EQ(ERR_EMPTY_RESPONSE, rv);
}
-// read_failure specifies a read failure that should cause the network
-// transaction to resend the request.
void HttpNetworkTransactionTest::KeepAliveConnectionResendRequestTest(
- const MockRead& read_failure) {
+ const MockWrite* write_failure,
+ const MockRead* read_failure) {
HttpRequestInfo request;
request.method = "GET";
request.url = GURL("http://www.foo.com/");
@@ -1018,12 +1022,33 @@
SessionDependencies session_deps;
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));
+ // Written data for successfully sending both requests.
+ MockWrite data1_writes[] = {
+ MockWrite("GET / HTTP/1.1\r\n"
+ "Host: www.foo.com\r\n"
+ "Connection: keep-alive\r\n\r\n"),
+ MockWrite("GET / HTTP/1.1\r\n"
+ "Host: www.foo.com\r\n"
+ "Connection: keep-alive\r\n\r\n")
+ };
+
+ // Read results for the first request.
MockRead data1_reads[] = {
MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"),
MockRead("hello"),
- read_failure, // Now, we reuse the connection and fail the first read.
+ MockRead(true, OK),
};
- StaticSocketDataProvider data1(data1_reads, arraysize(data1_reads), NULL, 0);
+
+ if (write_failure) {
+ ASSERT_TRUE(!read_failure);
+ data1_writes[1] = *write_failure;
+ } else {
+ ASSERT_TRUE(read_failure);
+ data1_reads[2] = *read_failure;
+ }
+
+ StaticSocketDataProvider data1(data1_reads, arraysize(data1_reads),
+ data1_writes, arraysize(data1_writes));
session_deps.socket_factory.AddSocketDataProvider(&data1);
MockRead data2_reads[] = {
@@ -1062,14 +1087,19 @@
}
}
+TEST_F(HttpNetworkTransactionTest, KeepAliveConnectionNotConnectedOnWrite) {
+ MockWrite write_failure(true, ERR_SOCKET_NOT_CONNECTED);
+ KeepAliveConnectionResendRequestTest(&write_failure, NULL);
+}
+
TEST_F(HttpNetworkTransactionTest, KeepAliveConnectionReset) {
MockRead read_failure(true, ERR_CONNECTION_RESET);
- KeepAliveConnectionResendRequestTest(read_failure);
+ KeepAliveConnectionResendRequestTest(NULL, &read_failure);
}
TEST_F(HttpNetworkTransactionTest, KeepAliveConnectionEOF) {
MockRead read_failure(false, OK); // EOF
- KeepAliveConnectionResendRequestTest(read_failure);
+ KeepAliveConnectionResendRequestTest(NULL, &read_failure);
}
TEST_F(HttpNetworkTransactionTest, NonKeepAliveConnectionReset) {
« 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