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

Side by Side Diff: net/spdy/spdy_network_transaction_spdy3_unittest.cc

Issue 10448083: Fix out of order SYN_STEAM frames. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix willchan's comments Created 8 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/http/http_network_transaction.h" 5 #include "net/http/http_network_transaction.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 1727 matching lines...) Expand 10 before | Expand all | Expand 10 after
1738 // Http POST Content-Length is using UploadDataStream::size(). 1738 // Http POST Content-Length is using UploadDataStream::size().
1739 // It is the same as request.upload_data->GetContentLengthSync(). 1739 // It is the same as request.upload_data->GetContentLengthSync().
1740 scoped_ptr<UploadDataStream> stream( 1740 scoped_ptr<UploadDataStream> stream(
1741 new UploadDataStream(request.upload_data)); 1741 new UploadDataStream(request.upload_data));
1742 ASSERT_EQ(OK, stream->Init()); 1742 ASSERT_EQ(OK, stream->Init());
1743 ASSERT_EQ(request.upload_data->GetContentLengthSync(), 1743 ASSERT_EQ(request.upload_data->GetContentLengthSync(),
1744 stream->size()); 1744 stream->size());
1745 scoped_ptr<SpdyFrame> stream_reply(ConstructSpdyPostSynReply(NULL, 0)); 1745 scoped_ptr<SpdyFrame> stream_reply(ConstructSpdyPostSynReply(NULL, 0));
1746 scoped_ptr<SpdyFrame> stream_body(ConstructSpdyBodyFrame(1, true)); 1746 scoped_ptr<SpdyFrame> stream_body(ConstructSpdyBodyFrame(1, true));
1747 MockRead reads[] = { 1747 MockRead reads[] = {
1748 CreateMockRead(*stream_reply, 2), 1748 CreateMockRead(*stream_reply, 1),
1749 CreateMockRead(*stream_body, 3), 1749 MockRead(ASYNC, 0, 3) // EOF
1750 MockRead(SYNCHRONOUS, 0, 0) // EOF
1751 }; 1750 };
1752 1751
1753 scoped_ptr<DelayedSocketData> data( 1752 scoped_ptr<SpdyFrame> req(ConstructSpdyPost(kUploadDataSize, NULL, 0));
1754 new DelayedSocketData(0, reads, arraysize(reads), NULL, 0)); 1753 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true));
1755 NormalSpdyTransactionHelper helper(request, 1754 MockRead writes[] = {
1755 CreateMockWrite(*req, 0),
1756 CreateMockWrite(*body, 2),
1757 };
1758
1759 scoped_refptr<DeterministicSocketData> data(
1760 new DeterministicSocketData(reads, arraysize(reads),
1761 writes, arraysize(writes)));
1762 NormalSpdyTransactionHelper helper(CreatePostRequest(),
1756 BoundNetLog(), GetParam(), NULL); 1763 BoundNetLog(), GetParam(), NULL);
1764 helper.SetDeterministic();
1757 helper.RunPreTestSetup(); 1765 helper.RunPreTestSetup();
1758 helper.AddData(data.get()); 1766 helper.AddDeterministicData(data.get());
1759 helper.RunDefaultTest(); 1767 HttpNetworkTransaction* trans = helper.trans();
1760 helper.VerifyDataConsumed();
1761 1768
1762 TransactionHelperResult out = helper.output(); 1769 TestCompletionCallback callback;
1763 EXPECT_EQ(ERR_SYN_REPLY_NOT_RECEIVED, out.rv); 1770 int rv = trans->Start(
1771 &CreatePostRequest(), callback.callback(), BoundNetLog());
1772 EXPECT_EQ(ERR_IO_PENDING, rv);
1773
1774 data->RunFor(2);
1775 rv = callback.WaitForResult();
1776 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, rv);
1777 data->RunFor(1);
1764 } 1778 }
1765 1779
1766 // The client upon cancellation tries to send a RST_STREAM frame. The mock 1780 // The client upon cancellation tries to send a RST_STREAM frame. The mock
1767 // socket causes the TCP write to return zero. This test checks that the client 1781 // socket causes the TCP write to return zero. This test checks that the client
1768 // tries to queue up the RST_STREAM frame again. 1782 // tries to queue up the RST_STREAM frame again.
1769 TEST_P(SpdyNetworkTransactionSpdy3Test, SocketWriteReturnsZero) { 1783 TEST_P(SpdyNetworkTransactionSpdy3Test, SocketWriteReturnsZero) {
1770 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 1784 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
1771 scoped_ptr<SpdyFrame> rst( 1785 scoped_ptr<SpdyFrame> rst(
1772 ConstructSpdyRstStream(1, CANCEL)); 1786 ConstructSpdyRstStream(1, CANCEL));
1773 MockWrite writes[] = { 1787 MockWrite writes[] = {
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
2056 kMaxSpdyFrameChunkSize * kFrameCount, NULL, 0)); 2070 kMaxSpdyFrameChunkSize * kFrameCount, NULL, 0));
2057 scoped_ptr<SpdyFrame> body( 2071 scoped_ptr<SpdyFrame> body(
2058 ConstructSpdyBodyFrame(1, content->c_str(), content->size(), false)); 2072 ConstructSpdyBodyFrame(1, content->c_str(), content->size(), false));
2059 scoped_ptr<SpdyFrame> rst( 2073 scoped_ptr<SpdyFrame> rst(
2060 ConstructSpdyRstStream(1, FLOW_CONTROL_ERROR)); 2074 ConstructSpdyRstStream(1, FLOW_CONTROL_ERROR));
2061 2075
2062 // We're not going to write a data frame with FIN, we'll receive a bad 2076 // We're not going to write a data frame with FIN, we'll receive a bad
2063 // WINDOW_UPDATE while sending a request and will send a RST_STREAM frame. 2077 // WINDOW_UPDATE while sending a request and will send a RST_STREAM frame.
2064 MockWrite writes[] = { 2078 MockWrite writes[] = {
2065 CreateMockWrite(*req), 2079 CreateMockWrite(*req),
2066 CreateMockWrite(*body), 2080 //CreateMockWrite(*body),
2067 CreateMockWrite(*rst), 2081 CreateMockWrite(*rst),
2068 }; 2082 };
2069 2083
2070 static const int32 kDeltaWindowSize = 0x7fffffff; // cause an overflow 2084 static const int32 kDeltaWindowSize = 0x7fffffff; // cause an overflow
2071 scoped_ptr<SpdyFrame> window_update( 2085 scoped_ptr<SpdyFrame> window_update(
2072 ConstructSpdyWindowUpdate(1, kDeltaWindowSize)); 2086 ConstructSpdyWindowUpdate(1, kDeltaWindowSize));
2073 scoped_ptr<SpdyFrame> window_update2( 2087 scoped_ptr<SpdyFrame> window_update2(
2074 ConstructSpdyWindowUpdate(2, kDeltaWindowSize)); 2088 ConstructSpdyWindowUpdate(2, kDeltaWindowSize));
2075 scoped_ptr<SpdyFrame> reply(ConstructSpdyPostSynReply(NULL, 0)); 2089 scoped_ptr<SpdyFrame> reply(ConstructSpdyPostSynReply(NULL, 0));
2076 2090
(...skipping 4064 matching lines...) Expand 10 before | Expand all | Expand 10 after
6141 // Verify the SYN_REPLY. 6155 // Verify the SYN_REPLY.
6142 HttpResponseInfo response = *trans->GetResponseInfo(); 6156 HttpResponseInfo response = *trans->GetResponseInfo();
6143 EXPECT_TRUE(response.headers != NULL); 6157 EXPECT_TRUE(response.headers != NULL);
6144 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 6158 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
6145 } 6159 }
6146 6160
6147 TEST_P(SpdyNetworkTransactionSpdy3Test, OutOfOrderSynStream) { 6161 TEST_P(SpdyNetworkTransactionSpdy3Test, OutOfOrderSynStream) {
6148 // This first request will start to establish the SpdySession. 6162 // This first request will start to establish the SpdySession.
6149 // Then we will start the second (MEDIUM priority) and then third 6163 // Then we will start the second (MEDIUM priority) and then third
6150 // (HIGHEST priority) request in such a way that the third will actually 6164 // (HIGHEST priority) request in such a way that the third will actually
6151 // start before the second, causing the second to be re-numbered. 6165 // start before the second, causing the second to be numbered differently
6166 // than they order they were created.
6152 scoped_ptr<SpdyFrame> req1(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 6167 scoped_ptr<SpdyFrame> req1(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
6153 scoped_ptr<SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, MEDIUM)); 6168 scoped_ptr<SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, HIGHEST));
6154 scoped_ptr<SpdyFrame> req3(ConstructSpdyGet(NULL, 0, false, 5, HIGHEST)); 6169 scoped_ptr<SpdyFrame> req3(ConstructSpdyGet(NULL, 0, false, 5, MEDIUM));
6155 MockWrite writes[] = { 6170 MockWrite writes[] = {
6156 CreateMockWrite(*req1, 0), 6171 CreateMockWrite(*req1, 0),
6157 CreateMockWrite(*req2, 3), 6172 CreateMockWrite(*req2, 3),
6158 CreateMockWrite(*req3, 4), 6173 CreateMockWrite(*req3, 4),
6159 }; 6174 };
6160 6175
6161 scoped_ptr<SpdyFrame> resp1(ConstructSpdyGetSynReply(NULL, 0, 1)); 6176 scoped_ptr<SpdyFrame> resp1(ConstructSpdyGetSynReply(NULL, 0, 1));
6162 scoped_ptr<SpdyFrame> body1(ConstructSpdyBodyFrame(1, true)); 6177 scoped_ptr<SpdyFrame> body1(ConstructSpdyBodyFrame(1, true));
6163 scoped_ptr<SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3)); 6178 scoped_ptr<SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3));
6164 scoped_ptr<SpdyFrame> body2(ConstructSpdyBodyFrame(3, true)); 6179 scoped_ptr<SpdyFrame> body2(ConstructSpdyBodyFrame(3, true));
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
6224 // And now we can allow everything else to run to completion. 6239 // And now we can allow everything else to run to completion.
6225 data->SetStop(10); 6240 data->SetStop(10);
6226 data->Run(); 6241 data->Run();
6227 EXPECT_EQ(OK, callback2.WaitForResult()); 6242 EXPECT_EQ(OK, callback2.WaitForResult());
6228 EXPECT_EQ(OK, callback3.WaitForResult()); 6243 EXPECT_EQ(OK, callback3.WaitForResult());
6229 6244
6230 helper.VerifyDataConsumed(); 6245 helper.VerifyDataConsumed();
6231 } 6246 }
6232 6247
6233 } // namespace net 6248 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698