| 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 1727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 4367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |