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

Unified Diff: net/quic/quic_http_stream_test.cc

Issue 497553002: Add QUIC tests for chunked uploads where the FIN frame has no body data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Placate clang Created 6 years, 4 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_http_stream_test.cc
diff --git a/net/quic/quic_http_stream_test.cc b/net/quic/quic_http_stream_test.cc
index 932f566d4a525c7efbc299e83188c6fc7177028a..c99fa83d22ee160ad9c085a8f954ba0b270ccf65 100644
--- a/net/quic/quic_http_stream_test.cc
+++ b/net/quic/quic_http_stream_test.cc
@@ -49,7 +49,7 @@ namespace net {
namespace test {
namespace {
-const char kUploadData[] = "hello world!";
+const char kUploadData[] = "Really nifty data!";
mmenke 2014/08/21 20:52:35 Sending upload data of "hello world!" to get a res
Ryan Hamilton 2014/08/21 21:06:44 Good point.
const char kServerHostname[] = "www.google.com";
const uint16 kServerPort = 80;
@@ -526,6 +526,105 @@ TEST_P(QuicHttpStreamTest, SendChunkedPostRequest) {
EXPECT_TRUE(AtEof());
}
+TEST_P(QuicHttpStreamTest, SendChunkedPostRequestWithFinalEmptyDataPacket) {
+ SetRequest("POST", "/", DEFAULT_PRIORITY);
+ size_t chunk_size = strlen(kUploadData);
+ AddWrite(ConstructRequestHeadersPacket(1, !kFin));
+ AddWrite(ConstructDataPacket(2, kIncludeVersion, !kFin, 0, kUploadData));
+ AddWrite(ConstructDataPacket(3, kIncludeVersion, kFin, chunk_size, ""));
+ AddWrite(ConstructAckPacket(4, 3, 1));
+ Initialize();
+
+ UploadDataStream upload_data_stream(UploadDataStream::CHUNKED, 0);
+ upload_data_stream.AppendChunk(kUploadData, chunk_size, false);
+
+ request_.method = "POST";
+ request_.url = GURL("http://www.google.com/");
+ request_.upload_data_stream = &upload_data_stream;
+ ASSERT_EQ(OK, request_.upload_data_stream->Init(CompletionCallback()));
+
+ ASSERT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY,
+ net_log_, callback_.callback()));
+ ASSERT_EQ(ERR_IO_PENDING, stream_->SendRequest(headers_, &response_,
+ callback_.callback()));
+
+ upload_data_stream.AppendChunk(NULL, 0, true);
+
+ // Ack all packets in the request.
+ ProcessPacket(ConstructAckPacket(1, 0, 0));
+
+ // Send the response headers (but not the body).
+ SetResponse("200 OK", std::string());
+ ProcessPacket(ConstructResponseHeadersPacket(2, !kFin));
+
+ // Since the headers have already arrived, this should return immediately.
+ ASSERT_EQ(OK, stream_->ReadResponseHeaders(callback_.callback()));
+ ASSERT_TRUE(response_.headers.get());
+ EXPECT_EQ(200, response_.headers->response_code());
+ EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain"));
+
+ // Send the response body.
+ const char kResponseBody[] = "Hello world!";
+ ProcessPacket(ConstructDataPacket(3, false, kFin, response_data_.length(),
+ kResponseBody));
+
+ // Since the body has already arrived, this should return immediately.
+ ASSERT_EQ(static_cast<int>(strlen(kResponseBody)),
+ stream_->ReadResponseBody(read_buffer_.get(), read_buffer_->size(),
+ callback_.callback()));
+
+ EXPECT_TRUE(stream_->IsResponseBodyComplete());
+ EXPECT_TRUE(AtEof());
+}
+
+TEST_P(QuicHttpStreamTest, SendChunkedPostRequestWithOneEmptyDataPacket) {
+ SetRequest("POST", "/", DEFAULT_PRIORITY);
+ AddWrite(ConstructRequestHeadersPacket(1, !kFin));
+ AddWrite(ConstructDataPacket(2, kIncludeVersion, kFin, 0, ""));
+ AddWrite(ConstructAckPacket(3, 3, 1));
+ Initialize();
+
+ UploadDataStream upload_data_stream(UploadDataStream::CHUNKED, 0);
+
+ request_.method = "POST";
+ request_.url = GURL("http://www.google.com/");
+ request_.upload_data_stream = &upload_data_stream;
+ ASSERT_EQ(OK, request_.upload_data_stream->Init(CompletionCallback()));
+
+ ASSERT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY,
+ net_log_, callback_.callback()));
+ ASSERT_EQ(ERR_IO_PENDING, stream_->SendRequest(headers_, &response_,
+ callback_.callback()));
+
+ upload_data_stream.AppendChunk(NULL, 0, true);
+
+ // Ack both packets in the request.
+ ProcessPacket(ConstructAckPacket(1, 0, 0));
mmenke 2014/08/21 20:52:36 I really can't make sense of ConstructAckPacket's
Ryan Hamilton 2014/08/21 21:06:44 The second argument should be the sequence number
mmenke 2014/08/21 21:20:47 I tried that, but it results in a GMOCK warning, a
+
+ // Send the response headers (but not the body).
+ SetResponse("200 OK", std::string());
+ ProcessPacket(ConstructResponseHeadersPacket(2, !kFin));
+
+ // Since the headers have already arrived, this should return immediately.
+ ASSERT_EQ(OK, stream_->ReadResponseHeaders(callback_.callback()));
+ ASSERT_TRUE(response_.headers.get());
+ EXPECT_EQ(200, response_.headers->response_code());
+ EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain"));
+
+ // Send the response body.
+ const char kResponseBody[] = "Hello world!";
+ ProcessPacket(ConstructDataPacket(3, false, kFin, response_data_.length(),
+ kResponseBody));
+
+ // Since the body has already arrived, this should return immediately.
+ ASSERT_EQ(static_cast<int>(strlen(kResponseBody)),
+ stream_->ReadResponseBody(read_buffer_.get(), read_buffer_->size(),
+ callback_.callback()));
+
+ EXPECT_TRUE(stream_->IsResponseBodyComplete());
+ EXPECT_TRUE(AtEof());
+}
+
TEST_P(QuicHttpStreamTest, DestroyedEarly) {
SetRequest("GET", "/", DEFAULT_PRIORITY);
AddWrite(ConstructRequestHeadersPacket(1, kFin));
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698