Chromium Code Reviews| 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..f9d93baa74e99d1325822cedccab137aba3190a5 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,19 @@ 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, 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 +468,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 +1541,34 @@ TEST_P(SpdyNetworkTransactionTest, Post) { |
| EXPECT_EQ("hello!", out.response_data); |
| } |
| +// Test that a chunked POST works. |
| +TEST_P(SpdyNetworkTransactionTest, ChunkedPost) { |
|
willchan no longer on Chromium
2011/03/03 19:47:48
You should also have a test with multiple chunks.
|
| + scoped_ptr<spdy::SpdyFrame> req(ConstructChunkedSpdyPost(NULL, 0)); |
| + scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); |
| + MockWrite writes[] = { |
| + CreateMockWrite(*req), |
| + CreateMockWrite(*body), // POST upload frame |
| + }; |
| + |
| + scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0)); |
| + MockRead reads[] = { |
| + CreateMockRead(*resp), |
| + CreateMockRead(*body), |
| + 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!", out.response_data); |
| +} |
| + |
| // Test that a POST without any post data works. |
| TEST_P(SpdyNetworkTransactionTest, NullPost) { |
| // Setup the request |