OLD | NEW |
---|---|
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 1718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1729 // Http POST Content-Length is using UploadDataStream::size(). | 1729 // Http POST Content-Length is using UploadDataStream::size(). |
1730 // It is the same as request.upload_data->GetContentLengthSync(). | 1730 // It is the same as request.upload_data->GetContentLengthSync(). |
1731 scoped_ptr<UploadDataStream> stream( | 1731 scoped_ptr<UploadDataStream> stream( |
1732 new UploadDataStream(request.upload_data)); | 1732 new UploadDataStream(request.upload_data)); |
1733 ASSERT_EQ(OK, stream->Init()); | 1733 ASSERT_EQ(OK, stream->Init()); |
1734 ASSERT_EQ(request.upload_data->GetContentLengthSync(), | 1734 ASSERT_EQ(request.upload_data->GetContentLengthSync(), |
1735 stream->size()); | 1735 stream->size()); |
1736 scoped_ptr<SpdyFrame> stream_reply(ConstructSpdyPostSynReply(NULL, 0)); | 1736 scoped_ptr<SpdyFrame> stream_reply(ConstructSpdyPostSynReply(NULL, 0)); |
1737 scoped_ptr<SpdyFrame> stream_body(ConstructSpdyBodyFrame(1, true)); | 1737 scoped_ptr<SpdyFrame> stream_body(ConstructSpdyBodyFrame(1, true)); |
1738 MockRead reads[] = { | 1738 MockRead reads[] = { |
1739 CreateMockRead(*stream_reply, 2), | 1739 CreateMockRead(*stream_reply, 1), |
1740 CreateMockRead(*stream_body, 3), | 1740 MockRead(ASYNC, 0, 3) // EOF |
1741 MockRead(SYNCHRONOUS, 0, 0) // EOF | |
1742 }; | 1741 }; |
1743 | 1742 |
1744 scoped_ptr<DelayedSocketData> data( | 1743 scoped_ptr<SpdyFrame> req(ConstructSpdyPost(kUploadDataSize, NULL, 0)); |
1745 new DelayedSocketData(0, reads, arraysize(reads), NULL, 0)); | 1744 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); |
1746 NormalSpdyTransactionHelper helper(request, | 1745 MockRead writes[] = { |
1746 CreateMockWrite(*req, 0), | |
1747 CreateMockWrite(*body, 2), | |
1748 }; | |
1749 | |
1750 scoped_refptr<DeterministicSocketData> data( | |
1751 new DeterministicSocketData(reads, arraysize(reads), | |
1752 writes, arraysize(writes))); | |
1753 NormalSpdyTransactionHelper helper(CreatePostRequest(), | |
1747 BoundNetLog(), GetParam(), NULL); | 1754 BoundNetLog(), GetParam(), NULL); |
1755 helper.SetDeterministic(); | |
1748 helper.RunPreTestSetup(); | 1756 helper.RunPreTestSetup(); |
1749 helper.AddData(data.get()); | 1757 helper.AddDeterministicData(data.get()); |
1750 helper.RunDefaultTest(); | 1758 HttpNetworkTransaction* trans = helper.trans(); |
1751 helper.VerifyDataConsumed(); | |
1752 | 1759 |
1753 TransactionHelperResult out = helper.output(); | 1760 TestCompletionCallback callback; |
1754 EXPECT_EQ(ERR_SYN_REPLY_NOT_RECEIVED, out.rv); | 1761 int rv = trans->Start( |
1762 &CreatePostRequest(), callback.callback(), BoundNetLog()); | |
1763 EXPECT_EQ(ERR_IO_PENDING, rv); | |
1764 | |
1765 data->RunFor(2); | |
1766 rv = callback.WaitForResult(); | |
1767 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, rv); | |
1768 data->RunFor(1); | |
1755 } | 1769 } |
1756 | 1770 |
1757 // The client upon cancellation tries to send a RST_STREAM frame. The mock | 1771 // The client upon cancellation tries to send a RST_STREAM frame. The mock |
1758 // socket causes the TCP write to return zero. This test checks that the client | 1772 // socket causes the TCP write to return zero. This test checks that the client |
1759 // tries to queue up the RST_STREAM frame again. | 1773 // tries to queue up the RST_STREAM frame again. |
1760 TEST_P(SpdyNetworkTransactionSpdy2Test, SocketWriteReturnsZero) { | 1774 TEST_P(SpdyNetworkTransactionSpdy2Test, SocketWriteReturnsZero) { |
1761 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 1775 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
1762 scoped_ptr<SpdyFrame> rst( | 1776 scoped_ptr<SpdyFrame> rst( |
1763 ConstructSpdyRstStream(1, CANCEL)); | 1777 ConstructSpdyRstStream(1, CANCEL)); |
1764 MockWrite writes[] = { | 1778 MockWrite writes[] = { |
(...skipping 3793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5558 // Verify the SYN_REPLY. | 5572 // Verify the SYN_REPLY. |
5559 HttpResponseInfo response = *trans->GetResponseInfo(); | 5573 HttpResponseInfo response = *trans->GetResponseInfo(); |
5560 EXPECT_TRUE(response.headers != NULL); | 5574 EXPECT_TRUE(response.headers != NULL); |
5561 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5575 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
5562 } | 5576 } |
5563 | 5577 |
5564 TEST_P(SpdyNetworkTransactionSpdy2Test, OutOfOrderSynStream) { | 5578 TEST_P(SpdyNetworkTransactionSpdy2Test, OutOfOrderSynStream) { |
5565 // This first request will start to establish the SpdySession. | 5579 // This first request will start to establish the SpdySession. |
5566 // Then we will start the second (MEDIUM priority) and then third | 5580 // Then we will start the second (MEDIUM priority) and then third |
5567 // (HIGHEST priority) request in such a way that the third will actually | 5581 // (HIGHEST priority) request in such a way that the third will actually |
5568 // start before the second, causing the second to be re-numbered. | 5582 // start before the second, causing the second to be numbered differently |
5583 // than they order they were created. | |
ramant (doing other things)
2012/06/26 23:30:25
nit: consider "they order" -> "the order". Sorry f
Ryan Hamilton
2012/06/27 16:58:28
Done.
| |
5569 scoped_ptr<SpdyFrame> req1(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 5584 scoped_ptr<SpdyFrame> req1(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
5570 scoped_ptr<SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, MEDIUM)); | 5585 scoped_ptr<SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, HIGHEST)); |
5571 scoped_ptr<SpdyFrame> req3(ConstructSpdyGet(NULL, 0, false, 5, HIGHEST)); | 5586 scoped_ptr<SpdyFrame> req3(ConstructSpdyGet(NULL, 0, false, 5, MEDIUM)); |
5572 MockWrite writes[] = { | 5587 MockWrite writes[] = { |
5573 CreateMockWrite(*req1, 0), | 5588 CreateMockWrite(*req1, 0), |
5574 CreateMockWrite(*req2, 3), | 5589 CreateMockWrite(*req2, 3), |
5575 CreateMockWrite(*req3, 4), | 5590 CreateMockWrite(*req3, 4), |
5576 }; | 5591 }; |
5577 | 5592 |
5578 scoped_ptr<SpdyFrame> resp1(ConstructSpdyGetSynReply(NULL, 0, 1)); | 5593 scoped_ptr<SpdyFrame> resp1(ConstructSpdyGetSynReply(NULL, 0, 1)); |
5579 scoped_ptr<SpdyFrame> body1(ConstructSpdyBodyFrame(1, true)); | 5594 scoped_ptr<SpdyFrame> body1(ConstructSpdyBodyFrame(1, true)); |
5580 scoped_ptr<SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3)); | 5595 scoped_ptr<SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3)); |
5581 scoped_ptr<SpdyFrame> body2(ConstructSpdyBodyFrame(3, true)); | 5596 scoped_ptr<SpdyFrame> body2(ConstructSpdyBodyFrame(3, true)); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5641 // And now we can allow everything else to run to completion. | 5656 // And now we can allow everything else to run to completion. |
5642 data->SetStop(10); | 5657 data->SetStop(10); |
5643 data->Run(); | 5658 data->Run(); |
5644 EXPECT_EQ(OK, callback2.WaitForResult()); | 5659 EXPECT_EQ(OK, callback2.WaitForResult()); |
5645 EXPECT_EQ(OK, callback3.WaitForResult()); | 5660 EXPECT_EQ(OK, callback3.WaitForResult()); |
5646 | 5661 |
5647 helper.VerifyDataConsumed(); | 5662 helper.VerifyDataConsumed(); |
5648 } | 5663 } |
5649 | 5664 |
5650 } // namespace net | 5665 } // namespace net |
OLD | NEW |