summaryrefslogtreecommitdiffstats
path: root/net/spdy/spdy_network_transaction_unittest.cc
diff options
context:
space:
mode:
authormbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-05 22:25:43 +0000
committermbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-05 22:25:43 +0000
commita5566f970e60a97a9129af7a828d562e70176d87 (patch)
tree9e9dfe1cdfa8f0cedb8e05b6c9b6484e3273c5c0 /net/spdy/spdy_network_transaction_unittest.cc
parentf93be30de128f68037f8eef0dd644df809b6d325 (diff)
downloadchromium_src-a5566f970e60a97a9129af7a828d562e70176d87.zip
chromium_src-a5566f970e60a97a9129af7a828d562e70176d87.tar.gz
chromium_src-a5566f970e60a97a9129af7a828d562e70176d87.tar.bz2
Fix SPDY crash where we receive an early SYN_REPLY.
Added a test case which simulates this by doing a POST and scheduling the SYN_REPLY to arrive before we've finished sending. Also improved the error checking in SpdyStream a bit. BUG=43133 TEST=SpdyNetworkTransactionTest.PostWithEarlySynReply Review URL: http://codereview.chromium.org/1931003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46505 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/spdy/spdy_network_transaction_unittest.cc')
-rw-r--r--net/spdy/spdy_network_transaction_unittest.cc64
1 files changed, 49 insertions, 15 deletions
diff --git a/net/spdy/spdy_network_transaction_unittest.cc b/net/spdy/spdy_network_transaction_unittest.cc
index a025ce9..add273b 100644
--- a/net/spdy/spdy_network_transaction_unittest.cc
+++ b/net/spdy/spdy_network_transaction_unittest.cc
@@ -569,21 +569,21 @@ TEST_F(SpdyNetworkTransactionTest, Post) {
// Test that a simple POST works.
TEST_F(SpdyNetworkTransactionTest, EmptyPost) {
-static const unsigned char kEmptyPostSyn[] = {
- 0x80, 0x01, 0x00, 0x01, // header
- 0x01, 0x00, 0x00, 0x4a, // flags, len
- 0x00, 0x00, 0x00, 0x01, // stream id
- 0x00, 0x00, 0x00, 0x00, // associated
- 0xc0, 0x00, 0x00, 0x03, // 4 headers
- 0x00, 0x06, 'm', 'e', 't', 'h', 'o', 'd',
- 0x00, 0x04, 'P', 'O', 'S', 'T',
- 0x00, 0x03, 'u', 'r', 'l',
- 0x00, 0x16, 'h', 't', 't', 'p', ':', '/', '/', 'w', 'w', 'w',
- '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'c', 'o',
- 'm', '/',
- 0x00, 0x07, 'v', 'e', 'r', 's', 'i', 'o', 'n',
- 0x00, 0x08, 'H', 'T', 'T', 'P', '/', '1', '.', '1',
-};
+ static const unsigned char kEmptyPostSyn[] = {
+ 0x80, 0x01, 0x00, 0x01, // header
+ 0x01, 0x00, 0x00, 0x4a, // flags, len
+ 0x00, 0x00, 0x00, 0x01, // stream id
+ 0x00, 0x00, 0x00, 0x00, // associated
+ 0xc0, 0x00, 0x00, 0x03, // 4 headers
+ 0x00, 0x06, 'm', 'e', 't', 'h', 'o', 'd',
+ 0x00, 0x04, 'P', 'O', 'S', 'T',
+ 0x00, 0x03, 'u', 'r', 'l',
+ 0x00, 0x16, 'h', 't', 't', 'p', ':', '/', '/', 'w', 'w', 'w',
+ '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'c', 'o',
+ 'm', '/',
+ 0x00, 0x07, 'v', 'e', 'r', 's', 'i', 'o', 'n',
+ 0x00, 0x08, 'H', 'T', 'T', 'P', '/', '1', '.', '1',
+ };
// Setup the request
HttpRequestInfo request;
@@ -615,6 +615,40 @@ static const unsigned char kEmptyPostSyn[] = {
EXPECT_EQ("hello!", out.response_data);
}
+// While we're doing a post, the server sends back a SYN_REPLY.
+TEST_F(SpdyNetworkTransactionTest, PostWithEarlySynReply) {
+ static const char upload[] = { "hello world" };
+
+ // Setup the request
+ HttpRequestInfo request;
+ request.method = "POST";
+ request.url = GURL("http://www.google.com/");
+ request.upload_data = new UploadData();
+ request.upload_data->AppendBytes(upload, sizeof(upload));
+
+ MockWrite writes[] = {
+ MockWrite(true, reinterpret_cast<const char*>(kPostSyn),
+ arraysize(kPostSyn), 2),
+ MockWrite(true, reinterpret_cast<const char*>(kPostUploadFrame),
+ arraysize(kPostUploadFrame), 3),
+ };
+
+ MockRead reads[] = {
+ MockRead(true, reinterpret_cast<const char*>(kPostSynReply),
+ arraysize(kPostSynReply), 2),
+ MockRead(true, reinterpret_cast<const char*>(kPostBodyFrame),
+ arraysize(kPostBodyFrame), 3),
+ MockRead(false, 0, 0) // EOF
+ };
+
+ scoped_refptr<DelayedSocketData> data(
+ new DelayedSocketData(0, reads, arraysize(reads),
+ writes, arraysize(writes)));
+ TransactionHelperResult out = TransactionHelper(request, data.get(),
+ BoundNetLog());
+ EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv);
+}
+
// Test that the transaction doesn't crash when we don't have a reply.
TEST_F(SpdyNetworkTransactionTest, ResponseWithoutSynReply) {
MockRead reads[] = {