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

Unified Diff: net/spdy/spdy_network_transaction_unittest.cc

Issue 6292013: Add chunked uploads support to SPDY (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 10 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/spdy/spdy_http_utils.cc ('k') | net/spdy/spdy_proxy_client_socket.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/spdy_network_transaction_unittest.cc
diff --git a/net/spdy/spdy_network_transaction_unittest.cc b/net/spdy/spdy_network_transaction_unittest.cc
index 84e19d642b79b23d7c31a7bf391421377e323ef5..94ef61d718c00f2f29126e28bd56002ca6042f35 100644
--- a/net/spdy/spdy_network_transaction_unittest.cc
+++ b/net/spdy/spdy_network_transaction_unittest.cc
@@ -40,6 +40,7 @@ class SpdyNetworkTransactionTest
EnableCompression(false);
google_get_request_initialized_ = false;
google_post_request_initialized_ = false;
+ google_chunked_post_request_initialized_ = false;
}
virtual void TearDown() {
@@ -350,6 +351,21 @@ class SpdyNetworkTransactionTest
return google_post_request_;
}
+ const HttpRequestInfo& CreateChunkedPostRequest() {
+ if (!google_chunked_post_request_initialized_) {
+ google_chunked_post_request_.method = "POST";
+ google_chunked_post_request_.url = GURL(kDefaultURL);
+ google_chunked_post_request_.upload_data = new UploadData();
+ google_chunked_post_request_.upload_data->set_is_chunked(true);
+ google_chunked_post_request_.upload_data->AppendChunk(
+ kUploadData, kUploadDataSize, false);
+ google_chunked_post_request_.upload_data->AppendChunk(
+ kUploadData, kUploadDataSize, true);
+ google_chunked_post_request_initialized_ = true;
+ }
+ return google_chunked_post_request_;
+ }
+
// Read the result of a particular transaction, knowing that we've got
// multiple transactions in the read pipeline; so as we read, we may have
// to skip over data destined for other transactions while we consume
@@ -454,8 +470,10 @@ class SpdyNetworkTransactionTest
private:
bool google_get_request_initialized_;
bool google_post_request_initialized_;
+ bool google_chunked_post_request_initialized_;
HttpRequestInfo google_get_request_;
HttpRequestInfo google_post_request_;
+ HttpRequestInfo google_chunked_post_request_;
HttpRequestInfo google_get_push_request_;
};
@@ -1525,6 +1543,38 @@ TEST_P(SpdyNetworkTransactionTest, Post) {
EXPECT_EQ("hello!", out.response_data);
}
+// Test that a chunked POST works.
+TEST_P(SpdyNetworkTransactionTest, ChunkedPost) {
+ UploadDataStream::set_merge_chunks(false);
+ scoped_ptr<spdy::SpdyFrame> req(ConstructChunkedSpdyPost(NULL, 0));
+ scoped_ptr<spdy::SpdyFrame> chunk1(ConstructSpdyBodyFrame(1, false));
+ scoped_ptr<spdy::SpdyFrame> chunk2(ConstructSpdyBodyFrame(1, true));
+ MockWrite writes[] = {
+ CreateMockWrite(*req),
+ CreateMockWrite(*chunk1),
+ CreateMockWrite(*chunk2),
+ };
+
+ scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0));
+ MockRead reads[] = {
+ CreateMockRead(*resp),
+ CreateMockRead(*chunk1),
+ CreateMockRead(*chunk2),
+ MockRead(true, 0, 0) // EOF
+ };
+
+ scoped_refptr<DelayedSocketData> data(
+ new DelayedSocketData(2, reads, arraysize(reads),
+ writes, arraysize(writes)));
+ NormalSpdyTransactionHelper helper(CreateChunkedPostRequest(),
+ BoundNetLog(), GetParam());
+ helper.RunToCompletion(data.get());
+ TransactionHelperResult out = helper.output();
+ EXPECT_EQ(OK, out.rv);
+ EXPECT_EQ("HTTP/1.1 200 OK", out.status_line);
+ EXPECT_EQ("hello!hello!", out.response_data);
+}
+
// Test that a POST without any post data works.
TEST_P(SpdyNetworkTransactionTest, NullPost) {
// Setup the request
« no previous file with comments | « net/spdy/spdy_http_utils.cc ('k') | net/spdy/spdy_proxy_client_socket.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698