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

Unified Diff: net/http/http_pipelined_connection_impl_unittest.cc

Issue 8591037: Implement Drain() on HttpPipelinedStream. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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_pipelined_stream.cc » ('j') | net/http/http_pipelined_stream.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_pipelined_connection_impl_unittest.cc
diff --git a/net/http/http_pipelined_connection_impl_unittest.cc b/net/http/http_pipelined_connection_impl_unittest.cc
index a95549430ca21d0be72bf5b870b3e4f19871aa3b..059ddb3d3f4b0e411a2e269257ae02cda3409650 100644
--- a/net/http/http_pipelined_connection_impl_unittest.cc
+++ b/net/http/http_pipelined_connection_impl_unittest.cc
@@ -1086,6 +1086,70 @@ TEST_F(HttpPipelinedConnectionImplTest, CloseBeforeReadCallbackRuns) {
MessageLoop::current()->RunAllPending();
}
+TEST_F(HttpPipelinedConnectionImplTest, RecoverFromDrainOnRedirect) {
mmenke 2011/11/18 15:45:38 Could you add a content-length: 0 test, too, out o
James Simonsen 2011/11/22 01:24:20 Done. They all sounded good, so I added all of the
+ MockWrite writes[] = {
+ MockWrite(false, 0, "GET /redirect.html HTTP/1.1\r\n\r\n"),
+ MockWrite(false, 1, "GET /ok.html HTTP/1.1\r\n\r\n"),
+ };
+ MockRead reads[] = {
+ MockRead(false, 2,
+ "HTTP/1.1 302 OK\r\n"
+ "Content-Length: 8\r\n\r\n"
+ "redirect"),
+ MockRead(false, 3,
+ "HTTP/1.1 200 OK\r\n"
+ "Content-Length: 7\r\n\r\n"
+ "ok.html"),
+ };
+ Initialize(reads, arraysize(reads), writes, arraysize(writes));
+
+ scoped_ptr<HttpStream> stream1(NewTestStream("redirect.html"));
+ scoped_ptr<HttpStream> stream2(NewTestStream("ok.html"));
+
+ HttpRequestHeaders headers1;
+ HttpResponseInfo response1;
+ EXPECT_EQ(OK, stream1->SendRequest(headers1, NULL, &response1, &callback_));
+ HttpRequestHeaders headers2;
+ HttpResponseInfo response2;
+ EXPECT_EQ(OK, stream2->SendRequest(headers2, NULL, &response2, &callback_));
+
+ EXPECT_EQ(OK, stream1->ReadResponseHeaders(&callback_));
+ stream1.release()->Drain(NULL);
+
+ EXPECT_EQ(OK, stream2->ReadResponseHeaders(&callback_));
+ ExpectResponse("ok.html", stream2, false);
+ stream2->Close(false);
+}
+
+TEST_F(HttpPipelinedConnectionImplTest, EvictAfterDrainOfUnknownSize) {
+ MockWrite writes[] = {
+ MockWrite(false, 0, "GET /redirect.html HTTP/1.1\r\n\r\n"),
+ MockWrite(false, 1, "GET /ok.html HTTP/1.1\r\n\r\n"),
+ };
+ MockRead reads[] = {
+ MockRead(false, 2,
+ "HTTP/1.1 302 OK\r\n\r\n"
+ "redirect"),
+ };
+ Initialize(reads, arraysize(reads), writes, arraysize(writes));
+
+ scoped_ptr<HttpStream> stream1(NewTestStream("redirect.html"));
+ scoped_ptr<HttpStream> stream2(NewTestStream("ok.html"));
+
+ HttpRequestHeaders headers1;
+ HttpResponseInfo response1;
+ EXPECT_EQ(OK, stream1->SendRequest(headers1, NULL, &response1, &callback_));
+ HttpRequestHeaders headers2;
+ HttpResponseInfo response2;
+ EXPECT_EQ(OK, stream2->SendRequest(headers2, NULL, &response2, &callback_));
+
+ EXPECT_EQ(OK, stream1->ReadResponseHeaders(&callback_));
+ stream1.release()->Drain(NULL);
+
+ EXPECT_EQ(ERR_PIPELINE_EVICTION, stream2->ReadResponseHeaders(&callback_));
+ stream2->Close(false);
+}
+
TEST_F(HttpPipelinedConnectionImplTest, OnPipelineHasCapacity) {
MockWrite writes[] = {
MockWrite(false, 0, "GET /ok.html HTTP/1.1\r\n\r\n"),
« no previous file with comments | « no previous file | net/http/http_pipelined_stream.cc » ('j') | net/http/http_pipelined_stream.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698