summaryrefslogtreecommitdiffstats
path: root/net/spdy
diff options
context:
space:
mode:
authorerikchen@google.com <erikchen@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-03 18:07:13 +0000
committererikchen@google.com <erikchen@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-03 18:07:13 +0000
commitf9a26d7cbc4c853d2bf70a8cfe840a2d0bdf1807 (patch)
tree167a5408dce932ac1775b187147541ee7284e823 /net/spdy
parent4cdcfda8743b8012d3936c26ad78e3017f5cee96 (diff)
downloadchromium_src-f9a26d7cbc4c853d2bf70a8cfe840a2d0bdf1807.zip
chromium_src-f9a26d7cbc4c853d2bf70a8cfe840a2d0bdf1807.tar.gz
chromium_src-f9a26d7cbc4c853d2bf70a8cfe840a2d0bdf1807.tar.bz2
SPDY correctly handles socket writes of zero length.
TEST=net_unittests BUG=none Review URL: http://codereview.chromium.org/2806085 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54785 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/spdy')
-rw-r--r--net/spdy/spdy_network_transaction_unittest.cc39
-rw-r--r--net/spdy/spdy_session.cc1
2 files changed, 38 insertions, 2 deletions
diff --git a/net/spdy/spdy_network_transaction_unittest.cc b/net/spdy/spdy_network_transaction_unittest.cc
index ef1f03e..24ad8ad 100644
--- a/net/spdy/spdy_network_transaction_unittest.cc
+++ b/net/spdy/spdy_network_transaction_unittest.cc
@@ -933,7 +933,6 @@ TEST_P(SpdyNetworkTransactionTest, NullPost) {
EXPECT_EQ("hello!", out.response_data);
}
-
// Test that a simple POST works.
TEST_P(SpdyNetworkTransactionTest, EmptyPost) {
// Setup the request
@@ -1022,6 +1021,44 @@ TEST_P(SpdyNetworkTransactionTest, PostWithEarlySynReply) {
EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv);
}
+// The client upon cancellation tries to send a RST_STREAM frame. The mock
+// socket causes the TCP write to return zero. This test checks that the client
+// tries to queue up the RST_STREAM frame again.
+TEST_P(SpdyNetworkTransactionTest, SocketWriteReturnsZero) {
+ scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
+ scoped_ptr<spdy::SpdyFrame> rst(
+ ConstructSpdyRstStream(1, spdy::CANCEL));
+ MockWrite writes[] = {
+ CreateMockWrite(*req.get(), 1),
+ MockWrite(true, 0, 0, 3),
+ CreateMockWrite(*rst.get(), 4),
+ };
+
+ scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1));
+ MockRead reads[] = {
+ CreateMockRead(*resp.get(), 2),
+ MockRead(true, 0, 0, 5) // EOF
+ };
+
+ scoped_refptr<OrderedSocketData> data(
+ new OrderedSocketData(reads, arraysize(reads),
+ writes, arraysize(writes)));
+ NormalSpdyTransactionHelper helper(CreateGetRequest(),
+ BoundNetLog(), GetParam());
+ helper.AddData(data.get());
+ helper.RunPreTestSetup();
+ HttpNetworkTransaction* trans = helper.trans();
+
+ TestCompletionCallback callback;
+ int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog());
+ EXPECT_EQ(ERR_IO_PENDING, rv);
+ rv = callback.WaitForResult();
+ helper.ResetTrans();
+ MessageLoop::current()->RunAllPending();
+ data->CompleteRead();
+ helper.VerifyDataConsumed();
+}
+
// Test that the transaction doesn't crash when we don't have a reply.
TEST_P(SpdyNetworkTransactionTest, ResponseWithoutSynReply) {
scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true));
diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc
index 9776bce..46e2273 100644
--- a/net/spdy/spdy_session.cc
+++ b/net/spdy/spdy_session.cc
@@ -610,7 +610,6 @@ void SpdySession::OnReadComplete(int bytes_read) {
void SpdySession::OnWriteComplete(int result) {
DCHECK(write_pending_);
DCHECK(in_flight_write_.size());
- DCHECK_NE(result, 0); // This shouldn't happen for write.
write_pending_ = false;