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

Unified Diff: net/spdy/spdy_network_transaction_unittest.cc

Issue 129543002: Enable SpdyStream's HALF_CLOSED_REMOTE state. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add add'l weak_this guard around delegate calls (2nd try). Created 6 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_stream.cc ('k') | net/spdy/spdy_stream.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 1c9abed27485dacb384dd685e6879e233275e134..38fe7ed113c3b3478cd975a1d1a04a147597e33f 100644
--- a/net/spdy/spdy_network_transaction_unittest.cc
+++ b/net/spdy/spdy_network_transaction_unittest.cc
@@ -2059,57 +2059,50 @@ TEST_P(SpdyNetworkTransactionTest, EmptyPost) {
EXPECT_EQ("hello!", out.response_data);
}
-// While we're doing a post, the server sends back a SYN_REPLY.
-TEST_P(SpdyNetworkTransactionTest, PostWithEarlySynReply) {
- static const char upload[] = { "hello!" };
- ScopedVector<UploadElementReader> element_readers;
- element_readers.push_back(
- new UploadBytesElementReader(upload, sizeof(upload)));
- UploadDataStream stream(element_readers.Pass(), 0);
-
- // Setup the request
- HttpRequestInfo request;
- request.method = "POST";
- request.url = GURL(kRequestUrl);
- request.upload_data_stream = &stream;
-
- scoped_ptr<SpdyFrame> stream_reply(
- spdy_util_.ConstructSpdyPostSynReply(NULL, 0));
- MockRead reads[] = {
- CreateMockRead(*stream_reply, 1),
- MockRead(ASYNC, 0, 4) // EOF
- };
-
- scoped_ptr<SpdyFrame> req(
- spdy_util_.ConstructSpdyPost(
- kRequestUrl, 1, kUploadDataSize, LOWEST, NULL, 0));
+// While we're doing a post, the server sends the reply before upload completes.
+TEST_P(SpdyNetworkTransactionTest, ResponseBeforePostCompletes) {
+ scoped_ptr<SpdyFrame> req(spdy_util_.ConstructChunkedSpdyPost(NULL, 0));
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
- scoped_ptr<SpdyFrame> rst(
- spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR));
MockWrite writes[] = {
CreateMockWrite(*req, 0),
- CreateMockWrite(*body, 2),
- CreateMockWrite(*rst, 3)
+ CreateMockWrite(*body, 3),
+ };
+ scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0));
+ MockRead reads[] = {
+ CreateMockRead(*resp, 1),
+ CreateMockRead(*body, 2),
+ MockRead(ASYNC, 0, 4) // EOF
};
+ // Write the request headers, and read the complete response
+ // while still waiting for chunked request data.
DeterministicSocketData data(reads, arraysize(reads),
writes, arraysize(writes));
- NormalSpdyTransactionHelper helper(CreatePostRequest(), DEFAULT_PRIORITY,
+ NormalSpdyTransactionHelper helper(CreateChunkedPostRequest(),
+ DEFAULT_PRIORITY,
BoundNetLog(), GetParam(), NULL);
helper.SetDeterministic();
helper.RunPreTestSetup();
helper.AddDeterministicData(&data);
- HttpNetworkTransaction* trans = helper.trans();
- TestCompletionCallback callback;
- int rv = trans->Start(
- &CreatePostRequest(), callback.callback(), BoundNetLog());
- EXPECT_EQ(ERR_IO_PENDING, rv);
+ ASSERT_TRUE(helper.StartDefaultTest());
- data.RunFor(4);
- rv = callback.WaitForResult();
- EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, rv);
- data.RunFor(1);
+ // Process the request headers, SYN_REPLY, and response body.
+ // The request body is still in flight.
+ data.RunFor(3);
+
+ const HttpResponseInfo* response = helper.trans()->GetResponseInfo();
+ EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
+
+ // Finish sending the request body.
+ helper.request().upload_data_stream->AppendChunk(
+ kUploadData, kUploadDataSize, true);
+ data.RunFor(2);
+
+ std::string response_body;
+ EXPECT_EQ(OK, ReadTransaction(helper.trans(), &response_body));
+ EXPECT_EQ(kUploadData, response_body);
+ helper.VerifyDataConsumed();
}
// The client upon cancellation tries to send a RST_STREAM frame. The mock
« no previous file with comments | « net/spdy/spdy_http_stream.cc ('k') | net/spdy/spdy_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698