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 <cmath> | 5 #include <cmath> |
6 #include <memory> | 6 #include <memory> |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 1805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1816 expected_response += kUploadData; | 1816 expected_response += kUploadData; |
1817 | 1817 |
1818 TransactionHelperResult out = helper.output(); | 1818 TransactionHelperResult out = helper.output(); |
1819 EXPECT_THAT(out.rv, IsOk()); | 1819 EXPECT_THAT(out.rv, IsOk()); |
1820 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 1820 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
1821 EXPECT_EQ(expected_response, out.response_data); | 1821 EXPECT_EQ(expected_response, out.response_data); |
1822 } | 1822 } |
1823 | 1823 |
1824 // Test that a POST without any post data works. | 1824 // Test that a POST without any post data works. |
1825 TEST_P(SpdyNetworkTransactionTest, NullPost) { | 1825 TEST_P(SpdyNetworkTransactionTest, NullPost) { |
1826 BufferedSpdyFramer framer(HTTP2); | 1826 BufferedSpdyFramer framer; |
1827 // Setup the request | 1827 // Setup the request |
1828 HttpRequestInfo request; | 1828 HttpRequestInfo request; |
1829 request.method = "POST"; | 1829 request.method = "POST"; |
1830 request.url = default_url_; | 1830 request.url = default_url_; |
1831 // Create an empty UploadData. | 1831 // Create an empty UploadData. |
1832 request.upload_data_stream = NULL; | 1832 request.upload_data_stream = NULL; |
1833 | 1833 |
1834 // When request.upload_data_stream is NULL for post, content-length is | 1834 // When request.upload_data_stream is NULL for post, content-length is |
1835 // expected to be 0. | 1835 // expected to be 0. |
1836 SpdyHeaderBlock req_block( | 1836 SpdyHeaderBlock req_block( |
(...skipping 21 matching lines...) Expand all Loading... |
1858 BoundNetLog(), GetParam(), NULL); | 1858 BoundNetLog(), GetParam(), NULL); |
1859 helper.RunToCompletion(&data); | 1859 helper.RunToCompletion(&data); |
1860 TransactionHelperResult out = helper.output(); | 1860 TransactionHelperResult out = helper.output(); |
1861 EXPECT_THAT(out.rv, IsOk()); | 1861 EXPECT_THAT(out.rv, IsOk()); |
1862 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 1862 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
1863 EXPECT_EQ("hello!", out.response_data); | 1863 EXPECT_EQ("hello!", out.response_data); |
1864 } | 1864 } |
1865 | 1865 |
1866 // Test that a simple POST works. | 1866 // Test that a simple POST works. |
1867 TEST_P(SpdyNetworkTransactionTest, EmptyPost) { | 1867 TEST_P(SpdyNetworkTransactionTest, EmptyPost) { |
1868 BufferedSpdyFramer framer(HTTP2); | 1868 BufferedSpdyFramer framer; |
1869 // Create an empty UploadDataStream. | 1869 // Create an empty UploadDataStream. |
1870 std::vector<std::unique_ptr<UploadElementReader>> element_readers; | 1870 std::vector<std::unique_ptr<UploadElementReader>> element_readers; |
1871 ElementsUploadDataStream stream(std::move(element_readers), 0); | 1871 ElementsUploadDataStream stream(std::move(element_readers), 0); |
1872 | 1872 |
1873 // Setup the request | 1873 // Setup the request |
1874 HttpRequestInfo request; | 1874 HttpRequestInfo request; |
1875 request.method = "POST"; | 1875 request.method = "POST"; |
1876 request.url = default_url_; | 1876 request.url = default_url_; |
1877 request.upload_data_stream = &stream; | 1877 request.upload_data_stream = &stream; |
1878 | 1878 |
(...skipping 1706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3585 EXPECT_NE(header_list->end(), header_list->Find(header)) << | 3585 EXPECT_NE(header_list->end(), header_list->Find(header)) << |
3586 "Header not found: " << *it; | 3586 "Header not found: " << *it; |
3587 } | 3587 } |
3588 } | 3588 } |
3589 | 3589 |
3590 // Since we buffer the IO from the stream to the renderer, this test verifies | 3590 // Since we buffer the IO from the stream to the renderer, this test verifies |
3591 // that when we read out the maximum amount of data (e.g. we received 50 bytes | 3591 // that when we read out the maximum amount of data (e.g. we received 50 bytes |
3592 // on the network, but issued a Read for only 5 of those bytes) that the data | 3592 // on the network, but issued a Read for only 5 of those bytes) that the data |
3593 // flow still works correctly. | 3593 // flow still works correctly. |
3594 TEST_P(SpdyNetworkTransactionTest, BufferFull) { | 3594 TEST_P(SpdyNetworkTransactionTest, BufferFull) { |
3595 BufferedSpdyFramer framer(HTTP2); | 3595 BufferedSpdyFramer framer; |
3596 | 3596 |
3597 std::unique_ptr<SpdySerializedFrame> req( | 3597 std::unique_ptr<SpdySerializedFrame> req( |
3598 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 3598 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
3599 MockWrite writes[] = {CreateMockWrite(*req, 0)}; | 3599 MockWrite writes[] = {CreateMockWrite(*req, 0)}; |
3600 | 3600 |
3601 // 2 data frames in a single read. | 3601 // 2 data frames in a single read. |
3602 std::unique_ptr<SpdySerializedFrame> data_frame_1( | 3602 std::unique_ptr<SpdySerializedFrame> data_frame_1( |
3603 framer.CreateDataFrame(1, "goodby", 6, DATA_FLAG_NONE)); | 3603 framer.CreateDataFrame(1, "goodby", 6, DATA_FLAG_NONE)); |
3604 std::unique_ptr<SpdySerializedFrame> data_frame_2( | 3604 std::unique_ptr<SpdySerializedFrame> data_frame_2( |
3605 framer.CreateDataFrame(1, "e worl", 6, DATA_FLAG_NONE)); | 3605 framer.CreateDataFrame(1, "e worl", 6, DATA_FLAG_NONE)); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3678 | 3678 |
3679 EXPECT_THAT(out.rv, IsOk()); | 3679 EXPECT_THAT(out.rv, IsOk()); |
3680 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 3680 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
3681 EXPECT_EQ("goodbye world", out.response_data); | 3681 EXPECT_EQ("goodbye world", out.response_data); |
3682 } | 3682 } |
3683 | 3683 |
3684 // Verify that basic buffering works; when multiple data frames arrive | 3684 // Verify that basic buffering works; when multiple data frames arrive |
3685 // at the same time, ensure that we don't notify a read completion for | 3685 // at the same time, ensure that we don't notify a read completion for |
3686 // each data frame individually. | 3686 // each data frame individually. |
3687 TEST_P(SpdyNetworkTransactionTest, Buffering) { | 3687 TEST_P(SpdyNetworkTransactionTest, Buffering) { |
3688 BufferedSpdyFramer framer(HTTP2); | 3688 BufferedSpdyFramer framer; |
3689 | 3689 |
3690 std::unique_ptr<SpdySerializedFrame> req( | 3690 std::unique_ptr<SpdySerializedFrame> req( |
3691 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 3691 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
3692 MockWrite writes[] = {CreateMockWrite(*req, 0)}; | 3692 MockWrite writes[] = {CreateMockWrite(*req, 0)}; |
3693 | 3693 |
3694 // 4 data frames in a single read. | 3694 // 4 data frames in a single read. |
3695 std::unique_ptr<SpdySerializedFrame> data_frame( | 3695 std::unique_ptr<SpdySerializedFrame> data_frame( |
3696 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); | 3696 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); |
3697 std::unique_ptr<SpdySerializedFrame> data_frame_fin( | 3697 std::unique_ptr<SpdySerializedFrame> data_frame_fin( |
3698 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_FIN)); | 3698 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_FIN)); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3770 // Verify that we consumed all test data. | 3770 // Verify that we consumed all test data. |
3771 helper.VerifyDataConsumed(); | 3771 helper.VerifyDataConsumed(); |
3772 | 3772 |
3773 EXPECT_THAT(out.rv, IsOk()); | 3773 EXPECT_THAT(out.rv, IsOk()); |
3774 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 3774 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
3775 EXPECT_EQ("messagemessagemessagemessage", out.response_data); | 3775 EXPECT_EQ("messagemessagemessagemessage", out.response_data); |
3776 } | 3776 } |
3777 | 3777 |
3778 // Verify the case where we buffer data but read it after it has been buffered. | 3778 // Verify the case where we buffer data but read it after it has been buffered. |
3779 TEST_P(SpdyNetworkTransactionTest, BufferedAll) { | 3779 TEST_P(SpdyNetworkTransactionTest, BufferedAll) { |
3780 BufferedSpdyFramer framer(HTTP2); | 3780 BufferedSpdyFramer framer; |
3781 | 3781 |
3782 std::unique_ptr<SpdySerializedFrame> req( | 3782 std::unique_ptr<SpdySerializedFrame> req( |
3783 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 3783 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
3784 MockWrite writes[] = {CreateMockWrite(*req, 0)}; | 3784 MockWrite writes[] = {CreateMockWrite(*req, 0)}; |
3785 | 3785 |
3786 // 5 data frames in a single read. | 3786 // 5 data frames in a single read. |
3787 std::unique_ptr<SpdySerializedFrame> reply( | 3787 std::unique_ptr<SpdySerializedFrame> reply( |
3788 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 3788 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
3789 std::unique_ptr<SpdySerializedFrame> data_frame( | 3789 std::unique_ptr<SpdySerializedFrame> data_frame( |
3790 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); | 3790 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3856 // Verify that we consumed all test data. | 3856 // Verify that we consumed all test data. |
3857 helper.VerifyDataConsumed(); | 3857 helper.VerifyDataConsumed(); |
3858 | 3858 |
3859 EXPECT_THAT(out.rv, IsOk()); | 3859 EXPECT_THAT(out.rv, IsOk()); |
3860 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 3860 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
3861 EXPECT_EQ("messagemessagemessagemessage", out.response_data); | 3861 EXPECT_EQ("messagemessagemessagemessage", out.response_data); |
3862 } | 3862 } |
3863 | 3863 |
3864 // Verify the case where we buffer data and close the connection. | 3864 // Verify the case where we buffer data and close the connection. |
3865 TEST_P(SpdyNetworkTransactionTest, BufferedClosed) { | 3865 TEST_P(SpdyNetworkTransactionTest, BufferedClosed) { |
3866 BufferedSpdyFramer framer(HTTP2); | 3866 BufferedSpdyFramer framer; |
3867 | 3867 |
3868 std::unique_ptr<SpdySerializedFrame> req( | 3868 std::unique_ptr<SpdySerializedFrame> req( |
3869 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 3869 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
3870 MockWrite writes[] = {CreateMockWrite(*req, 0)}; | 3870 MockWrite writes[] = {CreateMockWrite(*req, 0)}; |
3871 | 3871 |
3872 // All data frames in a single read. | 3872 // All data frames in a single read. |
3873 // NOTE: We don't FIN the stream. | 3873 // NOTE: We don't FIN the stream. |
3874 std::unique_ptr<SpdySerializedFrame> data_frame( | 3874 std::unique_ptr<SpdySerializedFrame> data_frame( |
3875 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); | 3875 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); |
3876 const SpdySerializedFrame* data_frames[4] = { | 3876 const SpdySerializedFrame* data_frames[4] = { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3943 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the | 3943 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the |
3944 // MockClientSocketFactory) are still alive. | 3944 // MockClientSocketFactory) are still alive. |
3945 base::RunLoop().RunUntilIdle(); | 3945 base::RunLoop().RunUntilIdle(); |
3946 | 3946 |
3947 // Verify that we consumed all test data. | 3947 // Verify that we consumed all test data. |
3948 helper.VerifyDataConsumed(); | 3948 helper.VerifyDataConsumed(); |
3949 } | 3949 } |
3950 | 3950 |
3951 // Verify the case where we buffer data and cancel the transaction. | 3951 // Verify the case where we buffer data and cancel the transaction. |
3952 TEST_P(SpdyNetworkTransactionTest, BufferedCancelled) { | 3952 TEST_P(SpdyNetworkTransactionTest, BufferedCancelled) { |
3953 BufferedSpdyFramer framer(HTTP2); | 3953 BufferedSpdyFramer framer; |
3954 | 3954 |
3955 std::unique_ptr<SpdySerializedFrame> req( | 3955 std::unique_ptr<SpdySerializedFrame> req( |
3956 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 3956 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
3957 std::unique_ptr<SpdySerializedFrame> rst( | 3957 std::unique_ptr<SpdySerializedFrame> rst( |
3958 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); | 3958 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); |
3959 MockWrite writes[] = {CreateMockWrite(*req, 0), CreateMockWrite(*rst, 4)}; | 3959 MockWrite writes[] = {CreateMockWrite(*req, 0), CreateMockWrite(*rst, 4)}; |
3960 | 3960 |
3961 // NOTE: We don't FIN the stream. | 3961 // NOTE: We don't FIN the stream. |
3962 std::unique_ptr<SpdySerializedFrame> data_frame( | 3962 std::unique_ptr<SpdySerializedFrame> data_frame( |
3963 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); | 3963 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); |
(...skipping 1865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5829 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); | 5829 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); |
5830 | 5830 |
5831 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 5831 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
5832 | 5832 |
5833 data.RunUntilPaused(); | 5833 data.RunUntilPaused(); |
5834 base::RunLoop().RunUntilIdle(); | 5834 base::RunLoop().RunUntilIdle(); |
5835 | 5835 |
5836 SpdyHttpStream* stream = static_cast<SpdyHttpStream*>(trans->stream_.get()); | 5836 SpdyHttpStream* stream = static_cast<SpdyHttpStream*>(trans->stream_.get()); |
5837 ASSERT_TRUE(stream); | 5837 ASSERT_TRUE(stream); |
5838 ASSERT_TRUE(stream->stream()); | 5838 ASSERT_TRUE(stream->stream()); |
5839 EXPECT_EQ( | 5839 EXPECT_EQ(static_cast<int>(kDefaultInitialWindowSize) + |
5840 static_cast<int>(SpdySession::GetDefaultInitialWindowSize(kProtoHTTP2)) + | 5840 kDeltaWindowSize * kDeltaCount - |
5841 kDeltaWindowSize * kDeltaCount - kMaxSpdyFrameChunkSize * kFrameCount, | 5841 kMaxSpdyFrameChunkSize * kFrameCount, |
5842 stream->stream()->send_window_size()); | 5842 stream->stream()->send_window_size()); |
5843 | 5843 |
5844 data.Resume(); | 5844 data.Resume(); |
5845 base::RunLoop().RunUntilIdle(); | 5845 base::RunLoop().RunUntilIdle(); |
5846 | 5846 |
5847 rv = callback.WaitForResult(); | 5847 rv = callback.WaitForResult(); |
5848 EXPECT_THAT(rv, IsOk()); | 5848 EXPECT_THAT(rv, IsOk()); |
5849 | 5849 |
5850 helper.VerifyDataConsumed(); | 5850 helper.VerifyDataConsumed(); |
5851 } | 5851 } |
5852 | 5852 |
5853 // Test that received data frames and sent WINDOW_UPDATE frames change | 5853 // Test that received data frames and sent WINDOW_UPDATE frames change |
5854 // the recv_window_size_ correctly. | 5854 // the recv_window_size_ correctly. |
5855 TEST_P(SpdyNetworkTransactionTest, WindowUpdateSent) { | 5855 TEST_P(SpdyNetworkTransactionTest, WindowUpdateSent) { |
5856 const int32_t default_initial_window_size = | |
5857 SpdySession::GetDefaultInitialWindowSize(kProtoHTTP2); | |
5858 // Session level maximum window size that is more than twice the default | 5856 // Session level maximum window size that is more than twice the default |
5859 // initial window size so that an initial window update is sent. | 5857 // initial window size so that an initial window update is sent. |
5860 const int32_t session_max_recv_window_size = 5 * 64 * 1024; | 5858 const int32_t session_max_recv_window_size = 5 * 64 * 1024; |
5861 ASSERT_LT(2 * default_initial_window_size, session_max_recv_window_size); | 5859 ASSERT_LT(2 * kDefaultInitialWindowSize, session_max_recv_window_size); |
5862 // Stream level maximum window size that is less than the session level | 5860 // Stream level maximum window size that is less than the session level |
5863 // maximum window size so that we test for confusion between the two. | 5861 // maximum window size so that we test for confusion between the two. |
5864 const int32_t stream_max_recv_window_size = 4 * 64 * 1024; | 5862 const int32_t stream_max_recv_window_size = 4 * 64 * 1024; |
5865 ASSERT_GT(session_max_recv_window_size, stream_max_recv_window_size); | 5863 ASSERT_GT(session_max_recv_window_size, stream_max_recv_window_size); |
5866 // Size of body to be sent. Has to be less than or equal to both window sizes | 5864 // Size of body to be sent. Has to be less than or equal to both window sizes |
5867 // so that we do not run out of receiving window. Also has to be greater than | 5865 // so that we do not run out of receiving window. Also has to be greater than |
5868 // half of them so that it triggers both a session level and a stream level | 5866 // half of them so that it triggers both a session level and a stream level |
5869 // window update frame. | 5867 // window update frame. |
5870 const int32_t kTargetSize = 3 * 64 * 1024; | 5868 const int32_t kTargetSize = 3 * 64 * 1024; |
5871 ASSERT_GE(session_max_recv_window_size, kTargetSize); | 5869 ASSERT_GE(session_max_recv_window_size, kTargetSize); |
(...skipping 13 matching lines...) Expand all Loading... |
5885 SettingsMap initial_settings; | 5883 SettingsMap initial_settings; |
5886 initial_settings[SETTINGS_MAX_CONCURRENT_STREAMS] = | 5884 initial_settings[SETTINGS_MAX_CONCURRENT_STREAMS] = |
5887 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, kMaxConcurrentPushedStreams); | 5885 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, kMaxConcurrentPushedStreams); |
5888 initial_settings[SETTINGS_INITIAL_WINDOW_SIZE] = | 5886 initial_settings[SETTINGS_INITIAL_WINDOW_SIZE] = |
5889 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, stream_max_recv_window_size); | 5887 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, stream_max_recv_window_size); |
5890 std::unique_ptr<SpdySerializedFrame> initial_settings_frame( | 5888 std::unique_ptr<SpdySerializedFrame> initial_settings_frame( |
5891 spdy_util_.ConstructSpdySettings(initial_settings)); | 5889 spdy_util_.ConstructSpdySettings(initial_settings)); |
5892 std::unique_ptr<SpdySerializedFrame> initial_window_update( | 5890 std::unique_ptr<SpdySerializedFrame> initial_window_update( |
5893 spdy_util_.ConstructSpdyWindowUpdate( | 5891 spdy_util_.ConstructSpdyWindowUpdate( |
5894 kSessionFlowControlStreamId, | 5892 kSessionFlowControlStreamId, |
5895 session_max_recv_window_size - default_initial_window_size)); | 5893 session_max_recv_window_size - kDefaultInitialWindowSize)); |
5896 std::unique_ptr<SpdySerializedFrame> req( | 5894 std::unique_ptr<SpdySerializedFrame> req( |
5897 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 5895 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
5898 std::unique_ptr<SpdySerializedFrame> session_window_update( | 5896 std::unique_ptr<SpdySerializedFrame> session_window_update( |
5899 spdy_util_.ConstructSpdyWindowUpdate(0, session_window_update_delta)); | 5897 spdy_util_.ConstructSpdyWindowUpdate(0, session_window_update_delta)); |
5900 std::unique_ptr<SpdySerializedFrame> stream_window_update( | 5898 std::unique_ptr<SpdySerializedFrame> stream_window_update( |
5901 spdy_util_.ConstructSpdyWindowUpdate(1, stream_window_update_delta)); | 5899 spdy_util_.ConstructSpdyWindowUpdate(1, stream_window_update_delta)); |
5902 | 5900 |
5903 std::vector<MockWrite> writes; | 5901 std::vector<MockWrite> writes; |
5904 writes.push_back(MockWrite(ASYNC, kHttp2ConnectionHeaderPrefix, | 5902 writes.push_back(MockWrite(ASYNC, kHttp2ConnectionHeaderPrefix, |
5905 kHttp2ConnectionHeaderPrefixSize, 0)); | 5903 kHttp2ConnectionHeaderPrefixSize, 0)); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6053 // also contains a FIN flag. SequencedSocketData is used to enforce all | 6051 // also contains a FIN flag. SequencedSocketData is used to enforce all |
6054 // writes, save the last, go through before a read could happen. The last frame | 6052 // writes, save the last, go through before a read could happen. The last frame |
6055 // ("hello!") is not permitted to go through since by the time its turn | 6053 // ("hello!") is not permitted to go through since by the time its turn |
6056 // arrives, window size is 0. At this point MessageLoop::Run() called via | 6054 // arrives, window size is 0. At this point MessageLoop::Run() called via |
6057 // callback would block. Therefore we call MessageLoop::RunUntilIdle() | 6055 // callback would block. Therefore we call MessageLoop::RunUntilIdle() |
6058 // which returns after performing all possible writes. We use DCHECKS to | 6056 // which returns after performing all possible writes. We use DCHECKS to |
6059 // ensure that last data frame is still there and stream has stalled. | 6057 // ensure that last data frame is still there and stream has stalled. |
6060 // After that, next read is artifically enforced, which causes a | 6058 // After that, next read is artifically enforced, which causes a |
6061 // WINDOW_UPDATE to be read and I/O process resumes. | 6059 // WINDOW_UPDATE to be read and I/O process resumes. |
6062 TEST_P(SpdyNetworkTransactionTest, FlowControlStallResume) { | 6060 TEST_P(SpdyNetworkTransactionTest, FlowControlStallResume) { |
6063 const int32_t initial_window_size = | 6061 const int32_t initial_window_size = kDefaultInitialWindowSize; |
6064 SpdySession::GetDefaultInitialWindowSize(kProtoHTTP2); | |
6065 // Number of upload data buffers we need to send to zero out the window size | 6062 // Number of upload data buffers we need to send to zero out the window size |
6066 // is the minimal number of upload buffers takes to be bigger than | 6063 // is the minimal number of upload buffers takes to be bigger than |
6067 // |initial_window_size|. | 6064 // |initial_window_size|. |
6068 size_t num_upload_buffers = | 6065 size_t num_upload_buffers = |
6069 ceil(static_cast<double>(initial_window_size) / kBufferSize); | 6066 ceil(static_cast<double>(initial_window_size) / kBufferSize); |
6070 // Each upload data buffer consists of |num_frames_in_one_upload_buffer| | 6067 // Each upload data buffer consists of |num_frames_in_one_upload_buffer| |
6071 // frames, each with |kMaxSpdyFrameChunkSize| bytes except the last frame, | 6068 // frames, each with |kMaxSpdyFrameChunkSize| bytes except the last frame, |
6072 // which has kBufferSize % kMaxSpdyChunkSize bytes. | 6069 // which has kBufferSize % kMaxSpdyChunkSize bytes. |
6073 size_t num_frames_in_one_upload_buffer = | 6070 size_t num_frames_in_one_upload_buffer = |
6074 ceil(static_cast<double>(kBufferSize) / kMaxSpdyFrameChunkSize); | 6071 ceil(static_cast<double>(kBufferSize) / kMaxSpdyFrameChunkSize); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6202 EXPECT_TRUE(stream->stream()->send_stalled_by_flow_control()); | 6199 EXPECT_TRUE(stream->stream()->send_stalled_by_flow_control()); |
6203 | 6200 |
6204 data.Resume(); // Read in WINDOW_UPDATE frame. | 6201 data.Resume(); // Read in WINDOW_UPDATE frame. |
6205 rv = callback.WaitForResult(); | 6202 rv = callback.WaitForResult(); |
6206 helper.VerifyDataConsumed(); | 6203 helper.VerifyDataConsumed(); |
6207 } | 6204 } |
6208 | 6205 |
6209 // Test we correctly handle the case where the SETTINGS frame results in | 6206 // Test we correctly handle the case where the SETTINGS frame results in |
6210 // unstalling the send window. | 6207 // unstalling the send window. |
6211 TEST_P(SpdyNetworkTransactionTest, FlowControlStallResumeAfterSettings) { | 6208 TEST_P(SpdyNetworkTransactionTest, FlowControlStallResumeAfterSettings) { |
6212 const int32_t initial_window_size = | 6209 const int32_t initial_window_size = kDefaultInitialWindowSize; |
6213 SpdySession::GetDefaultInitialWindowSize(kProtoHTTP2); | |
6214 // Number of upload data buffers we need to send to zero out the window size | 6210 // Number of upload data buffers we need to send to zero out the window size |
6215 // is the minimal number of upload buffers takes to be bigger than | 6211 // is the minimal number of upload buffers takes to be bigger than |
6216 // |initial_window_size|. | 6212 // |initial_window_size|. |
6217 size_t num_upload_buffers = | 6213 size_t num_upload_buffers = |
6218 ceil(static_cast<double>(initial_window_size) / kBufferSize); | 6214 ceil(static_cast<double>(initial_window_size) / kBufferSize); |
6219 // Each upload data buffer consists of |num_frames_in_one_upload_buffer| | 6215 // Each upload data buffer consists of |num_frames_in_one_upload_buffer| |
6220 // frames, each with |kMaxSpdyFrameChunkSize| bytes except the last frame, | 6216 // frames, each with |kMaxSpdyFrameChunkSize| bytes except the last frame, |
6221 // which has kBufferSize % kMaxSpdyChunkSize bytes. | 6217 // which has kBufferSize % kMaxSpdyChunkSize bytes. |
6222 size_t num_frames_in_one_upload_buffer = | 6218 size_t num_frames_in_one_upload_buffer = |
6223 ceil(static_cast<double>(kBufferSize) / kMaxSpdyFrameChunkSize); | 6219 ceil(static_cast<double>(kBufferSize) / kMaxSpdyFrameChunkSize); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6368 | 6364 |
6369 rv = callback.WaitForResult(); | 6365 rv = callback.WaitForResult(); |
6370 helper.VerifyDataConsumed(); | 6366 helper.VerifyDataConsumed(); |
6371 // If stream is NULL, that means it was unstalled and closed. | 6367 // If stream is NULL, that means it was unstalled and closed. |
6372 EXPECT_TRUE(stream->stream() == NULL); | 6368 EXPECT_TRUE(stream->stream() == NULL); |
6373 } | 6369 } |
6374 | 6370 |
6375 // Test we correctly handle the case where the SETTINGS frame results in a | 6371 // Test we correctly handle the case where the SETTINGS frame results in a |
6376 // negative send window size. | 6372 // negative send window size. |
6377 TEST_P(SpdyNetworkTransactionTest, FlowControlNegativeSendWindowSize) { | 6373 TEST_P(SpdyNetworkTransactionTest, FlowControlNegativeSendWindowSize) { |
6378 const int32_t initial_window_size = | 6374 const int32_t initial_window_size = kDefaultInitialWindowSize; |
6379 SpdySession::GetDefaultInitialWindowSize(kProtoHTTP2); | |
6380 // Number of upload data buffers we need to send to zero out the window size | 6375 // Number of upload data buffers we need to send to zero out the window size |
6381 // is the minimal number of upload buffers takes to be bigger than | 6376 // is the minimal number of upload buffers takes to be bigger than |
6382 // |initial_window_size|. | 6377 // |initial_window_size|. |
6383 size_t num_upload_buffers = | 6378 size_t num_upload_buffers = |
6384 ceil(static_cast<double>(initial_window_size) / kBufferSize); | 6379 ceil(static_cast<double>(initial_window_size) / kBufferSize); |
6385 // Each upload data buffer consists of |num_frames_in_one_upload_buffer| | 6380 // Each upload data buffer consists of |num_frames_in_one_upload_buffer| |
6386 // frames, each with |kMaxSpdyFrameChunkSize| bytes except the last frame, | 6381 // frames, each with |kMaxSpdyFrameChunkSize| bytes except the last frame, |
6387 // which has kBufferSize % kMaxSpdyChunkSize bytes. | 6382 // which has kBufferSize % kMaxSpdyChunkSize bytes. |
6388 size_t num_frames_in_one_upload_buffer = | 6383 size_t num_frames_in_one_upload_buffer = |
6389 ceil(static_cast<double>(kBufferSize) / kMaxSpdyFrameChunkSize); | 6384 ceil(static_cast<double>(kBufferSize) / kMaxSpdyFrameChunkSize); |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6706 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { | 6701 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { |
6707 std::unique_ptr<SSLSocketDataProvider> ssl_provider( | 6702 std::unique_ptr<SSLSocketDataProvider> ssl_provider( |
6708 new SSLSocketDataProvider(ASYNC, OK)); | 6703 new SSLSocketDataProvider(ASYNC, OK)); |
6709 // Set to TLS_RSA_WITH_NULL_MD5 | 6704 // Set to TLS_RSA_WITH_NULL_MD5 |
6710 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); | 6705 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); |
6711 | 6706 |
6712 RunTLSUsageCheckTest(std::move(ssl_provider)); | 6707 RunTLSUsageCheckTest(std::move(ssl_provider)); |
6713 } | 6708 } |
6714 | 6709 |
6715 } // namespace net | 6710 } // namespace net |
OLD | NEW |