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 23 matching lines...) Expand all Loading... |
34 SPDYNOSSL, | 34 SPDYNOSSL, |
35 SPDYSSL, | 35 SPDYSSL, |
36 }; | 36 }; |
37 class SpdyNetworkTransactionSpdy2Test | 37 class SpdyNetworkTransactionSpdy2Test |
38 : public ::testing::TestWithParam<SpdyNetworkTransactionSpdy2TestTypes> { | 38 : public ::testing::TestWithParam<SpdyNetworkTransactionSpdy2TestTypes> { |
39 protected: | 39 protected: |
40 | 40 |
41 virtual void SetUp() { | 41 virtual void SetUp() { |
42 // By default, all tests turn off compression. | 42 // By default, all tests turn off compression. |
43 EnableCompression(false); | 43 EnableCompression(false); |
| 44 SpdySession::set_default_protocol(SSLClientSocket::kProtoSPDY2); |
44 google_get_request_initialized_ = false; | 45 google_get_request_initialized_ = false; |
45 google_post_request_initialized_ = false; | 46 google_post_request_initialized_ = false; |
46 google_chunked_post_request_initialized_ = false; | 47 google_chunked_post_request_initialized_ = false; |
47 } | 48 } |
48 | 49 |
49 virtual void TearDown() { | 50 virtual void TearDown() { |
50 // Empty the current queue. | 51 // Empty the current queue. |
51 MessageLoop::current()->RunAllPending(); | 52 MessageLoop::current()->RunAllPending(); |
52 } | 53 } |
53 | 54 |
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
932 scoped_ptr<spdy::SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3)); | 933 scoped_ptr<spdy::SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3)); |
933 scoped_ptr<spdy::SpdyFrame> body2(ConstructSpdyBodyFrame(3, false)); | 934 scoped_ptr<spdy::SpdyFrame> body2(ConstructSpdyBodyFrame(3, false)); |
934 scoped_ptr<spdy::SpdyFrame> fbody2(ConstructSpdyBodyFrame(3, true)); | 935 scoped_ptr<spdy::SpdyFrame> fbody2(ConstructSpdyBodyFrame(3, true)); |
935 | 936 |
936 scoped_ptr<spdy::SpdyFrame> req3(ConstructSpdyGet(NULL, 0, false, 5, LOWEST)); | 937 scoped_ptr<spdy::SpdyFrame> req3(ConstructSpdyGet(NULL, 0, false, 5, LOWEST)); |
937 scoped_ptr<spdy::SpdyFrame> resp3(ConstructSpdyGetSynReply(NULL, 0, 5)); | 938 scoped_ptr<spdy::SpdyFrame> resp3(ConstructSpdyGetSynReply(NULL, 0, 5)); |
938 scoped_ptr<spdy::SpdyFrame> body3(ConstructSpdyBodyFrame(5, false)); | 939 scoped_ptr<spdy::SpdyFrame> body3(ConstructSpdyBodyFrame(5, false)); |
939 scoped_ptr<spdy::SpdyFrame> fbody3(ConstructSpdyBodyFrame(5, true)); | 940 scoped_ptr<spdy::SpdyFrame> fbody3(ConstructSpdyBodyFrame(5, true)); |
940 | 941 |
941 spdy::SpdySettings settings; | 942 spdy::SpdySettings settings; |
942 spdy::SettingsFlagsAndId id(0); | 943 spdy::SettingsFlagsAndId id(0, spdy::SETTINGS_MAX_CONCURRENT_STREAMS); |
943 id.set_id(spdy::SETTINGS_MAX_CONCURRENT_STREAMS); | |
944 const size_t max_concurrent_streams = 1; | 944 const size_t max_concurrent_streams = 1; |
945 | 945 |
946 settings.push_back(spdy::SpdySetting(id, max_concurrent_streams)); | 946 settings.push_back(spdy::SpdySetting(id, max_concurrent_streams)); |
947 scoped_ptr<spdy::SpdyFrame> settings_frame(ConstructSpdySettings(settings)); | 947 scoped_ptr<spdy::SpdyFrame> settings_frame(ConstructSpdySettings(settings)); |
948 | 948 |
949 MockWrite writes[] = { | 949 MockWrite writes[] = { |
950 CreateMockWrite(*req), | 950 CreateMockWrite(*req), |
951 CreateMockWrite(*req2), | 951 CreateMockWrite(*req2), |
952 CreateMockWrite(*req3), | 952 CreateMockWrite(*req3), |
953 }; | 953 }; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1071 scoped_ptr<spdy::SpdyFrame> resp4(ConstructSpdyGetSynReply(NULL, 0, 5)); | 1071 scoped_ptr<spdy::SpdyFrame> resp4(ConstructSpdyGetSynReply(NULL, 0, 5)); |
1072 scoped_ptr<spdy::SpdyFrame> fbody4(ConstructSpdyBodyFrame(5, true)); | 1072 scoped_ptr<spdy::SpdyFrame> fbody4(ConstructSpdyBodyFrame(5, true)); |
1073 | 1073 |
1074 scoped_ptr<spdy::SpdyFrame> req3(ConstructSpdyGet(NULL, 0, false, 7, LOWEST)); | 1074 scoped_ptr<spdy::SpdyFrame> req3(ConstructSpdyGet(NULL, 0, false, 7, LOWEST)); |
1075 scoped_ptr<spdy::SpdyFrame> resp3(ConstructSpdyGetSynReply(NULL, 0, 7)); | 1075 scoped_ptr<spdy::SpdyFrame> resp3(ConstructSpdyGetSynReply(NULL, 0, 7)); |
1076 scoped_ptr<spdy::SpdyFrame> body3(ConstructSpdyBodyFrame(7, false)); | 1076 scoped_ptr<spdy::SpdyFrame> body3(ConstructSpdyBodyFrame(7, false)); |
1077 scoped_ptr<spdy::SpdyFrame> fbody3(ConstructSpdyBodyFrame(7, true)); | 1077 scoped_ptr<spdy::SpdyFrame> fbody3(ConstructSpdyBodyFrame(7, true)); |
1078 | 1078 |
1079 | 1079 |
1080 spdy::SpdySettings settings; | 1080 spdy::SpdySettings settings; |
1081 spdy::SettingsFlagsAndId id(0); | 1081 spdy::SettingsFlagsAndId id(0, spdy::SETTINGS_MAX_CONCURRENT_STREAMS); |
1082 id.set_id(spdy::SETTINGS_MAX_CONCURRENT_STREAMS); | |
1083 const size_t max_concurrent_streams = 1; | 1082 const size_t max_concurrent_streams = 1; |
1084 | 1083 |
1085 settings.push_back(spdy::SpdySetting(id, max_concurrent_streams)); | 1084 settings.push_back(spdy::SpdySetting(id, max_concurrent_streams)); |
1086 scoped_ptr<spdy::SpdyFrame> settings_frame(ConstructSpdySettings(settings)); | 1085 scoped_ptr<spdy::SpdyFrame> settings_frame(ConstructSpdySettings(settings)); |
1087 | 1086 |
1088 MockWrite writes[] = { CreateMockWrite(*req), | 1087 MockWrite writes[] = { CreateMockWrite(*req), |
1089 CreateMockWrite(*req2), | 1088 CreateMockWrite(*req2), |
1090 CreateMockWrite(*req4), | 1089 CreateMockWrite(*req4), |
1091 CreateMockWrite(*req3), | 1090 CreateMockWrite(*req3), |
1092 }; | 1091 }; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1216 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 1215 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
1217 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, false)); | 1216 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, false)); |
1218 scoped_ptr<spdy::SpdyFrame> fbody(ConstructSpdyBodyFrame(1, true)); | 1217 scoped_ptr<spdy::SpdyFrame> fbody(ConstructSpdyBodyFrame(1, true)); |
1219 | 1218 |
1220 scoped_ptr<spdy::SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST)); | 1219 scoped_ptr<spdy::SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST)); |
1221 scoped_ptr<spdy::SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3)); | 1220 scoped_ptr<spdy::SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3)); |
1222 scoped_ptr<spdy::SpdyFrame> body2(ConstructSpdyBodyFrame(3, false)); | 1221 scoped_ptr<spdy::SpdyFrame> body2(ConstructSpdyBodyFrame(3, false)); |
1223 scoped_ptr<spdy::SpdyFrame> fbody2(ConstructSpdyBodyFrame(3, true)); | 1222 scoped_ptr<spdy::SpdyFrame> fbody2(ConstructSpdyBodyFrame(3, true)); |
1224 | 1223 |
1225 spdy::SpdySettings settings; | 1224 spdy::SpdySettings settings; |
1226 spdy::SettingsFlagsAndId id(0); | 1225 spdy::SettingsFlagsAndId id(0, spdy::SETTINGS_MAX_CONCURRENT_STREAMS); |
1227 id.set_id(spdy::SETTINGS_MAX_CONCURRENT_STREAMS); | |
1228 const size_t max_concurrent_streams = 1; | 1226 const size_t max_concurrent_streams = 1; |
1229 | 1227 |
1230 settings.push_back(spdy::SpdySetting(id, max_concurrent_streams)); | 1228 settings.push_back(spdy::SpdySetting(id, max_concurrent_streams)); |
1231 scoped_ptr<spdy::SpdyFrame> settings_frame(ConstructSpdySettings(settings)); | 1229 scoped_ptr<spdy::SpdyFrame> settings_frame(ConstructSpdySettings(settings)); |
1232 | 1230 |
1233 MockWrite writes[] = { CreateMockWrite(*req), | 1231 MockWrite writes[] = { CreateMockWrite(*req), |
1234 CreateMockWrite(*req2), | 1232 CreateMockWrite(*req2), |
1235 }; | 1233 }; |
1236 MockRead reads[] = { | 1234 MockRead reads[] = { |
1237 CreateMockRead(*settings_frame, 1), | 1235 CreateMockRead(*settings_frame, 1), |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1352 // Construct the request. | 1350 // Construct the request. |
1353 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 1351 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
1354 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 1352 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
1355 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, false)); | 1353 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, false)); |
1356 scoped_ptr<spdy::SpdyFrame> fin_body(ConstructSpdyBodyFrame(1, true)); | 1354 scoped_ptr<spdy::SpdyFrame> fin_body(ConstructSpdyBodyFrame(1, true)); |
1357 | 1355 |
1358 scoped_ptr<spdy::SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST)); | 1356 scoped_ptr<spdy::SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST)); |
1359 scoped_ptr<spdy::SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3)); | 1357 scoped_ptr<spdy::SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3)); |
1360 | 1358 |
1361 spdy::SpdySettings settings; | 1359 spdy::SpdySettings settings; |
1362 spdy::SettingsFlagsAndId id(0); | 1360 spdy::SettingsFlagsAndId id(0, spdy::SETTINGS_MAX_CONCURRENT_STREAMS); |
1363 id.set_id(spdy::SETTINGS_MAX_CONCURRENT_STREAMS); | |
1364 const size_t max_concurrent_streams = 1; | 1361 const size_t max_concurrent_streams = 1; |
1365 | 1362 |
1366 settings.push_back(spdy::SpdySetting(id, max_concurrent_streams)); | 1363 settings.push_back(spdy::SpdySetting(id, max_concurrent_streams)); |
1367 scoped_ptr<spdy::SpdyFrame> settings_frame(ConstructSpdySettings(settings)); | 1364 scoped_ptr<spdy::SpdyFrame> settings_frame(ConstructSpdySettings(settings)); |
1368 | 1365 |
1369 MockWrite writes[] = { CreateMockWrite(*req), | 1366 MockWrite writes[] = { CreateMockWrite(*req), |
1370 CreateMockWrite(*req2), | 1367 CreateMockWrite(*req2), |
1371 }; | 1368 }; |
1372 MockRead reads[] = { | 1369 MockRead reads[] = { |
1373 CreateMockRead(*settings_frame, 1), | 1370 CreateMockRead(*settings_frame, 1), |
(...skipping 1408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2782 EXPECT_TRUE(response.headers != NULL); | 2779 EXPECT_TRUE(response.headers != NULL); |
2783 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 2780 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
2784 | 2781 |
2785 // Verify the pushed stream. | 2782 // Verify the pushed stream. |
2786 EXPECT_TRUE(response2.headers != NULL); | 2783 EXPECT_TRUE(response2.headers != NULL); |
2787 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 2784 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
2788 } | 2785 } |
2789 | 2786 |
2790 TEST_P(SpdyNetworkTransactionSpdy2Test, | 2787 TEST_P(SpdyNetworkTransactionSpdy2Test, |
2791 ServerPushMultipleDataFrameInterrupted) { | 2788 ServerPushMultipleDataFrameInterrupted) { |
2792 SpdySession::set_use_flow_control(SpdySession::kDisableFlowControl); | |
2793 | |
2794 static const unsigned char kPushBodyFrame1[] = { | 2789 static const unsigned char kPushBodyFrame1[] = { |
2795 0x00, 0x00, 0x00, 0x02, // header, ID | 2790 0x00, 0x00, 0x00, 0x02, // header, ID |
2796 0x01, 0x00, 0x00, 0x1F, // FIN, length | 2791 0x01, 0x00, 0x00, 0x1F, // FIN, length |
2797 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | 2792 'p', 'u', 's', 'h', 'e', 'd' // "pushed" |
2798 }; | 2793 }; |
2799 static const char kPushBodyFrame2[] = " my darling"; | 2794 static const char kPushBodyFrame2[] = " my darling"; |
2800 static const char kPushBodyFrame3[] = " hello"; | 2795 static const char kPushBodyFrame3[] = " hello"; |
2801 static const char kPushBodyFrame4[] = " my baby"; | 2796 static const char kPushBodyFrame4[] = " my baby"; |
2802 | 2797 |
2803 scoped_ptr<spdy::SpdyFrame> | 2798 scoped_ptr<spdy::SpdyFrame> |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2845 &response2, | 2840 &response2, |
2846 expected_push_result); | 2841 expected_push_result); |
2847 | 2842 |
2848 // Verify the SYN_REPLY. | 2843 // Verify the SYN_REPLY. |
2849 EXPECT_TRUE(response.headers != NULL); | 2844 EXPECT_TRUE(response.headers != NULL); |
2850 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 2845 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
2851 | 2846 |
2852 // Verify the pushed stream. | 2847 // Verify the pushed stream. |
2853 EXPECT_TRUE(response2.headers != NULL); | 2848 EXPECT_TRUE(response2.headers != NULL); |
2854 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 2849 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
2855 | |
2856 SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); | |
2857 } | 2850 } |
2858 | 2851 |
2859 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushInvalidAssociatedStreamID0) { | 2852 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushInvalidAssociatedStreamID0) { |
2860 scoped_ptr<spdy::SpdyFrame> | 2853 scoped_ptr<spdy::SpdyFrame> |
2861 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 2854 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
2862 scoped_ptr<spdy::SpdyFrame> | 2855 scoped_ptr<spdy::SpdyFrame> |
2863 stream1_body(ConstructSpdyBodyFrame(1, true)); | 2856 stream1_body(ConstructSpdyBodyFrame(1, true)); |
2864 scoped_ptr<spdy::SpdyFrame> | 2857 scoped_ptr<spdy::SpdyFrame> |
2865 stream2_rst(ConstructSpdyRstStream(2, spdy::INVALID_STREAM)); | 2858 stream2_rst(ConstructSpdyRstStream(2, spdy::INVALID_STREAM)); |
2866 MockWrite writes[] = { | 2859 MockWrite writes[] = { |
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3561 ++it) { | 3554 ++it) { |
3562 EXPECT_EQ(it->second, (*headers)[it->first]); | 3555 EXPECT_EQ(it->second, (*headers)[it->first]); |
3563 } | 3556 } |
3564 } | 3557 } |
3565 | 3558 |
3566 // Since we buffer the IO from the stream to the renderer, this test verifies | 3559 // Since we buffer the IO from the stream to the renderer, this test verifies |
3567 // that when we read out the maximum amount of data (e.g. we received 50 bytes | 3560 // that when we read out the maximum amount of data (e.g. we received 50 bytes |
3568 // on the network, but issued a Read for only 5 of those bytes) that the data | 3561 // on the network, but issued a Read for only 5 of those bytes) that the data |
3569 // flow still works correctly. | 3562 // flow still works correctly. |
3570 TEST_P(SpdyNetworkTransactionSpdy2Test, BufferFull) { | 3563 TEST_P(SpdyNetworkTransactionSpdy2Test, BufferFull) { |
3571 SpdySession::set_use_flow_control(SpdySession::kDisableFlowControl); | |
3572 | |
3573 spdy::BufferedSpdyFramer framer(2); | 3564 spdy::BufferedSpdyFramer framer(2); |
3574 | 3565 |
3575 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 3566 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
3576 MockWrite writes[] = { CreateMockWrite(*req) }; | 3567 MockWrite writes[] = { CreateMockWrite(*req) }; |
3577 | 3568 |
3578 // 2 data frames in a single read. | 3569 // 2 data frames in a single read. |
3579 scoped_ptr<spdy::SpdyFrame> data_frame_1( | 3570 scoped_ptr<spdy::SpdyFrame> data_frame_1( |
3580 framer.CreateDataFrame(1, "goodby", 6, spdy::DATA_FLAG_NONE)); | 3571 framer.CreateDataFrame(1, "goodby", 6, spdy::DATA_FLAG_NONE)); |
3581 scoped_ptr<spdy::SpdyFrame> data_frame_2( | 3572 scoped_ptr<spdy::SpdyFrame> data_frame_2( |
3582 framer.CreateDataFrame(1, "e worl", 6, spdy::DATA_FLAG_NONE)); | 3573 framer.CreateDataFrame(1, "e worl", 6, spdy::DATA_FLAG_NONE)); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3652 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the | 3643 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the |
3653 // MockClientSocketFactory) are still alive. | 3644 // MockClientSocketFactory) are still alive. |
3654 MessageLoop::current()->RunAllPending(); | 3645 MessageLoop::current()->RunAllPending(); |
3655 | 3646 |
3656 // Verify that we consumed all test data. | 3647 // Verify that we consumed all test data. |
3657 helper.VerifyDataConsumed(); | 3648 helper.VerifyDataConsumed(); |
3658 | 3649 |
3659 EXPECT_EQ(OK, out.rv); | 3650 EXPECT_EQ(OK, out.rv); |
3660 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 3651 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
3661 EXPECT_EQ("goodbye world", out.response_data); | 3652 EXPECT_EQ("goodbye world", out.response_data); |
3662 | |
3663 SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); | |
3664 } | 3653 } |
3665 | 3654 |
3666 // Verify that basic buffering works; when multiple data frames arrive | 3655 // Verify that basic buffering works; when multiple data frames arrive |
3667 // at the same time, ensure that we don't notify a read completion for | 3656 // at the same time, ensure that we don't notify a read completion for |
3668 // each data frame individually. | 3657 // each data frame individually. |
3669 TEST_P(SpdyNetworkTransactionSpdy2Test, Buffering) { | 3658 TEST_P(SpdyNetworkTransactionSpdy2Test, Buffering) { |
3670 SpdySession::set_use_flow_control(SpdySession::kDisableFlowControl); | |
3671 | |
3672 spdy::BufferedSpdyFramer framer(2); | 3659 spdy::BufferedSpdyFramer framer(2); |
3673 | 3660 |
3674 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 3661 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
3675 MockWrite writes[] = { CreateMockWrite(*req) }; | 3662 MockWrite writes[] = { CreateMockWrite(*req) }; |
3676 | 3663 |
3677 // 4 data frames in a single read. | 3664 // 4 data frames in a single read. |
3678 scoped_ptr<spdy::SpdyFrame> data_frame( | 3665 scoped_ptr<spdy::SpdyFrame> data_frame( |
3679 framer.CreateDataFrame(1, "message", 7, spdy::DATA_FLAG_NONE)); | 3666 framer.CreateDataFrame(1, "message", 7, spdy::DATA_FLAG_NONE)); |
3680 scoped_ptr<spdy::SpdyFrame> data_frame_fin( | 3667 scoped_ptr<spdy::SpdyFrame> data_frame_fin( |
3681 framer.CreateDataFrame(1, "message", 7, spdy::DATA_FLAG_FIN)); | 3668 framer.CreateDataFrame(1, "message", 7, spdy::DATA_FLAG_FIN)); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3753 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the | 3740 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the |
3754 // MockClientSocketFactory) are still alive. | 3741 // MockClientSocketFactory) are still alive. |
3755 MessageLoop::current()->RunAllPending(); | 3742 MessageLoop::current()->RunAllPending(); |
3756 | 3743 |
3757 // Verify that we consumed all test data. | 3744 // Verify that we consumed all test data. |
3758 helper.VerifyDataConsumed(); | 3745 helper.VerifyDataConsumed(); |
3759 | 3746 |
3760 EXPECT_EQ(OK, out.rv); | 3747 EXPECT_EQ(OK, out.rv); |
3761 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 3748 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
3762 EXPECT_EQ("messagemessagemessagemessage", out.response_data); | 3749 EXPECT_EQ("messagemessagemessagemessage", out.response_data); |
3763 | |
3764 SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); | |
3765 } | 3750 } |
3766 | 3751 |
3767 // Verify the case where we buffer data but read it after it has been buffered. | 3752 // Verify the case where we buffer data but read it after it has been buffered. |
3768 TEST_P(SpdyNetworkTransactionSpdy2Test, BufferedAll) { | 3753 TEST_P(SpdyNetworkTransactionSpdy2Test, BufferedAll) { |
3769 spdy::BufferedSpdyFramer framer(2); | 3754 spdy::BufferedSpdyFramer framer(2); |
3770 | 3755 |
3771 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 3756 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
3772 MockWrite writes[] = { CreateMockWrite(*req) }; | 3757 MockWrite writes[] = { CreateMockWrite(*req) }; |
3773 | 3758 |
3774 // 5 data frames in a single read. | 3759 // 5 data frames in a single read. |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4058 ConstructSpdyPacket(kSynReplyInfo, | 4043 ConstructSpdyPacket(kSynReplyInfo, |
4059 kExtraHeaders, | 4044 kExtraHeaders, |
4060 arraysize(kExtraHeaders) / 2, | 4045 arraysize(kExtraHeaders) / 2, |
4061 NULL, | 4046 NULL, |
4062 0)); | 4047 0)); |
4063 | 4048 |
4064 unsigned int kSampleId1 = 0x1; | 4049 unsigned int kSampleId1 = 0x1; |
4065 unsigned int kSampleValue1 = 0x0a0a0a0a; | 4050 unsigned int kSampleValue1 = 0x0a0a0a0a; |
4066 unsigned int kSampleId2 = 0x2; | 4051 unsigned int kSampleId2 = 0x2; |
4067 unsigned int kSampleValue2 = 0x0b0b0b0b; | 4052 unsigned int kSampleValue2 = 0x0b0b0b0b; |
4068 unsigned int kSampleId3 = 0xababab; | 4053 unsigned int kSampleId3 = 0x3; |
4069 unsigned int kSampleValue3 = 0x0c0c0c0c; | 4054 unsigned int kSampleValue3 = 0x0c0c0c0c; |
4070 scoped_ptr<spdy::SpdyFrame> settings_frame; | 4055 scoped_ptr<spdy::SpdyFrame> settings_frame; |
4071 { | 4056 { |
4072 // Construct the SETTINGS frame. | 4057 // Construct the SETTINGS frame. |
4073 spdy::SpdySettings settings; | 4058 spdy::SpdySettings settings; |
4074 spdy::SettingsFlagsAndId setting(0); | |
4075 // First add a persisted setting | 4059 // First add a persisted setting |
4076 setting.set_flags(spdy::SETTINGS_FLAG_PLEASE_PERSIST); | 4060 spdy::SettingsFlagsAndId setting1(spdy::SETTINGS_FLAG_PLEASE_PERSIST, |
4077 setting.set_id(kSampleId1); | 4061 kSampleId1); |
4078 settings.push_back(std::make_pair(setting, kSampleValue1)); | 4062 settings.push_back(std::make_pair(setting1, kSampleValue1)); |
4079 // Next add a non-persisted setting | 4063 // Next add a non-persisted setting |
4080 setting.set_flags(0); | 4064 spdy::SettingsFlagsAndId setting2(0, kSampleId2); |
4081 setting.set_id(kSampleId2); | 4065 settings.push_back(std::make_pair(setting2, kSampleValue2)); |
4082 settings.push_back(std::make_pair(setting, kSampleValue2)); | |
4083 // Next add another persisted setting | 4066 // Next add another persisted setting |
4084 setting.set_flags(spdy::SETTINGS_FLAG_PLEASE_PERSIST); | 4067 spdy::SettingsFlagsAndId setting3(spdy::SETTINGS_FLAG_PLEASE_PERSIST, |
4085 setting.set_id(kSampleId3); | 4068 kSampleId3); |
4086 settings.push_back(std::make_pair(setting, kSampleValue3)); | 4069 settings.push_back(std::make_pair(setting3, kSampleValue3)); |
4087 settings_frame.reset(ConstructSpdySettings(settings)); | 4070 settings_frame.reset(ConstructSpdySettings(settings)); |
4088 } | 4071 } |
4089 | 4072 |
4090 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); | 4073 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); |
4091 MockRead reads[] = { | 4074 MockRead reads[] = { |
4092 CreateMockRead(*reply), | 4075 CreateMockRead(*reply), |
4093 CreateMockRead(*body), | 4076 CreateMockRead(*body), |
4094 CreateMockRead(*settings_frame), | 4077 CreateMockRead(*settings_frame), |
4095 MockRead(ASYNC, 0, 0) // EOF | 4078 MockRead(ASYNC, 0, 0) // EOF |
4096 }; | 4079 }; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4160 EXPECT_TRUE(spdy_session_pool->http_server_properties()->GetSpdySettings( | 4143 EXPECT_TRUE(spdy_session_pool->http_server_properties()->GetSpdySettings( |
4161 host_port_pair).empty()); | 4144 host_port_pair).empty()); |
4162 | 4145 |
4163 unsigned int kSampleId1 = 0x1; | 4146 unsigned int kSampleId1 = 0x1; |
4164 unsigned int kSampleValue1 = 0x0a0a0a0a; | 4147 unsigned int kSampleValue1 = 0x0a0a0a0a; |
4165 unsigned int kSampleId2 = 0xababab; | 4148 unsigned int kSampleId2 = 0xababab; |
4166 unsigned int kSampleValue2 = 0x0c0c0c0c; | 4149 unsigned int kSampleValue2 = 0x0c0c0c0c; |
4167 // Manually insert settings into the SpdySettingsStorage here. | 4150 // Manually insert settings into the SpdySettingsStorage here. |
4168 { | 4151 { |
4169 spdy::SpdySettings settings; | 4152 spdy::SpdySettings settings; |
4170 spdy::SettingsFlagsAndId setting(0); | |
4171 // First add a persisted setting | 4153 // First add a persisted setting |
4172 setting.set_flags(spdy::SETTINGS_FLAG_PLEASE_PERSIST); | 4154 spdy::SettingsFlagsAndId setting1(spdy::SETTINGS_FLAG_PLEASE_PERSIST, |
4173 setting.set_id(kSampleId1); | 4155 kSampleId1); |
4174 settings.push_back(std::make_pair(setting, kSampleValue1)); | 4156 settings.push_back(std::make_pair(setting1, kSampleValue1)); |
4175 // Next add another persisted setting | 4157 // Next add another persisted setting |
4176 setting.set_flags(spdy::SETTINGS_FLAG_PLEASE_PERSIST); | 4158 spdy::SettingsFlagsAndId setting2(spdy::SETTINGS_FLAG_PLEASE_PERSIST, |
4177 setting.set_id(kSampleId2); | 4159 kSampleId2); |
4178 settings.push_back(std::make_pair(setting, kSampleValue2)); | 4160 settings.push_back(std::make_pair(setting2, kSampleValue2)); |
4179 | 4161 |
4180 spdy_session_pool->http_server_properties()->SetSpdySettings( | 4162 spdy_session_pool->http_server_properties()->SetSpdySettings( |
4181 host_port_pair, settings); | 4163 host_port_pair, settings); |
4182 } | 4164 } |
4183 | 4165 |
4184 EXPECT_EQ(2u, spdy_session_pool->http_server_properties()->GetSpdySettings( | 4166 EXPECT_EQ(2u, spdy_session_pool->http_server_properties()->GetSpdySettings( |
4185 host_port_pair).size()); | 4167 host_port_pair).size()); |
4186 | 4168 |
4187 // Construct the SETTINGS frame. | 4169 // Construct the SETTINGS frame. |
4188 const spdy::SpdySettings& settings = | 4170 const spdy::SpdySettings& settings = |
(...skipping 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5516 << " Write index: " | 5498 << " Write index: " |
5517 << data->write_index(); | 5499 << data->write_index(); |
5518 | 5500 |
5519 // Verify the SYN_REPLY. | 5501 // Verify the SYN_REPLY. |
5520 HttpResponseInfo response = *trans->GetResponseInfo(); | 5502 HttpResponseInfo response = *trans->GetResponseInfo(); |
5521 EXPECT_TRUE(response.headers != NULL); | 5503 EXPECT_TRUE(response.headers != NULL); |
5522 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5504 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
5523 } | 5505 } |
5524 | 5506 |
5525 } // namespace net | 5507 } // namespace net |
OLD | NEW |