| 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 case kProtoHTTP11: | 76 case kProtoHTTP11: |
| 77 case kProtoSPDY1: | 77 case kProtoSPDY1: |
| 78 case kProtoSPDY21: | 78 case kProtoSPDY21: |
| 79 break; | 79 break; |
| 80 } | 80 } |
| 81 | 81 |
| 82 NOTREACHED(); | 82 NOTREACHED(); |
| 83 return HttpResponseInfo::CONNECTION_INFO_SPDY2; | 83 return HttpResponseInfo::CONNECTION_INFO_SPDY2; |
| 84 } | 84 } |
| 85 | 85 |
| 86 AlternateProtocol NextProtoToAlternateProtocol(NextProto next_proto) { | |
| 87 switch (next_proto) { | |
| 88 case kProtoSPDY2: | |
| 89 return NPN_SPDY_2; | |
| 90 case kProtoSPDY3: | |
| 91 return NPN_SPDY_3; | |
| 92 case kProtoSPDY31: | |
| 93 return NPN_SPDY_3_1; | |
| 94 case kProtoSPDY4a2: | |
| 95 return NPN_SPDY_4A2; | |
| 96 | |
| 97 case kProtoUnknown: | |
| 98 case kProtoHTTP11: | |
| 99 case kProtoSPDY1: | |
| 100 case kProtoSPDY21: | |
| 101 break; | |
| 102 } | |
| 103 | |
| 104 NOTREACHED(); | |
| 105 return NPN_SPDY_2; | |
| 106 } | |
| 107 | |
| 108 SpdySessionDependencies* CreateSpdySessionDependencies( | 86 SpdySessionDependencies* CreateSpdySessionDependencies( |
| 109 SpdyNetworkTransactionTestParams test_params) { | 87 SpdyNetworkTransactionTestParams test_params) { |
| 110 return new SpdySessionDependencies(test_params.protocol); | 88 return new SpdySessionDependencies(test_params.protocol); |
| 111 } | 89 } |
| 112 | 90 |
| 113 SpdySessionDependencies* CreateSpdySessionDependencies( | 91 SpdySessionDependencies* CreateSpdySessionDependencies( |
| 114 SpdyNetworkTransactionTestParams test_params, | 92 SpdyNetworkTransactionTestParams test_params, |
| 115 ProxyService* proxy_service) { | 93 ProxyService* proxy_service) { |
| 116 return new SpdySessionDependencies(test_params.protocol, proxy_service); | 94 return new SpdySessionDependencies(test_params.protocol, proxy_service); |
| 117 } | 95 } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 void RunPreTestSetup() { | 179 void RunPreTestSetup() { |
| 202 if (!session_deps_.get()) | 180 if (!session_deps_.get()) |
| 203 session_deps_.reset(CreateSpdySessionDependencies(test_params_)); | 181 session_deps_.reset(CreateSpdySessionDependencies(test_params_)); |
| 204 if (!session_.get()) | 182 if (!session_.get()) |
| 205 session_ = SpdySessionDependencies::SpdyCreateSession( | 183 session_ = SpdySessionDependencies::SpdyCreateSession( |
| 206 session_deps_.get()); | 184 session_deps_.get()); |
| 207 HttpStreamFactory::set_use_alternate_protocols(false); | 185 HttpStreamFactory::set_use_alternate_protocols(false); |
| 208 HttpStreamFactory::set_force_spdy_over_ssl(false); | 186 HttpStreamFactory::set_force_spdy_over_ssl(false); |
| 209 HttpStreamFactory::set_force_spdy_always(false); | 187 HttpStreamFactory::set_force_spdy_always(false); |
| 210 | 188 |
| 211 std::vector<std::string> next_protos; | 189 std::vector<std::string> next_protos = SpdyNextProtos(); |
| 212 next_protos.push_back("http/1.1"); | |
| 213 next_protos.push_back("spdy/2"); | |
| 214 | 190 |
| 215 switch (test_params_.ssl_type) { | 191 switch (test_params_.ssl_type) { |
| 216 case SPDYNPN: | 192 case SPDYNPN: |
| 217 session_->http_server_properties()->SetAlternateProtocol( | 193 session_->http_server_properties()->SetAlternateProtocol( |
| 218 HostPortPair("www.google.com", 80), 443, | 194 HostPortPair("www.google.com", 80), 443, |
| 219 NextProtoToAlternateProtocol(test_params_.protocol)); | 195 AlternateProtocolFromNextProto(test_params_.protocol)); |
| 220 HttpStreamFactory::set_use_alternate_protocols(true); | 196 HttpStreamFactory::set_use_alternate_protocols(true); |
| 221 HttpStreamFactory::SetNextProtos(next_protos); | 197 HttpStreamFactory::SetNextProtos(next_protos); |
| 222 break; | 198 break; |
| 223 case SPDYNOSSL: | 199 case SPDYNOSSL: |
| 224 HttpStreamFactory::set_force_spdy_over_ssl(false); | 200 HttpStreamFactory::set_force_spdy_over_ssl(false); |
| 225 HttpStreamFactory::set_force_spdy_always(true); | 201 HttpStreamFactory::set_force_spdy_always(true); |
| 226 break; | 202 break; |
| 227 case SPDYSSL: | 203 case SPDYSSL: |
| 228 HttpStreamFactory::set_force_spdy_over_ssl(true); | 204 HttpStreamFactory::set_force_spdy_over_ssl(true); |
| 229 HttpStreamFactory::set_force_spdy_always(true); | 205 HttpStreamFactory::set_force_spdy_always(true); |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 EXPECT_TRUE(pool->HasSession(key)); | 566 EXPECT_TRUE(pool->HasSession(key)); |
| 591 scoped_refptr<SpdySession> spdy_session(pool->Get(key, log)); | 567 scoped_refptr<SpdySession> spdy_session(pool->Get(key, log)); |
| 592 ASSERT_TRUE(spdy_session.get() != NULL); | 568 ASSERT_TRUE(spdy_session.get() != NULL); |
| 593 EXPECT_EQ(0u, spdy_session->num_active_streams()); | 569 EXPECT_EQ(0u, spdy_session->num_active_streams()); |
| 594 EXPECT_EQ(0u, spdy_session->num_unclaimed_pushed_streams()); | 570 EXPECT_EQ(0u, spdy_session->num_unclaimed_pushed_streams()); |
| 595 } | 571 } |
| 596 | 572 |
| 597 void RunServerPushTest(OrderedSocketData* data, | 573 void RunServerPushTest(OrderedSocketData* data, |
| 598 HttpResponseInfo* response, | 574 HttpResponseInfo* response, |
| 599 HttpResponseInfo* push_response, | 575 HttpResponseInfo* push_response, |
| 600 std::string& expected) { | 576 const std::string& expected) { |
| 601 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 577 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 602 BoundNetLog(), GetParam(), NULL); | 578 BoundNetLog(), GetParam(), NULL); |
| 603 helper.RunPreTestSetup(); | 579 helper.RunPreTestSetup(); |
| 604 helper.AddData(data); | 580 helper.AddData(data); |
| 605 | 581 |
| 606 HttpNetworkTransaction* trans = helper.trans(); | 582 HttpNetworkTransaction* trans = helper.trans(); |
| 607 | 583 |
| 608 // Start the transaction with basic parameters. | 584 // Start the transaction with basic parameters. |
| 609 TestCompletionCallback callback; | 585 TestCompletionCallback callback; |
| 610 int rv = trans->Start( | 586 int rv = trans->Start( |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 // Verify HttpNetworkTransaction constructor. | 684 // Verify HttpNetworkTransaction constructor. |
| 709 TEST_P(SpdyNetworkTransactionTest, Constructor) { | 685 TEST_P(SpdyNetworkTransactionTest, Constructor) { |
| 710 scoped_ptr<SpdySessionDependencies> session_deps( | 686 scoped_ptr<SpdySessionDependencies> session_deps( |
| 711 CreateSpdySessionDependencies(GetParam())); | 687 CreateSpdySessionDependencies(GetParam())); |
| 712 scoped_refptr<HttpNetworkSession> session( | 688 scoped_refptr<HttpNetworkSession> session( |
| 713 SpdySessionDependencies::SpdyCreateSession(session_deps.get())); | 689 SpdySessionDependencies::SpdyCreateSession(session_deps.get())); |
| 714 scoped_ptr<HttpTransaction> trans( | 690 scoped_ptr<HttpTransaction> trans( |
| 715 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 691 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 716 } | 692 } |
| 717 | 693 |
| 718 // TODO(akalin): Don't early-exit in the tests below for values > | |
| 719 // kProtoSPDY3. | |
| 720 | |
| 721 TEST_P(SpdyNetworkTransactionTest, Get) { | 694 TEST_P(SpdyNetworkTransactionTest, Get) { |
| 722 if (GetParam().protocol > kProtoSPDY3) | |
| 723 return; | |
| 724 | |
| 725 // Construct the request. | 695 // Construct the request. |
| 726 scoped_ptr<SpdyFrame> req( | 696 scoped_ptr<SpdyFrame> req( |
| 727 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 697 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 728 MockWrite writes[] = { CreateMockWrite(*req) }; | 698 MockWrite writes[] = { CreateMockWrite(*req) }; |
| 729 | 699 |
| 730 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 700 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 731 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 701 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 732 MockRead reads[] = { | 702 MockRead reads[] = { |
| 733 CreateMockRead(*resp), | 703 CreateMockRead(*resp), |
| 734 CreateMockRead(*body), | 704 CreateMockRead(*body), |
| 735 MockRead(ASYNC, 0, 0) // EOF | 705 MockRead(ASYNC, 0, 0) // EOF |
| 736 }; | 706 }; |
| 737 | 707 |
| 738 DelayedSocketData data(1, reads, arraysize(reads), | 708 DelayedSocketData data(1, reads, arraysize(reads), |
| 739 writes, arraysize(writes)); | 709 writes, arraysize(writes)); |
| 740 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 710 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 741 BoundNetLog(), GetParam(), NULL); | 711 BoundNetLog(), GetParam(), NULL); |
| 742 helper.RunToCompletion(&data); | 712 helper.RunToCompletion(&data); |
| 743 TransactionHelperResult out = helper.output(); | 713 TransactionHelperResult out = helper.output(); |
| 744 EXPECT_EQ(OK, out.rv); | 714 EXPECT_EQ(OK, out.rv); |
| 745 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 715 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 746 EXPECT_EQ("hello!", out.response_data); | 716 EXPECT_EQ("hello!", out.response_data); |
| 747 } | 717 } |
| 748 | 718 |
| 749 TEST_P(SpdyNetworkTransactionTest, GetAtEachPriority) { | 719 TEST_P(SpdyNetworkTransactionTest, GetAtEachPriority) { |
| 750 if (GetParam().protocol > kProtoSPDY3) | |
| 751 return; | |
| 752 | |
| 753 for (RequestPriority p = MINIMUM_PRIORITY; p < NUM_PRIORITIES; | 720 for (RequestPriority p = MINIMUM_PRIORITY; p < NUM_PRIORITIES; |
| 754 p = RequestPriority(p + 1)) { | 721 p = RequestPriority(p + 1)) { |
| 755 // Construct the request. | 722 // Construct the request. |
| 756 scoped_ptr<SpdyFrame> req( | 723 scoped_ptr<SpdyFrame> req( |
| 757 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, p, true)); | 724 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, p, true)); |
| 758 MockWrite writes[] = { CreateMockWrite(*req) }; | 725 MockWrite writes[] = { CreateMockWrite(*req) }; |
| 759 | 726 |
| 760 SpdyPriority spdy_prio = 0; | 727 SpdyPriority spdy_prio = 0; |
| 761 EXPECT_TRUE(GetSpdyPriority(spdy_util_.spdy_version(), *req, &spdy_prio)); | 728 EXPECT_TRUE(GetSpdyPriority(spdy_util_.spdy_version(), *req, &spdy_prio)); |
| 762 // this repeats the RequestPriority-->SpdyPriority mapping from | 729 // this repeats the RequestPriority-->SpdyPriority mapping from |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 // streams work properly. | 795 // streams work properly. |
| 829 | 796 |
| 830 // This can't use the TransactionHelper method, since it only | 797 // This can't use the TransactionHelper method, since it only |
| 831 // handles a single transaction, and finishes them as soon | 798 // handles a single transaction, and finishes them as soon |
| 832 // as it launches them. | 799 // as it launches them. |
| 833 | 800 |
| 834 // TODO(gavinp): create a working generalized TransactionHelper that | 801 // TODO(gavinp): create a working generalized TransactionHelper that |
| 835 // can allow multiple streams in flight. | 802 // can allow multiple streams in flight. |
| 836 | 803 |
| 837 TEST_P(SpdyNetworkTransactionTest, ThreeGets) { | 804 TEST_P(SpdyNetworkTransactionTest, ThreeGets) { |
| 838 if (GetParam().protocol > kProtoSPDY3) | |
| 839 return; | |
| 840 | |
| 841 scoped_ptr<SpdyFrame> req( | 805 scoped_ptr<SpdyFrame> req( |
| 842 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 806 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 843 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 807 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 844 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, false)); | 808 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, false)); |
| 845 scoped_ptr<SpdyFrame> fbody(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 809 scoped_ptr<SpdyFrame> fbody(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 846 | 810 |
| 847 scoped_ptr<SpdyFrame> req2( | 811 scoped_ptr<SpdyFrame> req2( |
| 848 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); | 812 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); |
| 849 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); | 813 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); |
| 850 scoped_ptr<SpdyFrame> body2(spdy_util_.ConstructSpdyBodyFrame(3, false)); | 814 scoped_ptr<SpdyFrame> body2(spdy_util_.ConstructSpdyBodyFrame(3, false)); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 out.rv = ReadTransaction(trans1.get(), &out.response_data); | 891 out.rv = ReadTransaction(trans1.get(), &out.response_data); |
| 928 helper.VerifyDataConsumed(); | 892 helper.VerifyDataConsumed(); |
| 929 EXPECT_EQ(OK, out.rv); | 893 EXPECT_EQ(OK, out.rv); |
| 930 | 894 |
| 931 EXPECT_EQ(OK, out.rv); | 895 EXPECT_EQ(OK, out.rv); |
| 932 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 896 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 933 EXPECT_EQ("hello!hello!", out.response_data); | 897 EXPECT_EQ("hello!hello!", out.response_data); |
| 934 } | 898 } |
| 935 | 899 |
| 936 TEST_P(SpdyNetworkTransactionTest, TwoGetsLateBinding) { | 900 TEST_P(SpdyNetworkTransactionTest, TwoGetsLateBinding) { |
| 937 if (GetParam().protocol > kProtoSPDY3) | |
| 938 return; | |
| 939 | |
| 940 scoped_ptr<SpdyFrame> req( | 901 scoped_ptr<SpdyFrame> req( |
| 941 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 902 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 942 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 903 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 943 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, false)); | 904 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, false)); |
| 944 scoped_ptr<SpdyFrame> fbody(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 905 scoped_ptr<SpdyFrame> fbody(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 945 | 906 |
| 946 scoped_ptr<SpdyFrame> req2( | 907 scoped_ptr<SpdyFrame> req2( |
| 947 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); | 908 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); |
| 948 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); | 909 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); |
| 949 scoped_ptr<SpdyFrame> body2(spdy_util_.ConstructSpdyBodyFrame(3, false)); | 910 scoped_ptr<SpdyFrame> body2(spdy_util_.ConstructSpdyBodyFrame(3, false)); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1017 out.response_info = *response2; | 978 out.response_info = *response2; |
| 1018 out.rv = ReadTransaction(trans2.get(), &out.response_data); | 979 out.rv = ReadTransaction(trans2.get(), &out.response_data); |
| 1019 EXPECT_EQ(OK, out.rv); | 980 EXPECT_EQ(OK, out.rv); |
| 1020 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 981 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 1021 EXPECT_EQ("hello!hello!", out.response_data); | 982 EXPECT_EQ("hello!hello!", out.response_data); |
| 1022 | 983 |
| 1023 helper.VerifyDataConsumed(); | 984 helper.VerifyDataConsumed(); |
| 1024 } | 985 } |
| 1025 | 986 |
| 1026 TEST_P(SpdyNetworkTransactionTest, TwoGetsLateBindingFromPreconnect) { | 987 TEST_P(SpdyNetworkTransactionTest, TwoGetsLateBindingFromPreconnect) { |
| 1027 if (GetParam().protocol > kProtoSPDY3) | |
| 1028 return; | |
| 1029 | |
| 1030 scoped_ptr<SpdyFrame> req( | 988 scoped_ptr<SpdyFrame> req( |
| 1031 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 989 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 1032 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 990 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 1033 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, false)); | 991 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, false)); |
| 1034 scoped_ptr<SpdyFrame> fbody(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 992 scoped_ptr<SpdyFrame> fbody(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 1035 | 993 |
| 1036 scoped_ptr<SpdyFrame> req2( | 994 scoped_ptr<SpdyFrame> req2( |
| 1037 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); | 995 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); |
| 1038 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); | 996 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); |
| 1039 scoped_ptr<SpdyFrame> body2(spdy_util_.ConstructSpdyBodyFrame(3, false)); | 997 scoped_ptr<SpdyFrame> body2(spdy_util_.ConstructSpdyBodyFrame(3, false)); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1126 | 1084 |
| 1127 helper.VerifyDataConsumed(); | 1085 helper.VerifyDataConsumed(); |
| 1128 } | 1086 } |
| 1129 | 1087 |
| 1130 // Similar to ThreeGets above, however this test adds a SETTINGS | 1088 // Similar to ThreeGets above, however this test adds a SETTINGS |
| 1131 // frame. The SETTINGS frame is read during the IO loop waiting on | 1089 // frame. The SETTINGS frame is read during the IO loop waiting on |
| 1132 // the first transaction completion, and sets a maximum concurrent | 1090 // the first transaction completion, and sets a maximum concurrent |
| 1133 // stream limit of 1. This means that our IO loop exists after the | 1091 // stream limit of 1. This means that our IO loop exists after the |
| 1134 // second transaction completes, so we can assert on read_index(). | 1092 // second transaction completes, so we can assert on read_index(). |
| 1135 TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrent) { | 1093 TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrent) { |
| 1136 if (GetParam().protocol > kProtoSPDY3) | |
| 1137 return; | |
| 1138 | |
| 1139 // Construct the request. | 1094 // Construct the request. |
| 1140 scoped_ptr<SpdyFrame> req( | 1095 scoped_ptr<SpdyFrame> req( |
| 1141 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 1096 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 1142 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 1097 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 1143 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, false)); | 1098 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, false)); |
| 1144 scoped_ptr<SpdyFrame> fbody(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 1099 scoped_ptr<SpdyFrame> fbody(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 1145 | 1100 |
| 1146 scoped_ptr<SpdyFrame> req2( | 1101 scoped_ptr<SpdyFrame> req2( |
| 1147 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); | 1102 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); |
| 1148 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); | 1103 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1262 } | 1217 } |
| 1263 EXPECT_EQ(OK, out.rv); | 1218 EXPECT_EQ(OK, out.rv); |
| 1264 } | 1219 } |
| 1265 | 1220 |
| 1266 // Similar to ThreeGetsWithMaxConcurrent above, however this test adds | 1221 // Similar to ThreeGetsWithMaxConcurrent above, however this test adds |
| 1267 // a fourth transaction. The third and fourth transactions have | 1222 // a fourth transaction. The third and fourth transactions have |
| 1268 // different data ("hello!" vs "hello!hello!") and because of the | 1223 // different data ("hello!" vs "hello!hello!") and because of the |
| 1269 // user specified priority, we expect to see them inverted in | 1224 // user specified priority, we expect to see them inverted in |
| 1270 // the response from the server. | 1225 // the response from the server. |
| 1271 TEST_P(SpdyNetworkTransactionTest, FourGetsWithMaxConcurrentPriority) { | 1226 TEST_P(SpdyNetworkTransactionTest, FourGetsWithMaxConcurrentPriority) { |
| 1272 if (GetParam().protocol > kProtoSPDY3) | |
| 1273 return; | |
| 1274 | |
| 1275 // Construct the request. | 1227 // Construct the request. |
| 1276 scoped_ptr<SpdyFrame> req( | 1228 scoped_ptr<SpdyFrame> req( |
| 1277 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 1229 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 1278 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 1230 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 1279 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, false)); | 1231 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, false)); |
| 1280 scoped_ptr<SpdyFrame> fbody(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 1232 scoped_ptr<SpdyFrame> fbody(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 1281 | 1233 |
| 1282 scoped_ptr<SpdyFrame> req2( | 1234 scoped_ptr<SpdyFrame> req2( |
| 1283 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); | 1235 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); |
| 1284 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); | 1236 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1418 EXPECT_EQ("hello!", out.response_data); | 1370 EXPECT_EQ("hello!", out.response_data); |
| 1419 helper.VerifyDataConsumed(); | 1371 helper.VerifyDataConsumed(); |
| 1420 EXPECT_EQ(OK, out.rv); | 1372 EXPECT_EQ(OK, out.rv); |
| 1421 } | 1373 } |
| 1422 | 1374 |
| 1423 // Similar to ThreeGetsMaxConcurrrent above, however, this test | 1375 // Similar to ThreeGetsMaxConcurrrent above, however, this test |
| 1424 // deletes a session in the middle of the transaction to insure | 1376 // deletes a session in the middle of the transaction to insure |
| 1425 // that we properly remove pendingcreatestream objects from | 1377 // that we properly remove pendingcreatestream objects from |
| 1426 // the spdy_session | 1378 // the spdy_session |
| 1427 TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrentDelete) { | 1379 TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrentDelete) { |
| 1428 if (GetParam().protocol > kProtoSPDY3) | |
| 1429 return; | |
| 1430 | |
| 1431 // Construct the request. | 1380 // Construct the request. |
| 1432 scoped_ptr<SpdyFrame> req( | 1381 scoped_ptr<SpdyFrame> req( |
| 1433 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 1382 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 1434 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 1383 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 1435 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, false)); | 1384 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, false)); |
| 1436 scoped_ptr<SpdyFrame> fbody(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 1385 scoped_ptr<SpdyFrame> fbody(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 1437 | 1386 |
| 1438 scoped_ptr<SpdyFrame> req2( | 1387 scoped_ptr<SpdyFrame> req2( |
| 1439 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); | 1388 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); |
| 1440 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); | 1389 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1557 HttpNetworkTransaction* transaction_; | 1506 HttpNetworkTransaction* transaction_; |
| 1558 CompletionCallback callback_; | 1507 CompletionCallback callback_; |
| 1559 }; | 1508 }; |
| 1560 | 1509 |
| 1561 } // namespace | 1510 } // namespace |
| 1562 | 1511 |
| 1563 // Similar to ThreeGetsMaxConcurrrentDelete above, however, this test | 1512 // Similar to ThreeGetsMaxConcurrrentDelete above, however, this test |
| 1564 // closes the socket while we have a pending transaction waiting for | 1513 // closes the socket while we have a pending transaction waiting for |
| 1565 // a pending stream creation. http://crbug.com/52901 | 1514 // a pending stream creation. http://crbug.com/52901 |
| 1566 TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrentSocketClose) { | 1515 TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrentSocketClose) { |
| 1567 if (GetParam().protocol > kProtoSPDY3) | |
| 1568 return; | |
| 1569 | |
| 1570 // Construct the request. | 1516 // Construct the request. |
| 1571 scoped_ptr<SpdyFrame> req( | 1517 scoped_ptr<SpdyFrame> req( |
| 1572 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 1518 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 1573 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 1519 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 1574 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, false)); | 1520 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, false)); |
| 1575 scoped_ptr<SpdyFrame> fin_body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 1521 scoped_ptr<SpdyFrame> fin_body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 1576 | 1522 |
| 1577 scoped_ptr<SpdyFrame> req2( | 1523 scoped_ptr<SpdyFrame> req2( |
| 1578 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); | 1524 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); |
| 1579 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); | 1525 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1653 out.status_line = response2->headers->GetStatusLine(); | 1599 out.status_line = response2->headers->GetStatusLine(); |
| 1654 out.response_info = *response2; | 1600 out.response_info = *response2; |
| 1655 out.rv = ReadTransaction(&trans2, &out.response_data); | 1601 out.rv = ReadTransaction(&trans2, &out.response_data); |
| 1656 EXPECT_EQ(ERR_CONNECTION_RESET, out.rv); | 1602 EXPECT_EQ(ERR_CONNECTION_RESET, out.rv); |
| 1657 | 1603 |
| 1658 helper.VerifyDataConsumed(); | 1604 helper.VerifyDataConsumed(); |
| 1659 } | 1605 } |
| 1660 | 1606 |
| 1661 // Test that a simple PUT request works. | 1607 // Test that a simple PUT request works. |
| 1662 TEST_P(SpdyNetworkTransactionTest, Put) { | 1608 TEST_P(SpdyNetworkTransactionTest, Put) { |
| 1663 if (GetParam().protocol > kProtoSPDY3) | |
| 1664 return; | |
| 1665 | |
| 1666 // Setup the request | 1609 // Setup the request |
| 1667 HttpRequestInfo request; | 1610 HttpRequestInfo request; |
| 1668 request.method = "PUT"; | 1611 request.method = "PUT"; |
| 1669 request.url = GURL("http://www.google.com/"); | 1612 request.url = GURL("http://www.google.com/"); |
| 1670 | 1613 |
| 1671 const SpdyHeaderInfo kSynStartHeader = { | 1614 const SpdyHeaderInfo kSynStartHeader = { |
| 1672 SYN_STREAM, // Kind = Syn | 1615 SYN_STREAM, // Kind = Syn |
| 1673 1, // Stream ID | 1616 1, // Stream ID |
| 1674 0, // Associated stream ID | 1617 0, // Associated stream ID |
| 1675 ConvertRequestPriorityToSpdyPriority( | 1618 ConvertRequestPriorityToSpdyPriority( |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1723 BoundNetLog(), GetParam(), NULL); | 1666 BoundNetLog(), GetParam(), NULL); |
| 1724 helper.RunToCompletion(&data); | 1667 helper.RunToCompletion(&data); |
| 1725 TransactionHelperResult out = helper.output(); | 1668 TransactionHelperResult out = helper.output(); |
| 1726 | 1669 |
| 1727 EXPECT_EQ(OK, out.rv); | 1670 EXPECT_EQ(OK, out.rv); |
| 1728 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 1671 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 1729 } | 1672 } |
| 1730 | 1673 |
| 1731 // Test that a simple HEAD request works. | 1674 // Test that a simple HEAD request works. |
| 1732 TEST_P(SpdyNetworkTransactionTest, Head) { | 1675 TEST_P(SpdyNetworkTransactionTest, Head) { |
| 1733 if (GetParam().protocol > kProtoSPDY3) | |
| 1734 return; | |
| 1735 | |
| 1736 // Setup the request | 1676 // Setup the request |
| 1737 HttpRequestInfo request; | 1677 HttpRequestInfo request; |
| 1738 request.method = "HEAD"; | 1678 request.method = "HEAD"; |
| 1739 request.url = GURL("http://www.google.com/"); | 1679 request.url = GURL("http://www.google.com/"); |
| 1740 | 1680 |
| 1741 const SpdyHeaderInfo kSynStartHeader = { | 1681 const SpdyHeaderInfo kSynStartHeader = { |
| 1742 SYN_STREAM, // Kind = Syn | 1682 SYN_STREAM, // Kind = Syn |
| 1743 1, // Stream ID | 1683 1, // Stream ID |
| 1744 0, // Associated stream ID | 1684 0, // Associated stream ID |
| 1745 ConvertRequestPriorityToSpdyPriority( | 1685 ConvertRequestPriorityToSpdyPriority( |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1794 BoundNetLog(), GetParam(), NULL); | 1734 BoundNetLog(), GetParam(), NULL); |
| 1795 helper.RunToCompletion(&data); | 1735 helper.RunToCompletion(&data); |
| 1796 TransactionHelperResult out = helper.output(); | 1736 TransactionHelperResult out = helper.output(); |
| 1797 | 1737 |
| 1798 EXPECT_EQ(OK, out.rv); | 1738 EXPECT_EQ(OK, out.rv); |
| 1799 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 1739 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 1800 } | 1740 } |
| 1801 | 1741 |
| 1802 // Test that a simple POST works. | 1742 // Test that a simple POST works. |
| 1803 TEST_P(SpdyNetworkTransactionTest, Post) { | 1743 TEST_P(SpdyNetworkTransactionTest, Post) { |
| 1804 if (GetParam().protocol > kProtoSPDY3) | |
| 1805 return; | |
| 1806 | |
| 1807 scoped_ptr<SpdyFrame> req( | 1744 scoped_ptr<SpdyFrame> req( |
| 1808 spdy_util_.ConstructSpdyPost( | 1745 spdy_util_.ConstructSpdyPost( |
| 1809 kRequestUrl, 1, kUploadDataSize, LOWEST, NULL, 0)); | 1746 kRequestUrl, 1, kUploadDataSize, LOWEST, NULL, 0)); |
| 1810 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 1747 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 1811 MockWrite writes[] = { | 1748 MockWrite writes[] = { |
| 1812 CreateMockWrite(*req), | 1749 CreateMockWrite(*req), |
| 1813 CreateMockWrite(*body), // POST upload frame | 1750 CreateMockWrite(*body), // POST upload frame |
| 1814 }; | 1751 }; |
| 1815 | 1752 |
| 1816 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); | 1753 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); |
| 1817 MockRead reads[] = { | 1754 MockRead reads[] = { |
| 1818 CreateMockRead(*resp), | 1755 CreateMockRead(*resp), |
| 1819 CreateMockRead(*body), | 1756 CreateMockRead(*body), |
| 1820 MockRead(ASYNC, 0, 0) // EOF | 1757 MockRead(ASYNC, 0, 0) // EOF |
| 1821 }; | 1758 }; |
| 1822 | 1759 |
| 1823 DelayedSocketData data(2, reads, arraysize(reads), | 1760 DelayedSocketData data(2, reads, arraysize(reads), |
| 1824 writes, arraysize(writes)); | 1761 writes, arraysize(writes)); |
| 1825 NormalSpdyTransactionHelper helper(CreatePostRequest(), DEFAULT_PRIORITY, | 1762 NormalSpdyTransactionHelper helper(CreatePostRequest(), DEFAULT_PRIORITY, |
| 1826 BoundNetLog(), GetParam(), NULL); | 1763 BoundNetLog(), GetParam(), NULL); |
| 1827 helper.RunToCompletion(&data); | 1764 helper.RunToCompletion(&data); |
| 1828 TransactionHelperResult out = helper.output(); | 1765 TransactionHelperResult out = helper.output(); |
| 1829 EXPECT_EQ(OK, out.rv); | 1766 EXPECT_EQ(OK, out.rv); |
| 1830 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 1767 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 1831 EXPECT_EQ("hello!", out.response_data); | 1768 EXPECT_EQ("hello!", out.response_data); |
| 1832 } | 1769 } |
| 1833 | 1770 |
| 1834 // Test that a POST with a file works. | 1771 // Test that a POST with a file works. |
| 1835 TEST_P(SpdyNetworkTransactionTest, FilePost) { | 1772 TEST_P(SpdyNetworkTransactionTest, FilePost) { |
| 1836 if (GetParam().protocol > kProtoSPDY3) | |
| 1837 return; | |
| 1838 | |
| 1839 scoped_ptr<SpdyFrame> req( | 1773 scoped_ptr<SpdyFrame> req( |
| 1840 spdy_util_.ConstructSpdyPost( | 1774 spdy_util_.ConstructSpdyPost( |
| 1841 kRequestUrl, 1, kUploadDataSize, LOWEST, NULL, 0)); | 1775 kRequestUrl, 1, kUploadDataSize, LOWEST, NULL, 0)); |
| 1842 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 1776 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 1843 MockWrite writes[] = { | 1777 MockWrite writes[] = { |
| 1844 CreateMockWrite(*req), | 1778 CreateMockWrite(*req), |
| 1845 CreateMockWrite(*body), // POST upload frame | 1779 CreateMockWrite(*body), // POST upload frame |
| 1846 }; | 1780 }; |
| 1847 | 1781 |
| 1848 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); | 1782 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); |
| 1849 MockRead reads[] = { | 1783 MockRead reads[] = { |
| 1850 CreateMockRead(*resp), | 1784 CreateMockRead(*resp), |
| 1851 CreateMockRead(*body), | 1785 CreateMockRead(*body), |
| 1852 MockRead(ASYNC, 0, 0) // EOF | 1786 MockRead(ASYNC, 0, 0) // EOF |
| 1853 }; | 1787 }; |
| 1854 | 1788 |
| 1855 DelayedSocketData data(2, reads, arraysize(reads), | 1789 DelayedSocketData data(2, reads, arraysize(reads), |
| 1856 writes, arraysize(writes)); | 1790 writes, arraysize(writes)); |
| 1857 NormalSpdyTransactionHelper helper(CreateFilePostRequest(), DEFAULT_PRIORITY, | 1791 NormalSpdyTransactionHelper helper(CreateFilePostRequest(), DEFAULT_PRIORITY, |
| 1858 BoundNetLog(), GetParam(), NULL); | 1792 BoundNetLog(), GetParam(), NULL); |
| 1859 helper.RunToCompletion(&data); | 1793 helper.RunToCompletion(&data); |
| 1860 TransactionHelperResult out = helper.output(); | 1794 TransactionHelperResult out = helper.output(); |
| 1861 EXPECT_EQ(OK, out.rv); | 1795 EXPECT_EQ(OK, out.rv); |
| 1862 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 1796 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 1863 EXPECT_EQ("hello!", out.response_data); | 1797 EXPECT_EQ("hello!", out.response_data); |
| 1864 } | 1798 } |
| 1865 | 1799 |
| 1866 // Test that a complex POST works. | 1800 // Test that a complex POST works. |
| 1867 TEST_P(SpdyNetworkTransactionTest, ComplexPost) { | 1801 TEST_P(SpdyNetworkTransactionTest, ComplexPost) { |
| 1868 if (GetParam().protocol > kProtoSPDY3) | |
| 1869 return; | |
| 1870 | |
| 1871 scoped_ptr<SpdyFrame> req( | 1802 scoped_ptr<SpdyFrame> req( |
| 1872 spdy_util_.ConstructSpdyPost( | 1803 spdy_util_.ConstructSpdyPost( |
| 1873 kRequestUrl, 1, kUploadDataSize, LOWEST, NULL, 0)); | 1804 kRequestUrl, 1, kUploadDataSize, LOWEST, NULL, 0)); |
| 1874 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 1805 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 1875 MockWrite writes[] = { | 1806 MockWrite writes[] = { |
| 1876 CreateMockWrite(*req), | 1807 CreateMockWrite(*req), |
| 1877 CreateMockWrite(*body), // POST upload frame | 1808 CreateMockWrite(*body), // POST upload frame |
| 1878 }; | 1809 }; |
| 1879 | 1810 |
| 1880 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); | 1811 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1891 BoundNetLog(), GetParam(), NULL); | 1822 BoundNetLog(), GetParam(), NULL); |
| 1892 helper.RunToCompletion(&data); | 1823 helper.RunToCompletion(&data); |
| 1893 TransactionHelperResult out = helper.output(); | 1824 TransactionHelperResult out = helper.output(); |
| 1894 EXPECT_EQ(OK, out.rv); | 1825 EXPECT_EQ(OK, out.rv); |
| 1895 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 1826 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 1896 EXPECT_EQ("hello!", out.response_data); | 1827 EXPECT_EQ("hello!", out.response_data); |
| 1897 } | 1828 } |
| 1898 | 1829 |
| 1899 // Test that a chunked POST works. | 1830 // Test that a chunked POST works. |
| 1900 TEST_P(SpdyNetworkTransactionTest, ChunkedPost) { | 1831 TEST_P(SpdyNetworkTransactionTest, ChunkedPost) { |
| 1901 if (GetParam().protocol > kProtoSPDY3) | |
| 1902 return; | |
| 1903 | |
| 1904 scoped_ptr<SpdyFrame> req(spdy_util_.ConstructChunkedSpdyPost(NULL, 0)); | 1832 scoped_ptr<SpdyFrame> req(spdy_util_.ConstructChunkedSpdyPost(NULL, 0)); |
| 1905 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 1833 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 1906 MockWrite writes[] = { | 1834 MockWrite writes[] = { |
| 1907 CreateMockWrite(*req), | 1835 CreateMockWrite(*req), |
| 1908 CreateMockWrite(*body), | 1836 CreateMockWrite(*body), |
| 1909 }; | 1837 }; |
| 1910 | 1838 |
| 1911 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); | 1839 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); |
| 1912 MockRead reads[] = { | 1840 MockRead reads[] = { |
| 1913 CreateMockRead(*resp), | 1841 CreateMockRead(*resp), |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1930 | 1858 |
| 1931 helper.RunToCompletion(&data); | 1859 helper.RunToCompletion(&data); |
| 1932 TransactionHelperResult out = helper.output(); | 1860 TransactionHelperResult out = helper.output(); |
| 1933 EXPECT_EQ(OK, out.rv); | 1861 EXPECT_EQ(OK, out.rv); |
| 1934 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 1862 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 1935 EXPECT_EQ(kUploadData, out.response_data); | 1863 EXPECT_EQ(kUploadData, out.response_data); |
| 1936 } | 1864 } |
| 1937 | 1865 |
| 1938 // Test that a chunked POST works with chunks appended after transaction starts. | 1866 // Test that a chunked POST works with chunks appended after transaction starts. |
| 1939 TEST_P(SpdyNetworkTransactionTest, DelayedChunkedPost) { | 1867 TEST_P(SpdyNetworkTransactionTest, DelayedChunkedPost) { |
| 1940 if (GetParam().protocol > kProtoSPDY3) | |
| 1941 return; | |
| 1942 | |
| 1943 scoped_ptr<SpdyFrame> req(spdy_util_.ConstructChunkedSpdyPost(NULL, 0)); | 1868 scoped_ptr<SpdyFrame> req(spdy_util_.ConstructChunkedSpdyPost(NULL, 0)); |
| 1944 scoped_ptr<SpdyFrame> chunk1(spdy_util_.ConstructSpdyBodyFrame(1, false)); | 1869 scoped_ptr<SpdyFrame> chunk1(spdy_util_.ConstructSpdyBodyFrame(1, false)); |
| 1945 scoped_ptr<SpdyFrame> chunk2(spdy_util_.ConstructSpdyBodyFrame(1, false)); | 1870 scoped_ptr<SpdyFrame> chunk2(spdy_util_.ConstructSpdyBodyFrame(1, false)); |
| 1946 scoped_ptr<SpdyFrame> chunk3(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 1871 scoped_ptr<SpdyFrame> chunk3(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 1947 MockWrite writes[] = { | 1872 MockWrite writes[] = { |
| 1948 CreateMockWrite(*req), | 1873 CreateMockWrite(*req), |
| 1949 CreateMockWrite(*chunk1), | 1874 CreateMockWrite(*chunk1), |
| 1950 CreateMockWrite(*chunk2), | 1875 CreateMockWrite(*chunk2), |
| 1951 CreateMockWrite(*chunk3), | 1876 CreateMockWrite(*chunk3), |
| 1952 }; | 1877 }; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1989 expected_response += kUploadData; | 1914 expected_response += kUploadData; |
| 1990 | 1915 |
| 1991 TransactionHelperResult out = helper.output(); | 1916 TransactionHelperResult out = helper.output(); |
| 1992 EXPECT_EQ(OK, out.rv); | 1917 EXPECT_EQ(OK, out.rv); |
| 1993 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 1918 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 1994 EXPECT_EQ(expected_response, out.response_data); | 1919 EXPECT_EQ(expected_response, out.response_data); |
| 1995 } | 1920 } |
| 1996 | 1921 |
| 1997 // Test that a POST without any post data works. | 1922 // Test that a POST without any post data works. |
| 1998 TEST_P(SpdyNetworkTransactionTest, NullPost) { | 1923 TEST_P(SpdyNetworkTransactionTest, NullPost) { |
| 1999 if (GetParam().protocol > kProtoSPDY3) | |
| 2000 return; | |
| 2001 | |
| 2002 // Setup the request | 1924 // Setup the request |
| 2003 HttpRequestInfo request; | 1925 HttpRequestInfo request; |
| 2004 request.method = "POST"; | 1926 request.method = "POST"; |
| 2005 request.url = GURL(kRequestUrl); | 1927 request.url = GURL(kRequestUrl); |
| 2006 // Create an empty UploadData. | 1928 // Create an empty UploadData. |
| 2007 request.upload_data_stream = NULL; | 1929 request.upload_data_stream = NULL; |
| 2008 | 1930 |
| 2009 // When request.upload_data_stream is NULL for post, content-length is | 1931 // When request.upload_data_stream is NULL for post, content-length is |
| 2010 // expected to be 0. | 1932 // expected to be 0. |
| 2011 scoped_ptr<SpdyFrame> req( | 1933 scoped_ptr<SpdyFrame> req( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2031 BoundNetLog(), GetParam(), NULL); | 1953 BoundNetLog(), GetParam(), NULL); |
| 2032 helper.RunToCompletion(&data); | 1954 helper.RunToCompletion(&data); |
| 2033 TransactionHelperResult out = helper.output(); | 1955 TransactionHelperResult out = helper.output(); |
| 2034 EXPECT_EQ(OK, out.rv); | 1956 EXPECT_EQ(OK, out.rv); |
| 2035 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 1957 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 2036 EXPECT_EQ("hello!", out.response_data); | 1958 EXPECT_EQ("hello!", out.response_data); |
| 2037 } | 1959 } |
| 2038 | 1960 |
| 2039 // Test that a simple POST works. | 1961 // Test that a simple POST works. |
| 2040 TEST_P(SpdyNetworkTransactionTest, EmptyPost) { | 1962 TEST_P(SpdyNetworkTransactionTest, EmptyPost) { |
| 2041 if (GetParam().protocol > kProtoSPDY3) | |
| 2042 return; | |
| 2043 | |
| 2044 // Create an empty UploadDataStream. | 1963 // Create an empty UploadDataStream. |
| 2045 ScopedVector<UploadElementReader> element_readers; | 1964 ScopedVector<UploadElementReader> element_readers; |
| 2046 UploadDataStream stream(&element_readers, 0); | 1965 UploadDataStream stream(&element_readers, 0); |
| 2047 | 1966 |
| 2048 // Setup the request | 1967 // Setup the request |
| 2049 HttpRequestInfo request; | 1968 HttpRequestInfo request; |
| 2050 request.method = "POST"; | 1969 request.method = "POST"; |
| 2051 request.url = GURL(kRequestUrl); | 1970 request.url = GURL(kRequestUrl); |
| 2052 request.upload_data_stream = &stream; | 1971 request.upload_data_stream = &stream; |
| 2053 | 1972 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2075 BoundNetLog(), GetParam(), NULL); | 1994 BoundNetLog(), GetParam(), NULL); |
| 2076 helper.RunToCompletion(&data); | 1995 helper.RunToCompletion(&data); |
| 2077 TransactionHelperResult out = helper.output(); | 1996 TransactionHelperResult out = helper.output(); |
| 2078 EXPECT_EQ(OK, out.rv); | 1997 EXPECT_EQ(OK, out.rv); |
| 2079 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 1998 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 2080 EXPECT_EQ("hello!", out.response_data); | 1999 EXPECT_EQ("hello!", out.response_data); |
| 2081 } | 2000 } |
| 2082 | 2001 |
| 2083 // While we're doing a post, the server sends back a SYN_REPLY. | 2002 // While we're doing a post, the server sends back a SYN_REPLY. |
| 2084 TEST_P(SpdyNetworkTransactionTest, PostWithEarlySynReply) { | 2003 TEST_P(SpdyNetworkTransactionTest, PostWithEarlySynReply) { |
| 2085 if (GetParam().protocol > kProtoSPDY3) | |
| 2086 return; | |
| 2087 | |
| 2088 static const char upload[] = { "hello!" }; | 2004 static const char upload[] = { "hello!" }; |
| 2089 ScopedVector<UploadElementReader> element_readers; | 2005 ScopedVector<UploadElementReader> element_readers; |
| 2090 element_readers.push_back( | 2006 element_readers.push_back( |
| 2091 new UploadBytesElementReader(upload, sizeof(upload))); | 2007 new UploadBytesElementReader(upload, sizeof(upload))); |
| 2092 UploadDataStream stream(&element_readers, 0); | 2008 UploadDataStream stream(&element_readers, 0); |
| 2093 | 2009 |
| 2094 // Setup the request | 2010 // Setup the request |
| 2095 HttpRequestInfo request; | 2011 HttpRequestInfo request; |
| 2096 request.method = "POST"; | 2012 request.method = "POST"; |
| 2097 request.url = GURL(kRequestUrl); | 2013 request.url = GURL(kRequestUrl); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2131 data.RunFor(2); | 2047 data.RunFor(2); |
| 2132 rv = callback.WaitForResult(); | 2048 rv = callback.WaitForResult(); |
| 2133 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, rv); | 2049 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, rv); |
| 2134 data.RunFor(1); | 2050 data.RunFor(1); |
| 2135 } | 2051 } |
| 2136 | 2052 |
| 2137 // The client upon cancellation tries to send a RST_STREAM frame. The mock | 2053 // The client upon cancellation tries to send a RST_STREAM frame. The mock |
| 2138 // socket causes the TCP write to return zero. This test checks that the client | 2054 // socket causes the TCP write to return zero. This test checks that the client |
| 2139 // tries to queue up the RST_STREAM frame again. | 2055 // tries to queue up the RST_STREAM frame again. |
| 2140 TEST_P(SpdyNetworkTransactionTest, SocketWriteReturnsZero) { | 2056 TEST_P(SpdyNetworkTransactionTest, SocketWriteReturnsZero) { |
| 2141 if (GetParam().protocol > kProtoSPDY3) | |
| 2142 return; | |
| 2143 | |
| 2144 scoped_ptr<SpdyFrame> req( | 2057 scoped_ptr<SpdyFrame> req( |
| 2145 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 2058 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 2146 scoped_ptr<SpdyFrame> rst( | 2059 scoped_ptr<SpdyFrame> rst( |
| 2147 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); | 2060 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); |
| 2148 MockWrite writes[] = { | 2061 MockWrite writes[] = { |
| 2149 CreateMockWrite(*req.get(), 0, SYNCHRONOUS), | 2062 CreateMockWrite(*req.get(), 0, SYNCHRONOUS), |
| 2150 MockWrite(SYNCHRONOUS, 0, 0, 2), | 2063 MockWrite(SYNCHRONOUS, 0, 0, 2), |
| 2151 CreateMockWrite(*rst.get(), 3, SYNCHRONOUS), | 2064 CreateMockWrite(*rst.get(), 3, SYNCHRONOUS), |
| 2152 }; | 2065 }; |
| 2153 | 2066 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2175 data.Run(); | 2088 data.Run(); |
| 2176 helper.ResetTrans(); | 2089 helper.ResetTrans(); |
| 2177 data.SetStop(20); | 2090 data.SetStop(20); |
| 2178 data.Run(); | 2091 data.Run(); |
| 2179 | 2092 |
| 2180 helper.VerifyDataConsumed(); | 2093 helper.VerifyDataConsumed(); |
| 2181 } | 2094 } |
| 2182 | 2095 |
| 2183 // Test that the transaction doesn't crash when we don't have a reply. | 2096 // Test that the transaction doesn't crash when we don't have a reply. |
| 2184 TEST_P(SpdyNetworkTransactionTest, ResponseWithoutSynReply) { | 2097 TEST_P(SpdyNetworkTransactionTest, ResponseWithoutSynReply) { |
| 2185 if (GetParam().protocol > kProtoSPDY3) | |
| 2186 return; | |
| 2187 | |
| 2188 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 2098 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 2189 MockRead reads[] = { | 2099 MockRead reads[] = { |
| 2190 CreateMockRead(*body), | 2100 CreateMockRead(*body), |
| 2191 MockRead(ASYNC, 0, 0) // EOF | 2101 MockRead(ASYNC, 0, 0) // EOF |
| 2192 }; | 2102 }; |
| 2193 | 2103 |
| 2194 DelayedSocketData data(1, reads, arraysize(reads), NULL, 0); | 2104 DelayedSocketData data(1, reads, arraysize(reads), NULL, 0); |
| 2195 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 2105 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 2196 BoundNetLog(), GetParam(), NULL); | 2106 BoundNetLog(), GetParam(), NULL); |
| 2197 helper.RunToCompletion(&data); | 2107 helper.RunToCompletion(&data); |
| 2198 TransactionHelperResult out = helper.output(); | 2108 TransactionHelperResult out = helper.output(); |
| 2199 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); | 2109 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); |
| 2200 } | 2110 } |
| 2201 | 2111 |
| 2202 // Test that the transaction doesn't crash when we get two replies on the same | 2112 // Test that the transaction doesn't crash when we get two replies on the same |
| 2203 // stream ID. See http://crbug.com/45639. | 2113 // stream ID. See http://crbug.com/45639. |
| 2204 TEST_P(SpdyNetworkTransactionTest, ResponseWithTwoSynReplies) { | 2114 TEST_P(SpdyNetworkTransactionTest, ResponseWithTwoSynReplies) { |
| 2205 if (GetParam().protocol > kProtoSPDY3) | |
| 2206 return; | |
| 2207 | |
| 2208 scoped_ptr<SpdyFrame> req( | 2115 scoped_ptr<SpdyFrame> req( |
| 2209 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 2116 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 2210 scoped_ptr<SpdyFrame> rst( | 2117 scoped_ptr<SpdyFrame> rst( |
| 2211 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_STREAM_IN_USE)); | 2118 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_STREAM_IN_USE)); |
| 2212 MockWrite writes[] = { | 2119 MockWrite writes[] = { |
| 2213 CreateMockWrite(*req), | 2120 CreateMockWrite(*req), |
| 2214 CreateMockWrite(*rst), | 2121 CreateMockWrite(*rst), |
| 2215 }; | 2122 }; |
| 2216 | 2123 |
| 2217 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 2124 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2265 // enough number of WINDOW_UPDATEs to finish the first read and cause a | 2172 // enough number of WINDOW_UPDATEs to finish the first read and cause a |
| 2266 // write, leading to a complete write of request body; after that we send | 2173 // write, leading to a complete write of request body; after that we send |
| 2267 // a reply with a body, to cause a graceful shutdown. | 2174 // a reply with a body, to cause a graceful shutdown. |
| 2268 | 2175 |
| 2269 // TODO(agayev): develop a socket data provider where both, reads and | 2176 // TODO(agayev): develop a socket data provider where both, reads and |
| 2270 // writes are ordered so that writing tests like these are easy and rewrite | 2177 // writes are ordered so that writing tests like these are easy and rewrite |
| 2271 // all these tests using it. Right now we are working around the | 2178 // all these tests using it. Right now we are working around the |
| 2272 // limitations as described above and it's not deterministic, tests may | 2179 // limitations as described above and it's not deterministic, tests may |
| 2273 // fail under specific circumstances. | 2180 // fail under specific circumstances. |
| 2274 TEST_P(SpdyNetworkTransactionTest, WindowUpdateReceived) { | 2181 TEST_P(SpdyNetworkTransactionTest, WindowUpdateReceived) { |
| 2275 if (GetParam().protocol != kProtoSPDY3) | 2182 if (GetParam().protocol < kProtoSPDY3) |
| 2276 return; | 2183 return; |
| 2277 | 2184 |
| 2278 static int kFrameCount = 2; | 2185 static int kFrameCount = 2; |
| 2279 scoped_ptr<std::string> content( | 2186 scoped_ptr<std::string> content( |
| 2280 new std::string(kMaxSpdyFrameChunkSize, 'a')); | 2187 new std::string(kMaxSpdyFrameChunkSize, 'a')); |
| 2281 scoped_ptr<SpdyFrame> req(spdy_util_.ConstructSpdyPost( | 2188 scoped_ptr<SpdyFrame> req(spdy_util_.ConstructSpdyPost( |
| 2282 kRequestUrl, 1, kMaxSpdyFrameChunkSize * kFrameCount, LOWEST, NULL, 0)); | 2189 kRequestUrl, 1, kMaxSpdyFrameChunkSize * kFrameCount, LOWEST, NULL, 0)); |
| 2283 scoped_ptr<SpdyFrame> body( | 2190 scoped_ptr<SpdyFrame> body( |
| 2284 spdy_util_.ConstructSpdyBodyFrame( | 2191 spdy_util_.ConstructSpdyBodyFrame( |
| 2285 1, content->c_str(), content->size(), false)); | 2192 1, content->c_str(), content->size(), false)); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2356 | 2263 |
| 2357 rv = callback.WaitForResult(); | 2264 rv = callback.WaitForResult(); |
| 2358 EXPECT_EQ(OK, rv); | 2265 EXPECT_EQ(OK, rv); |
| 2359 | 2266 |
| 2360 helper.VerifyDataConsumed(); | 2267 helper.VerifyDataConsumed(); |
| 2361 } | 2268 } |
| 2362 | 2269 |
| 2363 // Test that received data frames and sent WINDOW_UPDATE frames change | 2270 // Test that received data frames and sent WINDOW_UPDATE frames change |
| 2364 // the recv_window_size_ correctly. | 2271 // the recv_window_size_ correctly. |
| 2365 TEST_P(SpdyNetworkTransactionTest, WindowUpdateSent) { | 2272 TEST_P(SpdyNetworkTransactionTest, WindowUpdateSent) { |
| 2366 if (GetParam().protocol != kProtoSPDY3) | 2273 if (GetParam().protocol < kProtoSPDY3) |
| 2367 return; | 2274 return; |
| 2368 | 2275 |
| 2369 // Set the data in the body frame large enough to trigger sending a | 2276 // Set the data in the body frame large enough to trigger sending a |
| 2370 // WINDOW_UPDATE by the stream. | 2277 // WINDOW_UPDATE by the stream. |
| 2371 const std::string body_data(kSpdyStreamInitialWindowSize / 2 + 1, 'x'); | 2278 const std::string body_data(kSpdyStreamInitialWindowSize / 2 + 1, 'x'); |
| 2372 | 2279 |
| 2373 scoped_ptr<SpdyFrame> req( | 2280 scoped_ptr<SpdyFrame> req( |
| 2374 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 2281 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 2282 scoped_ptr<SpdyFrame> session_window_update( |
| 2283 spdy_util_.ConstructSpdyWindowUpdate(0, body_data.size())); |
| 2375 scoped_ptr<SpdyFrame> window_update( | 2284 scoped_ptr<SpdyFrame> window_update( |
| 2376 spdy_util_.ConstructSpdyWindowUpdate(1, body_data.size())); | 2285 spdy_util_.ConstructSpdyWindowUpdate(1, body_data.size())); |
| 2377 | 2286 |
| 2378 MockWrite writes[] = { | 2287 std::vector<MockWrite> writes; |
| 2379 CreateMockWrite(*req), | 2288 writes.push_back(CreateMockWrite(*req)); |
| 2380 CreateMockWrite(*window_update), | 2289 if (GetParam().protocol >= kProtoSPDY31) |
| 2381 }; | 2290 writes.push_back(CreateMockWrite(*session_window_update)); |
| 2291 writes.push_back(CreateMockWrite(*window_update)); |
| 2382 | 2292 |
| 2383 scoped_ptr<SpdyFrame> resp( | 2293 scoped_ptr<SpdyFrame> resp( |
| 2384 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 2294 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 2385 scoped_ptr<SpdyFrame> body_no_fin( | 2295 scoped_ptr<SpdyFrame> body_no_fin( |
| 2386 spdy_util_.ConstructSpdyBodyFrame( | 2296 spdy_util_.ConstructSpdyBodyFrame( |
| 2387 1, body_data.data(), body_data.size(), false)); | 2297 1, body_data.data(), body_data.size(), false)); |
| 2388 scoped_ptr<SpdyFrame> body_fin( | 2298 scoped_ptr<SpdyFrame> body_fin( |
| 2389 spdy_util_.ConstructSpdyBodyFrame(1, NULL, 0, true)); | 2299 spdy_util_.ConstructSpdyBodyFrame(1, NULL, 0, true)); |
| 2390 MockRead reads[] = { | 2300 MockRead reads[] = { |
| 2391 CreateMockRead(*resp), | 2301 CreateMockRead(*resp), |
| 2392 CreateMockRead(*body_no_fin), | 2302 CreateMockRead(*body_no_fin), |
| 2393 MockRead(ASYNC, ERR_IO_PENDING, 0), // Force a pause | 2303 MockRead(ASYNC, ERR_IO_PENDING, 0), // Force a pause |
| 2394 CreateMockRead(*body_fin), | 2304 CreateMockRead(*body_fin), |
| 2395 MockRead(ASYNC, ERR_IO_PENDING, 0), // Force a pause | 2305 MockRead(ASYNC, ERR_IO_PENDING, 0), // Force a pause |
| 2396 MockRead(ASYNC, 0, 0) // EOF | 2306 MockRead(ASYNC, 0, 0) // EOF |
| 2397 }; | 2307 }; |
| 2398 | 2308 |
| 2399 DelayedSocketData data(1, reads, arraysize(reads), | 2309 DelayedSocketData data(1, reads, arraysize(reads), |
| 2400 writes, arraysize(writes)); | 2310 vector_as_array(&writes), writes.size()); |
| 2401 | 2311 |
| 2402 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 2312 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 2403 BoundNetLog(), GetParam(), NULL); | 2313 BoundNetLog(), GetParam(), NULL); |
| 2404 helper.AddData(&data); | 2314 helper.AddData(&data); |
| 2405 helper.RunPreTestSetup(); | 2315 helper.RunPreTestSetup(); |
| 2406 HttpNetworkTransaction* trans = helper.trans(); | 2316 HttpNetworkTransaction* trans = helper.trans(); |
| 2407 | 2317 |
| 2408 TestCompletionCallback callback; | 2318 TestCompletionCallback callback; |
| 2409 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); | 2319 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); |
| 2410 | 2320 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2443 base::MessageLoop::current()->RunUntilIdle(); | 2353 base::MessageLoop::current()->RunUntilIdle(); |
| 2444 | 2354 |
| 2445 // Read EOF. | 2355 // Read EOF. |
| 2446 data.CompleteRead(); | 2356 data.CompleteRead(); |
| 2447 | 2357 |
| 2448 helper.VerifyDataConsumed(); | 2358 helper.VerifyDataConsumed(); |
| 2449 } | 2359 } |
| 2450 | 2360 |
| 2451 // Test that WINDOW_UPDATE frame causing overflow is handled correctly. | 2361 // Test that WINDOW_UPDATE frame causing overflow is handled correctly. |
| 2452 TEST_P(SpdyNetworkTransactionTest, WindowUpdateOverflow) { | 2362 TEST_P(SpdyNetworkTransactionTest, WindowUpdateOverflow) { |
| 2453 if (GetParam().protocol != kProtoSPDY3) | 2363 if (GetParam().protocol < kProtoSPDY3) |
| 2454 return; | 2364 return; |
| 2455 | 2365 |
| 2456 // Number of full frames we hope to write (but will not, used to | 2366 // Number of full frames we hope to write (but will not, used to |
| 2457 // set content-length header correctly) | 2367 // set content-length header correctly) |
| 2458 static int kFrameCount = 3; | 2368 static int kFrameCount = 3; |
| 2459 | 2369 |
| 2460 scoped_ptr<std::string> content( | 2370 scoped_ptr<std::string> content( |
| 2461 new std::string(kMaxSpdyFrameChunkSize, 'a')); | 2371 new std::string(kMaxSpdyFrameChunkSize, 'a')); |
| 2462 scoped_ptr<SpdyFrame> req(spdy_util_.ConstructSpdyPost( | 2372 scoped_ptr<SpdyFrame> req(spdy_util_.ConstructSpdyPost( |
| 2463 kRequestUrl, 1, kMaxSpdyFrameChunkSize * kFrameCount, LOWEST, NULL, 0)); | 2373 kRequestUrl, 1, kMaxSpdyFrameChunkSize * kFrameCount, LOWEST, NULL, 0)); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2525 // also contains a FIN flag. DelayedSocketData is used to enforce all | 2435 // also contains a FIN flag. DelayedSocketData is used to enforce all |
| 2526 // writes go through before a read could happen. However, the last frame | 2436 // writes go through before a read could happen. However, the last frame |
| 2527 // ("hello!") is not supposed to go through since by the time its turn | 2437 // ("hello!") is not supposed to go through since by the time its turn |
| 2528 // arrives, window size is 0. At this point MessageLoop::Run() called via | 2438 // arrives, window size is 0. At this point MessageLoop::Run() called via |
| 2529 // callback would block. Therefore we call MessageLoop::RunUntilIdle() | 2439 // callback would block. Therefore we call MessageLoop::RunUntilIdle() |
| 2530 // which returns after performing all possible writes. We use DCHECKS to | 2440 // which returns after performing all possible writes. We use DCHECKS to |
| 2531 // ensure that last data frame is still there and stream has stalled. | 2441 // ensure that last data frame is still there and stream has stalled. |
| 2532 // After that, next read is artifically enforced, which causes a | 2442 // After that, next read is artifically enforced, which causes a |
| 2533 // WINDOW_UPDATE to be read and I/O process resumes. | 2443 // WINDOW_UPDATE to be read and I/O process resumes. |
| 2534 TEST_P(SpdyNetworkTransactionTest, FlowControlStallResume) { | 2444 TEST_P(SpdyNetworkTransactionTest, FlowControlStallResume) { |
| 2535 if (GetParam().protocol != kProtoSPDY3) | 2445 if (GetParam().protocol < kProtoSPDY3) |
| 2536 return; | 2446 return; |
| 2537 | 2447 |
| 2538 // Number of frames we need to send to zero out the window size: data | 2448 // Number of frames we need to send to zero out the window size: data |
| 2539 // frames plus SYN_STREAM plus the last data frame; also we need another | 2449 // frames plus SYN_STREAM plus the last data frame; also we need another |
| 2540 // data frame that we will send once the WINDOW_UPDATE is received, | 2450 // data frame that we will send once the WINDOW_UPDATE is received, |
| 2541 // therefore +3. | 2451 // therefore +3. |
| 2542 size_t num_writes = kSpdyStreamInitialWindowSize / kMaxSpdyFrameChunkSize + 3; | 2452 size_t num_writes = kSpdyStreamInitialWindowSize / kMaxSpdyFrameChunkSize + 3; |
| 2543 | 2453 |
| 2544 // Calculate last frame's size; 0 size data frame is legal. | 2454 // Calculate last frame's size; 0 size data frame is legal. |
| 2545 size_t last_frame_size = | 2455 size_t last_frame_size = |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2569 scoped_ptr<MockWrite[]> writes(new MockWrite[num_writes]); | 2479 scoped_ptr<MockWrite[]> writes(new MockWrite[num_writes]); |
| 2570 size_t i = 0; | 2480 size_t i = 0; |
| 2571 writes[i] = CreateMockWrite(*req); | 2481 writes[i] = CreateMockWrite(*req); |
| 2572 for (i = 1; i < num_writes - 2; i++) | 2482 for (i = 1; i < num_writes - 2; i++) |
| 2573 writes[i] = CreateMockWrite(*body1); | 2483 writes[i] = CreateMockWrite(*body1); |
| 2574 writes[i++] = CreateMockWrite(*body2); | 2484 writes[i++] = CreateMockWrite(*body2); |
| 2575 writes[i] = CreateMockWrite(*body3); | 2485 writes[i] = CreateMockWrite(*body3); |
| 2576 | 2486 |
| 2577 // Construct read frame, give enough space to upload the rest of the | 2487 // Construct read frame, give enough space to upload the rest of the |
| 2578 // data. | 2488 // data. |
| 2489 scoped_ptr<SpdyFrame> session_window_update( |
| 2490 spdy_util_.ConstructSpdyWindowUpdate(0, kUploadDataSize)); |
| 2579 scoped_ptr<SpdyFrame> window_update( | 2491 scoped_ptr<SpdyFrame> window_update( |
| 2580 spdy_util_.ConstructSpdyWindowUpdate(1, kUploadDataSize)); | 2492 spdy_util_.ConstructSpdyWindowUpdate(1, kUploadDataSize)); |
| 2581 scoped_ptr<SpdyFrame> reply(spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); | 2493 scoped_ptr<SpdyFrame> reply(spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); |
| 2582 MockRead reads[] = { | 2494 MockRead reads[] = { |
| 2495 CreateMockRead(*session_window_update), |
| 2496 CreateMockRead(*session_window_update), |
| 2583 CreateMockRead(*window_update), | 2497 CreateMockRead(*window_update), |
| 2584 CreateMockRead(*window_update), | 2498 CreateMockRead(*window_update), |
| 2585 CreateMockRead(*reply), | 2499 CreateMockRead(*reply), |
| 2586 CreateMockRead(*body2), | 2500 CreateMockRead(*body2), |
| 2587 CreateMockRead(*body3), | 2501 CreateMockRead(*body3), |
| 2588 MockRead(ASYNC, 0, 0) // EOF | 2502 MockRead(ASYNC, 0, 0) // EOF |
| 2589 }; | 2503 }; |
| 2590 | 2504 |
| 2505 // Skip the session window updates unless we're using SPDY/3.1 and |
| 2506 // above. |
| 2507 size_t read_offset = (GetParam().protocol >= kProtoSPDY31) ? 0 : 2; |
| 2508 size_t num_reads = arraysize(reads) - read_offset; |
| 2509 |
| 2591 // Force all writes to happen before any read, last write will not | 2510 // Force all writes to happen before any read, last write will not |
| 2592 // actually queue a frame, due to window size being 0. | 2511 // actually queue a frame, due to window size being 0. |
| 2593 DelayedSocketData data(num_writes, reads, arraysize(reads), | 2512 DelayedSocketData data(num_writes, reads + read_offset, num_reads, |
| 2594 writes.get(), num_writes); | 2513 writes.get(), num_writes); |
| 2595 | 2514 |
| 2596 ScopedVector<UploadElementReader> element_readers; | 2515 ScopedVector<UploadElementReader> element_readers; |
| 2597 std::string upload_data_string(kSpdyStreamInitialWindowSize, 'a'); | 2516 std::string upload_data_string(kSpdyStreamInitialWindowSize, 'a'); |
| 2598 upload_data_string.append(kUploadData, kUploadDataSize); | 2517 upload_data_string.append(kUploadData, kUploadDataSize); |
| 2599 element_readers.push_back(new UploadBytesElementReader( | 2518 element_readers.push_back(new UploadBytesElementReader( |
| 2600 upload_data_string.c_str(), upload_data_string.size())); | 2519 upload_data_string.c_str(), upload_data_string.size())); |
| 2601 UploadDataStream upload_data_stream(&element_readers, 0); | 2520 UploadDataStream upload_data_stream(&element_readers, 0); |
| 2602 | 2521 |
| 2603 HttpRequestInfo request; | 2522 HttpRequestInfo request; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2630 EXPECT_TRUE(stream->stream()->send_stalled_by_flow_control()); | 2549 EXPECT_TRUE(stream->stream()->send_stalled_by_flow_control()); |
| 2631 | 2550 |
| 2632 data.ForceNextRead(); // Read in WINDOW_UPDATE frame. | 2551 data.ForceNextRead(); // Read in WINDOW_UPDATE frame. |
| 2633 rv = callback.WaitForResult(); | 2552 rv = callback.WaitForResult(); |
| 2634 helper.VerifyDataConsumed(); | 2553 helper.VerifyDataConsumed(); |
| 2635 } | 2554 } |
| 2636 | 2555 |
| 2637 // Test we correctly handle the case where the SETTINGS frame results in | 2556 // Test we correctly handle the case where the SETTINGS frame results in |
| 2638 // unstalling the send window. | 2557 // unstalling the send window. |
| 2639 TEST_P(SpdyNetworkTransactionTest, FlowControlStallResumeAfterSettings) { | 2558 TEST_P(SpdyNetworkTransactionTest, FlowControlStallResumeAfterSettings) { |
| 2640 if (GetParam().protocol != kProtoSPDY3) | 2559 if (GetParam().protocol < kProtoSPDY3) |
| 2641 return; | 2560 return; |
| 2642 | 2561 |
| 2643 // Number of frames we need to send to zero out the window size: data | 2562 // Number of frames we need to send to zero out the window size: data |
| 2644 // frames plus SYN_STREAM plus the last data frame; also we need another | 2563 // frames plus SYN_STREAM plus the last data frame; also we need another |
| 2645 // data frame that we will send once the SETTING is received, therefore +3. | 2564 // data frame that we will send once the SETTING is received, therefore +3. |
| 2646 size_t num_writes = kSpdyStreamInitialWindowSize / kMaxSpdyFrameChunkSize + 3; | 2565 size_t num_writes = kSpdyStreamInitialWindowSize / kMaxSpdyFrameChunkSize + 3; |
| 2647 | 2566 |
| 2648 // Calculate last frame's size; 0 size data frame is legal. | 2567 // Calculate last frame's size; 0 size data frame is legal. |
| 2649 size_t last_frame_size = | 2568 size_t last_frame_size = |
| 2650 kSpdyStreamInitialWindowSize % kMaxSpdyFrameChunkSize; | 2569 kSpdyStreamInitialWindowSize % kMaxSpdyFrameChunkSize; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2682 // rest of the data. | 2601 // rest of the data. |
| 2683 SettingsMap settings; | 2602 SettingsMap settings; |
| 2684 settings[SETTINGS_INITIAL_WINDOW_SIZE] = | 2603 settings[SETTINGS_INITIAL_WINDOW_SIZE] = |
| 2685 SettingsFlagsAndValue( | 2604 SettingsFlagsAndValue( |
| 2686 SETTINGS_FLAG_NONE, kSpdyStreamInitialWindowSize * 2); | 2605 SETTINGS_FLAG_NONE, kSpdyStreamInitialWindowSize * 2); |
| 2687 scoped_ptr<SpdyFrame> settings_frame_large( | 2606 scoped_ptr<SpdyFrame> settings_frame_large( |
| 2688 spdy_util_.ConstructSpdySettings(settings)); | 2607 spdy_util_.ConstructSpdySettings(settings)); |
| 2689 | 2608 |
| 2690 reads.push_back(CreateMockRead(*settings_frame_large, i++)); | 2609 reads.push_back(CreateMockRead(*settings_frame_large, i++)); |
| 2691 | 2610 |
| 2611 scoped_ptr<SpdyFrame> session_window_update( |
| 2612 spdy_util_.ConstructSpdyWindowUpdate(0, kUploadDataSize)); |
| 2613 if (GetParam().protocol >= kProtoSPDY31) |
| 2614 reads.push_back(CreateMockRead(*session_window_update, i++)); |
| 2615 |
| 2692 writes.push_back(CreateMockWrite(*body3, i++)); | 2616 writes.push_back(CreateMockWrite(*body3, i++)); |
| 2693 | 2617 |
| 2694 scoped_ptr<SpdyFrame> reply(spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); | 2618 scoped_ptr<SpdyFrame> reply(spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); |
| 2695 reads.push_back(CreateMockRead(*reply, i++)); | 2619 reads.push_back(CreateMockRead(*reply, i++)); |
| 2696 reads.push_back(CreateMockRead(*body2, i++)); | 2620 reads.push_back(CreateMockRead(*body2, i++)); |
| 2697 reads.push_back(CreateMockRead(*body3, i++)); | 2621 reads.push_back(CreateMockRead(*body3, i++)); |
| 2698 reads.push_back(MockRead(ASYNC, 0, i++)); // EOF | 2622 reads.push_back(MockRead(ASYNC, 0, i++)); // EOF |
| 2699 | 2623 |
| 2700 // Force all writes to happen before any read, last write will not | 2624 // Force all writes to happen before any read, last write will not |
| 2701 // actually queue a frame, due to window size being 0. | 2625 // actually queue a frame, due to window size being 0. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2743 data.RunFor(6); // Read in SETTINGS frame to unstall. | 2667 data.RunFor(6); // Read in SETTINGS frame to unstall. |
| 2744 rv = callback.WaitForResult(); | 2668 rv = callback.WaitForResult(); |
| 2745 helper.VerifyDataConsumed(); | 2669 helper.VerifyDataConsumed(); |
| 2746 // If stream is NULL, that means it was unstalled and closed. | 2670 // If stream is NULL, that means it was unstalled and closed. |
| 2747 EXPECT_TRUE(stream->stream() == NULL); | 2671 EXPECT_TRUE(stream->stream() == NULL); |
| 2748 } | 2672 } |
| 2749 | 2673 |
| 2750 // Test we correctly handle the case where the SETTINGS frame results in a | 2674 // Test we correctly handle the case where the SETTINGS frame results in a |
| 2751 // negative send window size. | 2675 // negative send window size. |
| 2752 TEST_P(SpdyNetworkTransactionTest, FlowControlNegativeSendWindowSize) { | 2676 TEST_P(SpdyNetworkTransactionTest, FlowControlNegativeSendWindowSize) { |
| 2753 if (GetParam().protocol != kProtoSPDY3) | 2677 if (GetParam().protocol < kProtoSPDY3) |
| 2754 return; | 2678 return; |
| 2755 | 2679 |
| 2756 // Number of frames we need to send to zero out the window size: data | 2680 // Number of frames we need to send to zero out the window size: data |
| 2757 // frames plus SYN_STREAM plus the last data frame; also we need another | 2681 // frames plus SYN_STREAM plus the last data frame; also we need another |
| 2758 // data frame that we will send once the SETTING is received, therefore +3. | 2682 // data frame that we will send once the SETTING is received, therefore +3. |
| 2759 size_t num_writes = kSpdyStreamInitialWindowSize / kMaxSpdyFrameChunkSize + 3; | 2683 size_t num_writes = kSpdyStreamInitialWindowSize / kMaxSpdyFrameChunkSize + 3; |
| 2760 | 2684 |
| 2761 // Calculate last frame's size; 0 size data frame is legal. | 2685 // Calculate last frame's size; 0 size data frame is legal. |
| 2762 size_t last_frame_size = | 2686 size_t last_frame_size = |
| 2763 kSpdyStreamInitialWindowSize % kMaxSpdyFrameChunkSize; | 2687 kSpdyStreamInitialWindowSize % kMaxSpdyFrameChunkSize; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2792 writes.push_back(CreateMockWrite(*body2, i++)); | 2716 writes.push_back(CreateMockWrite(*body2, i++)); |
| 2793 | 2717 |
| 2794 // Construct read frame for SETTINGS that makes the send_window_size | 2718 // Construct read frame for SETTINGS that makes the send_window_size |
| 2795 // negative. | 2719 // negative. |
| 2796 SettingsMap new_settings; | 2720 SettingsMap new_settings; |
| 2797 new_settings[SETTINGS_INITIAL_WINDOW_SIZE] = | 2721 new_settings[SETTINGS_INITIAL_WINDOW_SIZE] = |
| 2798 SettingsFlagsAndValue( | 2722 SettingsFlagsAndValue( |
| 2799 SETTINGS_FLAG_NONE, kSpdyStreamInitialWindowSize / 2); | 2723 SETTINGS_FLAG_NONE, kSpdyStreamInitialWindowSize / 2); |
| 2800 scoped_ptr<SpdyFrame> settings_frame_small( | 2724 scoped_ptr<SpdyFrame> settings_frame_small( |
| 2801 spdy_util_.ConstructSpdySettings(new_settings)); | 2725 spdy_util_.ConstructSpdySettings(new_settings)); |
| 2802 // Construct read frame for WINDOW_UPDATE that makes the send_window_size | 2726 // Construct read frames for WINDOW_UPDATE that makes the send_window_size |
| 2803 // postive. | 2727 // positive. |
| 2728 scoped_ptr<SpdyFrame> session_window_update_init_size( |
| 2729 spdy_util_.ConstructSpdyWindowUpdate(0, kSpdyStreamInitialWindowSize)); |
| 2804 scoped_ptr<SpdyFrame> window_update_init_size( | 2730 scoped_ptr<SpdyFrame> window_update_init_size( |
| 2805 spdy_util_.ConstructSpdyWindowUpdate(1, kSpdyStreamInitialWindowSize)); | 2731 spdy_util_.ConstructSpdyWindowUpdate(1, kSpdyStreamInitialWindowSize)); |
| 2806 | 2732 |
| 2807 reads.push_back(CreateMockRead(*settings_frame_small, i++)); | 2733 reads.push_back(CreateMockRead(*settings_frame_small, i++)); |
| 2734 |
| 2735 if (GetParam().protocol >= kProtoSPDY3) |
| 2736 reads.push_back(CreateMockRead(*session_window_update_init_size, i++)); |
| 2737 |
| 2808 reads.push_back(CreateMockRead(*window_update_init_size, i++)); | 2738 reads.push_back(CreateMockRead(*window_update_init_size, i++)); |
| 2809 | 2739 |
| 2810 writes.push_back(CreateMockWrite(*body3, i++)); | 2740 writes.push_back(CreateMockWrite(*body3, i++)); |
| 2811 | 2741 |
| 2812 scoped_ptr<SpdyFrame> reply(spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); | 2742 scoped_ptr<SpdyFrame> reply(spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); |
| 2813 reads.push_back(CreateMockRead(*reply, i++)); | 2743 reads.push_back(CreateMockRead(*reply, i++)); |
| 2814 reads.push_back(CreateMockRead(*body2, i++)); | 2744 reads.push_back(CreateMockRead(*body2, i++)); |
| 2815 reads.push_back(CreateMockRead(*body3, i++)); | 2745 reads.push_back(CreateMockRead(*body3, i++)); |
| 2816 reads.push_back(MockRead(ASYNC, 0, i++)); // EOF | 2746 reads.push_back(MockRead(ASYNC, 0, i++)); // EOF |
| 2817 | 2747 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2851 EXPECT_EQ(0, stream->stream()->send_window_size()); | 2781 EXPECT_EQ(0, stream->stream()->send_window_size()); |
| 2852 | 2782 |
| 2853 // All the body data should have been read. | 2783 // All the body data should have been read. |
| 2854 // TODO(satorux): This is because of the weirdness in reading the request | 2784 // TODO(satorux): This is because of the weirdness in reading the request |
| 2855 // body in OnSendBodyComplete(). See crbug.com/113107. | 2785 // body in OnSendBodyComplete(). See crbug.com/113107. |
| 2856 EXPECT_TRUE(upload_data_stream.IsEOF()); | 2786 EXPECT_TRUE(upload_data_stream.IsEOF()); |
| 2857 // But the body is not yet fully sent (kUploadData is not yet sent) | 2787 // But the body is not yet fully sent (kUploadData is not yet sent) |
| 2858 // since we're send-stalled. | 2788 // since we're send-stalled. |
| 2859 EXPECT_TRUE(stream->stream()->send_stalled_by_flow_control()); | 2789 EXPECT_TRUE(stream->stream()->send_stalled_by_flow_control()); |
| 2860 | 2790 |
| 2861 data.RunFor(7); // Read in WINDOW_UPDATE or SETTINGS frame. | 2791 // Read in WINDOW_UPDATE or SETTINGS frame. |
| 2792 data.RunFor((GetParam().protocol >= kProtoSPDY31) ? 8 : 7); |
| 2862 rv = callback.WaitForResult(); | 2793 rv = callback.WaitForResult(); |
| 2863 helper.VerifyDataConsumed(); | 2794 helper.VerifyDataConsumed(); |
| 2864 } | 2795 } |
| 2865 | 2796 |
| 2866 TEST_P(SpdyNetworkTransactionTest, ResetReplyWithTransferEncoding) { | 2797 TEST_P(SpdyNetworkTransactionTest, ResetReplyWithTransferEncoding) { |
| 2867 if (GetParam().protocol > kProtoSPDY3) | |
| 2868 return; | |
| 2869 | |
| 2870 // Construct the request. | 2798 // Construct the request. |
| 2871 scoped_ptr<SpdyFrame> req( | 2799 scoped_ptr<SpdyFrame> req( |
| 2872 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 2800 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 2873 scoped_ptr<SpdyFrame> rst( | 2801 scoped_ptr<SpdyFrame> rst( |
| 2874 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); | 2802 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); |
| 2875 MockWrite writes[] = { | 2803 MockWrite writes[] = { |
| 2876 CreateMockWrite(*req), | 2804 CreateMockWrite(*req), |
| 2877 CreateMockWrite(*rst), | 2805 CreateMockWrite(*rst), |
| 2878 }; | 2806 }; |
| 2879 | 2807 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2896 BoundNetLog(), GetParam(), NULL); | 2824 BoundNetLog(), GetParam(), NULL); |
| 2897 helper.RunToCompletion(&data); | 2825 helper.RunToCompletion(&data); |
| 2898 TransactionHelperResult out = helper.output(); | 2826 TransactionHelperResult out = helper.output(); |
| 2899 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); | 2827 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); |
| 2900 | 2828 |
| 2901 helper.session()->spdy_session_pool()->CloseAllSessions(); | 2829 helper.session()->spdy_session_pool()->CloseAllSessions(); |
| 2902 helper.VerifyDataConsumed(); | 2830 helper.VerifyDataConsumed(); |
| 2903 } | 2831 } |
| 2904 | 2832 |
| 2905 TEST_P(SpdyNetworkTransactionTest, ResetPushWithTransferEncoding) { | 2833 TEST_P(SpdyNetworkTransactionTest, ResetPushWithTransferEncoding) { |
| 2906 if (GetParam().protocol > kProtoSPDY3) | |
| 2907 return; | |
| 2908 | |
| 2909 // Construct the request. | 2834 // Construct the request. |
| 2910 scoped_ptr<SpdyFrame> req( | 2835 scoped_ptr<SpdyFrame> req( |
| 2911 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 2836 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 2912 scoped_ptr<SpdyFrame> rst( | 2837 scoped_ptr<SpdyFrame> rst( |
| 2913 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_PROTOCOL_ERROR)); | 2838 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_PROTOCOL_ERROR)); |
| 2914 MockWrite writes[] = { | 2839 MockWrite writes[] = { |
| 2915 CreateMockWrite(*req), | 2840 CreateMockWrite(*req), |
| 2916 CreateMockWrite(*rst), | 2841 CreateMockWrite(*rst), |
| 2917 }; | 2842 }; |
| 2918 | 2843 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2939 TransactionHelperResult out = helper.output(); | 2864 TransactionHelperResult out = helper.output(); |
| 2940 EXPECT_EQ(OK, out.rv); | 2865 EXPECT_EQ(OK, out.rv); |
| 2941 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 2866 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 2942 EXPECT_EQ("hello!", out.response_data); | 2867 EXPECT_EQ("hello!", out.response_data); |
| 2943 | 2868 |
| 2944 helper.session()->spdy_session_pool()->CloseAllSessions(); | 2869 helper.session()->spdy_session_pool()->CloseAllSessions(); |
| 2945 helper.VerifyDataConsumed(); | 2870 helper.VerifyDataConsumed(); |
| 2946 } | 2871 } |
| 2947 | 2872 |
| 2948 TEST_P(SpdyNetworkTransactionTest, CancelledTransaction) { | 2873 TEST_P(SpdyNetworkTransactionTest, CancelledTransaction) { |
| 2949 if (GetParam().protocol > kProtoSPDY3) | |
| 2950 return; | |
| 2951 | |
| 2952 // Construct the request. | 2874 // Construct the request. |
| 2953 scoped_ptr<SpdyFrame> req( | 2875 scoped_ptr<SpdyFrame> req( |
| 2954 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 2876 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 2955 MockWrite writes[] = { | 2877 MockWrite writes[] = { |
| 2956 CreateMockWrite(*req), | 2878 CreateMockWrite(*req), |
| 2957 }; | 2879 }; |
| 2958 | 2880 |
| 2959 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 2881 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 2960 MockRead reads[] = { | 2882 MockRead reads[] = { |
| 2961 CreateMockRead(*resp), | 2883 CreateMockRead(*resp), |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2982 helper.ResetTrans(); // Cancel the transaction. | 2904 helper.ResetTrans(); // Cancel the transaction. |
| 2983 | 2905 |
| 2984 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the | 2906 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the |
| 2985 // MockClientSocketFactory) are still alive. | 2907 // MockClientSocketFactory) are still alive. |
| 2986 base::MessageLoop::current()->RunUntilIdle(); | 2908 base::MessageLoop::current()->RunUntilIdle(); |
| 2987 helper.VerifyDataNotConsumed(); | 2909 helper.VerifyDataNotConsumed(); |
| 2988 } | 2910 } |
| 2989 | 2911 |
| 2990 // Verify that the client sends a Rst Frame upon cancelling the stream. | 2912 // Verify that the client sends a Rst Frame upon cancelling the stream. |
| 2991 TEST_P(SpdyNetworkTransactionTest, CancelledTransactionSendRst) { | 2913 TEST_P(SpdyNetworkTransactionTest, CancelledTransactionSendRst) { |
| 2992 if (GetParam().protocol > kProtoSPDY3) | |
| 2993 return; | |
| 2994 | |
| 2995 scoped_ptr<SpdyFrame> req( | 2914 scoped_ptr<SpdyFrame> req( |
| 2996 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 2915 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 2997 scoped_ptr<SpdyFrame> rst( | 2916 scoped_ptr<SpdyFrame> rst( |
| 2998 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); | 2917 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); |
| 2999 MockWrite writes[] = { | 2918 MockWrite writes[] = { |
| 3000 CreateMockWrite(*req, 0, SYNCHRONOUS), | 2919 CreateMockWrite(*req, 0, SYNCHRONOUS), |
| 3001 CreateMockWrite(*rst, 2, SYNCHRONOUS), | 2920 CreateMockWrite(*rst, 2, SYNCHRONOUS), |
| 3002 }; | 2921 }; |
| 3003 | 2922 |
| 3004 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 2923 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 3030 data.SetStop(20); | 2949 data.SetStop(20); |
| 3031 data.Run(); | 2950 data.Run(); |
| 3032 | 2951 |
| 3033 helper.VerifyDataConsumed(); | 2952 helper.VerifyDataConsumed(); |
| 3034 } | 2953 } |
| 3035 | 2954 |
| 3036 // Verify that the client can correctly deal with the user callback attempting | 2955 // Verify that the client can correctly deal with the user callback attempting |
| 3037 // to start another transaction on a session that is closing down. See | 2956 // to start another transaction on a session that is closing down. See |
| 3038 // http://crbug.com/47455 | 2957 // http://crbug.com/47455 |
| 3039 TEST_P(SpdyNetworkTransactionTest, StartTransactionOnReadCallback) { | 2958 TEST_P(SpdyNetworkTransactionTest, StartTransactionOnReadCallback) { |
| 3040 if (GetParam().protocol > kProtoSPDY3) | |
| 3041 return; | |
| 3042 | |
| 3043 scoped_ptr<SpdyFrame> req( | 2959 scoped_ptr<SpdyFrame> req( |
| 3044 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 2960 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 3045 MockWrite writes[] = { CreateMockWrite(*req) }; | 2961 MockWrite writes[] = { CreateMockWrite(*req) }; |
| 3046 MockWrite writes2[] = { CreateMockWrite(*req) }; | 2962 MockWrite writes2[] = { CreateMockWrite(*req) }; |
| 3047 | 2963 |
| 3048 // The indicated length of this frame is longer than its actual length. When | 2964 // The indicated length of this frame is longer than its actual length. When |
| 3049 // the session receives an empty frame after this one, it shuts down the | 2965 // the session receives an empty frame after this one, it shuts down the |
| 3050 // session, and calls the read callback with the incomplete data. | 2966 // session, and calls the read callback with the incomplete data. |
| 3051 const uint8 kGetBodyFrame2[] = { | 2967 const uint8 kGetBodyFrame2[] = { |
| 3052 0x00, 0x00, 0x00, 0x01, | 2968 0x00, 0x00, 0x00, 0x01, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3097 data.CompleteRead(); | 3013 data.CompleteRead(); |
| 3098 // This finishes the read. | 3014 // This finishes the read. |
| 3099 data.CompleteRead(); | 3015 data.CompleteRead(); |
| 3100 helper.VerifyDataConsumed(); | 3016 helper.VerifyDataConsumed(); |
| 3101 } | 3017 } |
| 3102 | 3018 |
| 3103 // Verify that the client can correctly deal with the user callback deleting the | 3019 // Verify that the client can correctly deal with the user callback deleting the |
| 3104 // transaction. Failures will usually be valgrind errors. See | 3020 // transaction. Failures will usually be valgrind errors. See |
| 3105 // http://crbug.com/46925 | 3021 // http://crbug.com/46925 |
| 3106 TEST_P(SpdyNetworkTransactionTest, DeleteSessionOnReadCallback) { | 3022 TEST_P(SpdyNetworkTransactionTest, DeleteSessionOnReadCallback) { |
| 3107 if (GetParam().protocol > kProtoSPDY3) | |
| 3108 return; | |
| 3109 | |
| 3110 scoped_ptr<SpdyFrame> req( | 3023 scoped_ptr<SpdyFrame> req( |
| 3111 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 3024 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 3112 MockWrite writes[] = { CreateMockWrite(*req) }; | 3025 MockWrite writes[] = { CreateMockWrite(*req) }; |
| 3113 | 3026 |
| 3114 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 3027 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 3115 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 3028 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 3116 MockRead reads[] = { | 3029 MockRead reads[] = { |
| 3117 CreateMockRead(*resp.get(), 2), | 3030 CreateMockRead(*resp.get(), 2), |
| 3118 MockRead(ASYNC, ERR_IO_PENDING, 3), // Force a pause | 3031 MockRead(ASYNC, ERR_IO_PENDING, 3), // Force a pause |
| 3119 CreateMockRead(*body.get(), 4), | 3032 CreateMockRead(*body.get(), 4), |
| (...skipping 27 matching lines...) Expand all Loading... |
| 3147 ASSERT_EQ(ERR_IO_PENDING, rv); | 3060 ASSERT_EQ(ERR_IO_PENDING, rv); |
| 3148 data.CompleteRead(); | 3061 data.CompleteRead(); |
| 3149 | 3062 |
| 3150 // Finish running rest of tasks. | 3063 // Finish running rest of tasks. |
| 3151 base::MessageLoop::current()->RunUntilIdle(); | 3064 base::MessageLoop::current()->RunUntilIdle(); |
| 3152 helper.VerifyDataConsumed(); | 3065 helper.VerifyDataConsumed(); |
| 3153 } | 3066 } |
| 3154 | 3067 |
| 3155 // Send a spdy request to www.google.com that gets redirected to www.foo.com. | 3068 // Send a spdy request to www.google.com that gets redirected to www.foo.com. |
| 3156 TEST_P(SpdyNetworkTransactionTest, RedirectGetRequest) { | 3069 TEST_P(SpdyNetworkTransactionTest, RedirectGetRequest) { |
| 3157 if (GetParam().protocol > kProtoSPDY3) | |
| 3158 return; | |
| 3159 | |
| 3160 const SpdyHeaderInfo kSynStartHeader = spdy_util_.MakeSpdyHeader(SYN_STREAM); | 3070 const SpdyHeaderInfo kSynStartHeader = spdy_util_.MakeSpdyHeader(SYN_STREAM); |
| 3161 scoped_ptr<SpdyHeaderBlock> headers( | 3071 scoped_ptr<SpdyHeaderBlock> headers( |
| 3162 spdy_util_.ConstructGetHeaderBlock("http://www.google.com/")); | 3072 spdy_util_.ConstructGetHeaderBlock("http://www.google.com/")); |
| 3163 (*headers)["user-agent"] = ""; | 3073 (*headers)["user-agent"] = ""; |
| 3164 (*headers)["accept-encoding"] = "gzip,deflate"; | 3074 (*headers)["accept-encoding"] = "gzip,deflate"; |
| 3165 scoped_ptr<SpdyHeaderBlock> headers2( | 3075 scoped_ptr<SpdyHeaderBlock> headers2( |
| 3166 spdy_util_.ConstructGetHeaderBlock("http://www.foo.com/index.php")); | 3076 spdy_util_.ConstructGetHeaderBlock("http://www.foo.com/index.php")); |
| 3167 (*headers2)["user-agent"] = ""; | 3077 (*headers2)["user-agent"] = ""; |
| 3168 (*headers2)["accept-encoding"] = "gzip,deflate"; | 3078 (*headers2)["accept-encoding"] = "gzip,deflate"; |
| 3169 | 3079 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3226 } | 3136 } |
| 3227 EXPECT_TRUE(data.at_read_eof()); | 3137 EXPECT_TRUE(data.at_read_eof()); |
| 3228 EXPECT_TRUE(data.at_write_eof()); | 3138 EXPECT_TRUE(data.at_write_eof()); |
| 3229 EXPECT_TRUE(data2.at_read_eof()); | 3139 EXPECT_TRUE(data2.at_read_eof()); |
| 3230 EXPECT_TRUE(data2.at_write_eof()); | 3140 EXPECT_TRUE(data2.at_write_eof()); |
| 3231 } | 3141 } |
| 3232 | 3142 |
| 3233 // Send a spdy request to www.google.com. Get a pushed stream that redirects to | 3143 // Send a spdy request to www.google.com. Get a pushed stream that redirects to |
| 3234 // www.foo.com. | 3144 // www.foo.com. |
| 3235 TEST_P(SpdyNetworkTransactionTest, RedirectServerPush) { | 3145 TEST_P(SpdyNetworkTransactionTest, RedirectServerPush) { |
| 3236 if (GetParam().protocol > kProtoSPDY3) | |
| 3237 return; | |
| 3238 | |
| 3239 const SpdyHeaderInfo kSynStartHeader = spdy_util_.MakeSpdyHeader(SYN_STREAM); | 3146 const SpdyHeaderInfo kSynStartHeader = spdy_util_.MakeSpdyHeader(SYN_STREAM); |
| 3240 | 3147 |
| 3241 scoped_ptr<SpdyHeaderBlock> headers( | 3148 scoped_ptr<SpdyHeaderBlock> headers( |
| 3242 spdy_util_.ConstructGetHeaderBlock("http://www.google.com/")); | 3149 spdy_util_.ConstructGetHeaderBlock("http://www.google.com/")); |
| 3243 (*headers)["user-agent"] = ""; | 3150 (*headers)["user-agent"] = ""; |
| 3244 (*headers)["accept-encoding"] = "gzip,deflate"; | 3151 (*headers)["accept-encoding"] = "gzip,deflate"; |
| 3245 | 3152 |
| 3246 // Setup writes/reads to www.google.com | 3153 // Setup writes/reads to www.google.com |
| 3247 scoped_ptr<SpdyFrame> req( | 3154 scoped_ptr<SpdyFrame> req( |
| 3248 spdy_util_.ConstructSpdyFrame(kSynStartHeader, headers.Pass())); | 3155 spdy_util_.ConstructSpdyFrame(kSynStartHeader, headers.Pass())); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3331 } | 3238 } |
| 3332 data.CompleteRead(); | 3239 data.CompleteRead(); |
| 3333 data2.CompleteRead(); | 3240 data2.CompleteRead(); |
| 3334 EXPECT_TRUE(data.at_read_eof()); | 3241 EXPECT_TRUE(data.at_read_eof()); |
| 3335 EXPECT_TRUE(data.at_write_eof()); | 3242 EXPECT_TRUE(data.at_write_eof()); |
| 3336 EXPECT_TRUE(data2.at_read_eof()); | 3243 EXPECT_TRUE(data2.at_read_eof()); |
| 3337 EXPECT_TRUE(data2.at_write_eof()); | 3244 EXPECT_TRUE(data2.at_write_eof()); |
| 3338 } | 3245 } |
| 3339 | 3246 |
| 3340 TEST_P(SpdyNetworkTransactionTest, ServerPushSingleDataFrame) { | 3247 TEST_P(SpdyNetworkTransactionTest, ServerPushSingleDataFrame) { |
| 3341 if (GetParam().protocol > kProtoSPDY3) | |
| 3342 return; | |
| 3343 | |
| 3344 static const unsigned char kPushBodyFrame[] = { | |
| 3345 0x00, 0x00, 0x00, 0x02, // header, ID | |
| 3346 0x01, 0x00, 0x00, 0x06, // FIN, length | |
| 3347 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | |
| 3348 }; | |
| 3349 scoped_ptr<SpdyFrame> stream1_syn( | 3248 scoped_ptr<SpdyFrame> stream1_syn( |
| 3350 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 3249 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 3351 scoped_ptr<SpdyFrame> stream1_body( | 3250 scoped_ptr<SpdyFrame> stream1_body( |
| 3352 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 3251 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 3353 MockWrite writes[] = { | 3252 MockWrite writes[] = { |
| 3354 CreateMockWrite(*stream1_syn, 1), | 3253 CreateMockWrite(*stream1_syn, 1), |
| 3355 }; | 3254 }; |
| 3356 | 3255 |
| 3357 scoped_ptr<SpdyFrame> | 3256 scoped_ptr<SpdyFrame> |
| 3358 stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 3257 stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 3359 scoped_ptr<SpdyFrame> | 3258 scoped_ptr<SpdyFrame> |
| 3360 stream2_syn(spdy_util_.ConstructSpdyPush(NULL, | 3259 stream2_syn(spdy_util_.ConstructSpdyPush(NULL, |
| 3361 0, | 3260 0, |
| 3362 2, | 3261 2, |
| 3363 1, | 3262 1, |
| 3364 "http://www.google.com/foo.dat")); | 3263 "http://www.google.com/foo.dat")); |
| 3264 const char kPushedData[] = "pushed"; |
| 3265 scoped_ptr<SpdyFrame> stream2_body( |
| 3266 spdy_util_.ConstructSpdyBodyFrame( |
| 3267 2, kPushedData, strlen(kPushedData), true)); |
| 3365 MockRead reads[] = { | 3268 MockRead reads[] = { |
| 3366 CreateMockRead(*stream1_reply, 2), | 3269 CreateMockRead(*stream1_reply, 2), |
| 3367 CreateMockRead(*stream2_syn, 3), | 3270 CreateMockRead(*stream2_syn, 3), |
| 3368 CreateMockRead(*stream1_body, 4, SYNCHRONOUS), | 3271 CreateMockRead(*stream1_body, 4, SYNCHRONOUS), |
| 3369 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame), | 3272 CreateMockRead(*stream2_body, 5), |
| 3370 arraysize(kPushBodyFrame), 5), | |
| 3371 MockRead(ASYNC, ERR_IO_PENDING, 6), // Force a pause | 3273 MockRead(ASYNC, ERR_IO_PENDING, 6), // Force a pause |
| 3372 }; | 3274 }; |
| 3373 | 3275 |
| 3374 HttpResponseInfo response; | 3276 HttpResponseInfo response; |
| 3375 HttpResponseInfo response2; | 3277 HttpResponseInfo response2; |
| 3376 std::string expected_push_result("pushed"); | 3278 std::string expected_push_result("pushed"); |
| 3377 OrderedSocketData data(reads, arraysize(reads), | 3279 OrderedSocketData data(reads, arraysize(reads), |
| 3378 writes, arraysize(writes)); | 3280 writes, arraysize(writes)); |
| 3379 RunServerPushTest(&data, | 3281 RunServerPushTest(&data, |
| 3380 &response, | 3282 &response, |
| 3381 &response2, | 3283 &response2, |
| 3382 expected_push_result); | 3284 expected_push_result); |
| 3383 | 3285 |
| 3384 // Verify the SYN_REPLY. | 3286 // Verify the SYN_REPLY. |
| 3385 EXPECT_TRUE(response.headers.get() != NULL); | 3287 EXPECT_TRUE(response.headers.get() != NULL); |
| 3386 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3288 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 3387 | 3289 |
| 3388 // Verify the pushed stream. | 3290 // Verify the pushed stream. |
| 3389 EXPECT_TRUE(response2.headers.get() != NULL); | 3291 EXPECT_TRUE(response2.headers.get() != NULL); |
| 3390 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 3292 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
| 3391 } | 3293 } |
| 3392 | 3294 |
| 3393 TEST_P(SpdyNetworkTransactionTest, ServerPushBeforeSynReply) { | 3295 TEST_P(SpdyNetworkTransactionTest, ServerPushBeforeSynReply) { |
| 3394 if (GetParam().protocol > kProtoSPDY3) | |
| 3395 return; | |
| 3396 | |
| 3397 static const unsigned char kPushBodyFrame[] = { | |
| 3398 0x00, 0x00, 0x00, 0x02, // header, ID | |
| 3399 0x01, 0x00, 0x00, 0x06, // FIN, length | |
| 3400 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | |
| 3401 }; | |
| 3402 scoped_ptr<SpdyFrame> stream1_syn( | 3296 scoped_ptr<SpdyFrame> stream1_syn( |
| 3403 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 3297 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 3404 scoped_ptr<SpdyFrame> stream1_body( | 3298 scoped_ptr<SpdyFrame> stream1_body( |
| 3405 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 3299 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 3406 MockWrite writes[] = { | 3300 MockWrite writes[] = { |
| 3407 CreateMockWrite(*stream1_syn, 1), | 3301 CreateMockWrite(*stream1_syn, 1), |
| 3408 }; | 3302 }; |
| 3409 | 3303 |
| 3410 scoped_ptr<SpdyFrame> | 3304 scoped_ptr<SpdyFrame> |
| 3411 stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 3305 stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 3412 scoped_ptr<SpdyFrame> | 3306 scoped_ptr<SpdyFrame> |
| 3413 stream2_syn(spdy_util_.ConstructSpdyPush(NULL, | 3307 stream2_syn(spdy_util_.ConstructSpdyPush(NULL, |
| 3414 0, | 3308 0, |
| 3415 2, | 3309 2, |
| 3416 1, | 3310 1, |
| 3417 "http://www.google.com/foo.dat")); | 3311 "http://www.google.com/foo.dat")); |
| 3312 const char kPushedData[] = "pushed"; |
| 3313 scoped_ptr<SpdyFrame> stream2_body( |
| 3314 spdy_util_.ConstructSpdyBodyFrame( |
| 3315 2, kPushedData, strlen(kPushedData), true)); |
| 3418 MockRead reads[] = { | 3316 MockRead reads[] = { |
| 3419 CreateMockRead(*stream2_syn, 2), | 3317 CreateMockRead(*stream2_syn, 2), |
| 3420 CreateMockRead(*stream1_reply, 3), | 3318 CreateMockRead(*stream1_reply, 3), |
| 3421 CreateMockRead(*stream1_body, 4, SYNCHRONOUS), | 3319 CreateMockRead(*stream1_body, 4, SYNCHRONOUS), |
| 3422 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame), | 3320 CreateMockRead(*stream2_body, 5), |
| 3423 arraysize(kPushBodyFrame), 5), | |
| 3424 MockRead(ASYNC, ERR_IO_PENDING, 6), // Force a pause | 3321 MockRead(ASYNC, ERR_IO_PENDING, 6), // Force a pause |
| 3425 }; | 3322 }; |
| 3426 | 3323 |
| 3427 HttpResponseInfo response; | 3324 HttpResponseInfo response; |
| 3428 HttpResponseInfo response2; | 3325 HttpResponseInfo response2; |
| 3429 std::string expected_push_result("pushed"); | 3326 std::string expected_push_result("pushed"); |
| 3430 OrderedSocketData data(reads, arraysize(reads), | 3327 OrderedSocketData data(reads, arraysize(reads), |
| 3431 writes, arraysize(writes)); | 3328 writes, arraysize(writes)); |
| 3432 RunServerPushTest(&data, | 3329 RunServerPushTest(&data, |
| 3433 &response, | 3330 &response, |
| 3434 &response2, | 3331 &response2, |
| 3435 expected_push_result); | 3332 expected_push_result); |
| 3436 | 3333 |
| 3437 // Verify the SYN_REPLY. | 3334 // Verify the SYN_REPLY. |
| 3438 EXPECT_TRUE(response.headers.get() != NULL); | 3335 EXPECT_TRUE(response.headers.get() != NULL); |
| 3439 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3336 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 3440 | 3337 |
| 3441 // Verify the pushed stream. | 3338 // Verify the pushed stream. |
| 3442 EXPECT_TRUE(response2.headers.get() != NULL); | 3339 EXPECT_TRUE(response2.headers.get() != NULL); |
| 3443 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 3340 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
| 3444 } | 3341 } |
| 3445 | 3342 |
| 3446 TEST_P(SpdyNetworkTransactionTest, ServerPushSingleDataFrame2) { | 3343 TEST_P(SpdyNetworkTransactionTest, ServerPushSingleDataFrame2) { |
| 3447 if (GetParam().protocol > kProtoSPDY3) | |
| 3448 return; | |
| 3449 | |
| 3450 static const unsigned char kPushBodyFrame[] = { | |
| 3451 0x00, 0x00, 0x00, 0x02, // header, ID | |
| 3452 0x01, 0x00, 0x00, 0x06, // FIN, length | |
| 3453 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | |
| 3454 }; | |
| 3455 scoped_ptr<SpdyFrame> stream1_syn( | 3344 scoped_ptr<SpdyFrame> stream1_syn( |
| 3456 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 3345 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 3457 MockWrite writes[] = { CreateMockWrite(*stream1_syn, 1), }; | 3346 MockWrite writes[] = { CreateMockWrite(*stream1_syn, 1), }; |
| 3458 | 3347 |
| 3459 scoped_ptr<SpdyFrame> | 3348 scoped_ptr<SpdyFrame> |
| 3460 stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 3349 stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 3461 scoped_ptr<SpdyFrame> | 3350 scoped_ptr<SpdyFrame> |
| 3462 stream2_syn(spdy_util_.ConstructSpdyPush(NULL, | 3351 stream2_syn(spdy_util_.ConstructSpdyPush(NULL, |
| 3463 0, | 3352 0, |
| 3464 2, | 3353 2, |
| 3465 1, | 3354 1, |
| 3466 "http://www.google.com/foo.dat")); | 3355 "http://www.google.com/foo.dat")); |
| 3356 const char kPushedData[] = "pushed"; |
| 3357 scoped_ptr<SpdyFrame> stream2_body( |
| 3358 spdy_util_.ConstructSpdyBodyFrame( |
| 3359 2, kPushedData, strlen(kPushedData), true)); |
| 3467 scoped_ptr<SpdyFrame> | 3360 scoped_ptr<SpdyFrame> |
| 3468 stream1_body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 3361 stream1_body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 3469 MockRead reads[] = { | 3362 MockRead reads[] = { |
| 3470 CreateMockRead(*stream1_reply, 2), | 3363 CreateMockRead(*stream1_reply, 2), |
| 3471 CreateMockRead(*stream2_syn, 3), | 3364 CreateMockRead(*stream2_syn, 3), |
| 3472 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame), | 3365 CreateMockRead(*stream2_body, 4), |
| 3473 arraysize(kPushBodyFrame), 5), | 3366 CreateMockRead(*stream1_body, 5, SYNCHRONOUS), |
| 3474 CreateMockRead(*stream1_body, 4, SYNCHRONOUS), | |
| 3475 MockRead(ASYNC, ERR_IO_PENDING, 6), // Force a pause | 3367 MockRead(ASYNC, ERR_IO_PENDING, 6), // Force a pause |
| 3476 }; | 3368 }; |
| 3477 | 3369 |
| 3478 HttpResponseInfo response; | 3370 HttpResponseInfo response; |
| 3479 HttpResponseInfo response2; | 3371 HttpResponseInfo response2; |
| 3480 std::string expected_push_result("pushed"); | 3372 std::string expected_push_result("pushed"); |
| 3481 OrderedSocketData data(reads, arraysize(reads), | 3373 OrderedSocketData data(reads, arraysize(reads), |
| 3482 writes, arraysize(writes)); | 3374 writes, arraysize(writes)); |
| 3483 RunServerPushTest(&data, | 3375 RunServerPushTest(&data, |
| 3484 &response, | 3376 &response, |
| 3485 &response2, | 3377 &response2, |
| 3486 expected_push_result); | 3378 expected_push_result); |
| 3487 | 3379 |
| 3488 // Verify the SYN_REPLY. | 3380 // Verify the SYN_REPLY. |
| 3489 EXPECT_TRUE(response.headers.get() != NULL); | 3381 EXPECT_TRUE(response.headers.get() != NULL); |
| 3490 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3382 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 3491 | 3383 |
| 3492 // Verify the pushed stream. | 3384 // Verify the pushed stream. |
| 3493 EXPECT_TRUE(response2.headers.get() != NULL); | 3385 EXPECT_TRUE(response2.headers.get() != NULL); |
| 3494 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 3386 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
| 3495 } | 3387 } |
| 3496 | 3388 |
| 3497 TEST_P(SpdyNetworkTransactionTest, ServerPushServerAborted) { | 3389 TEST_P(SpdyNetworkTransactionTest, ServerPushServerAborted) { |
| 3498 if (GetParam().protocol > kProtoSPDY3) | |
| 3499 return; | |
| 3500 | |
| 3501 scoped_ptr<SpdyFrame> stream1_syn( | 3390 scoped_ptr<SpdyFrame> stream1_syn( |
| 3502 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 3391 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 3503 scoped_ptr<SpdyFrame> stream1_body( | 3392 scoped_ptr<SpdyFrame> stream1_body( |
| 3504 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 3393 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 3505 MockWrite writes[] = { | 3394 MockWrite writes[] = { |
| 3506 CreateMockWrite(*stream1_syn, 1), | 3395 CreateMockWrite(*stream1_syn, 1), |
| 3507 }; | 3396 }; |
| 3508 | 3397 |
| 3509 scoped_ptr<SpdyFrame> | 3398 scoped_ptr<SpdyFrame> |
| 3510 stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 3399 stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3551 << data.write_count() | 3440 << data.write_count() |
| 3552 << " Write index: " | 3441 << " Write index: " |
| 3553 << data.write_index(); | 3442 << data.write_index(); |
| 3554 | 3443 |
| 3555 // Verify the SYN_REPLY. | 3444 // Verify the SYN_REPLY. |
| 3556 HttpResponseInfo response = *trans->GetResponseInfo(); | 3445 HttpResponseInfo response = *trans->GetResponseInfo(); |
| 3557 EXPECT_TRUE(response.headers.get() != NULL); | 3446 EXPECT_TRUE(response.headers.get() != NULL); |
| 3558 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3447 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 3559 } | 3448 } |
| 3560 | 3449 |
| 3450 // Verify that we don't leak streams and that we properly send a reset |
| 3451 // if the server pushes the same stream twice. |
| 3561 TEST_P(SpdyNetworkTransactionTest, ServerPushDuplicate) { | 3452 TEST_P(SpdyNetworkTransactionTest, ServerPushDuplicate) { |
| 3562 if (GetParam().protocol > kProtoSPDY3) | |
| 3563 return; | |
| 3564 | |
| 3565 // Verify that we don't leak streams and that we properly send a reset | |
| 3566 // if the server pushes the same stream twice. | |
| 3567 static const unsigned char kPushBodyFrame[] = { | |
| 3568 0x00, 0x00, 0x00, 0x02, // header, ID | |
| 3569 0x01, 0x00, 0x00, 0x06, // FIN, length | |
| 3570 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | |
| 3571 }; | |
| 3572 | |
| 3573 scoped_ptr<SpdyFrame> stream1_syn( | 3453 scoped_ptr<SpdyFrame> stream1_syn( |
| 3574 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 3454 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 3575 scoped_ptr<SpdyFrame> stream1_body( | 3455 scoped_ptr<SpdyFrame> stream1_body( |
| 3576 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 3456 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 3577 scoped_ptr<SpdyFrame> stream3_rst( | 3457 scoped_ptr<SpdyFrame> stream3_rst( |
| 3578 spdy_util_.ConstructSpdyRstStream(4, RST_STREAM_PROTOCOL_ERROR)); | 3458 spdy_util_.ConstructSpdyRstStream(4, RST_STREAM_PROTOCOL_ERROR)); |
| 3579 MockWrite writes[] = { | 3459 MockWrite writes[] = { |
| 3580 CreateMockWrite(*stream1_syn, 1), | 3460 CreateMockWrite(*stream1_syn, 1), |
| 3581 CreateMockWrite(*stream3_rst, 5), | 3461 CreateMockWrite(*stream3_rst, 5), |
| 3582 }; | 3462 }; |
| 3583 | 3463 |
| 3584 scoped_ptr<SpdyFrame> | 3464 scoped_ptr<SpdyFrame> |
| 3585 stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 3465 stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 3586 scoped_ptr<SpdyFrame> | 3466 scoped_ptr<SpdyFrame> |
| 3587 stream2_syn(spdy_util_.ConstructSpdyPush(NULL, | 3467 stream2_syn(spdy_util_.ConstructSpdyPush(NULL, |
| 3588 0, | 3468 0, |
| 3589 2, | 3469 2, |
| 3590 1, | 3470 1, |
| 3591 "http://www.google.com/foo.dat")); | 3471 "http://www.google.com/foo.dat")); |
| 3472 const char kPushedData[] = "pushed"; |
| 3473 scoped_ptr<SpdyFrame> stream2_body( |
| 3474 spdy_util_.ConstructSpdyBodyFrame( |
| 3475 2, kPushedData, strlen(kPushedData), true)); |
| 3592 scoped_ptr<SpdyFrame> | 3476 scoped_ptr<SpdyFrame> |
| 3593 stream3_syn(spdy_util_.ConstructSpdyPush(NULL, | 3477 stream3_syn(spdy_util_.ConstructSpdyPush(NULL, |
| 3594 0, | 3478 0, |
| 3595 4, | 3479 4, |
| 3596 1, | 3480 1, |
| 3597 "http://www.google.com/foo.dat")); | 3481 "http://www.google.com/foo.dat")); |
| 3598 MockRead reads[] = { | 3482 MockRead reads[] = { |
| 3599 CreateMockRead(*stream1_reply, 2), | 3483 CreateMockRead(*stream1_reply, 2), |
| 3600 CreateMockRead(*stream2_syn, 3), | 3484 CreateMockRead(*stream2_syn, 3), |
| 3601 CreateMockRead(*stream3_syn, 4), | 3485 CreateMockRead(*stream3_syn, 4), |
| 3602 CreateMockRead(*stream1_body, 6, SYNCHRONOUS), | 3486 CreateMockRead(*stream1_body, 6, SYNCHRONOUS), |
| 3603 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame), | 3487 CreateMockRead(*stream2_body, 7), |
| 3604 arraysize(kPushBodyFrame), 7), | |
| 3605 MockRead(ASYNC, ERR_IO_PENDING, 8), // Force a pause | 3488 MockRead(ASYNC, ERR_IO_PENDING, 8), // Force a pause |
| 3606 }; | 3489 }; |
| 3607 | 3490 |
| 3608 HttpResponseInfo response; | 3491 HttpResponseInfo response; |
| 3609 HttpResponseInfo response2; | 3492 HttpResponseInfo response2; |
| 3610 std::string expected_push_result("pushed"); | 3493 std::string expected_push_result("pushed"); |
| 3611 OrderedSocketData data(reads, arraysize(reads), | 3494 OrderedSocketData data(reads, arraysize(reads), |
| 3612 writes, arraysize(writes)); | 3495 writes, arraysize(writes)); |
| 3613 RunServerPushTest(&data, | 3496 RunServerPushTest(&data, |
| 3614 &response, | 3497 &response, |
| 3615 &response2, | 3498 &response2, |
| 3616 expected_push_result); | 3499 expected_push_result); |
| 3617 | 3500 |
| 3618 // Verify the SYN_REPLY. | 3501 // Verify the SYN_REPLY. |
| 3619 EXPECT_TRUE(response.headers.get() != NULL); | 3502 EXPECT_TRUE(response.headers.get() != NULL); |
| 3620 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3503 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 3621 | 3504 |
| 3622 // Verify the pushed stream. | 3505 // Verify the pushed stream. |
| 3623 EXPECT_TRUE(response2.headers.get() != NULL); | 3506 EXPECT_TRUE(response2.headers.get() != NULL); |
| 3624 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 3507 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
| 3625 } | 3508 } |
| 3626 | 3509 |
| 3627 TEST_P(SpdyNetworkTransactionTest, ServerPushMultipleDataFrame) { | 3510 TEST_P(SpdyNetworkTransactionTest, ServerPushMultipleDataFrame) { |
| 3628 if (GetParam().protocol > kProtoSPDY3) | |
| 3629 return; | |
| 3630 | |
| 3631 static const unsigned char kPushBodyFrame1[] = { | |
| 3632 0x00, 0x00, 0x00, 0x02, // header, ID | |
| 3633 0x01, 0x00, 0x00, 0x1F, // FIN, length | |
| 3634 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | |
| 3635 }; | |
| 3636 static const char kPushBodyFrame2[] = " my darling"; | |
| 3637 static const char kPushBodyFrame3[] = " hello"; | |
| 3638 static const char kPushBodyFrame4[] = " my baby"; | |
| 3639 | |
| 3640 scoped_ptr<SpdyFrame> stream1_syn( | 3511 scoped_ptr<SpdyFrame> stream1_syn( |
| 3641 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 3512 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 3642 scoped_ptr<SpdyFrame> stream1_body( | 3513 scoped_ptr<SpdyFrame> stream1_body( |
| 3643 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 3514 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 3644 MockWrite writes[] = { | 3515 MockWrite writes[] = { |
| 3645 CreateMockWrite(*stream1_syn, 1), | 3516 CreateMockWrite(*stream1_syn, 1), |
| 3646 }; | 3517 }; |
| 3647 | 3518 |
| 3648 scoped_ptr<SpdyFrame> | 3519 scoped_ptr<SpdyFrame> |
| 3649 stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 3520 stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 3650 scoped_ptr<SpdyFrame> | 3521 scoped_ptr<SpdyFrame> |
| 3651 stream2_syn(spdy_util_.ConstructSpdyPush(NULL, | 3522 stream2_syn(spdy_util_.ConstructSpdyPush(NULL, |
| 3652 0, | 3523 0, |
| 3653 2, | 3524 2, |
| 3654 1, | 3525 1, |
| 3655 "http://www.google.com/foo.dat")); | 3526 "http://www.google.com/foo.dat")); |
| 3527 static const char kPushedData[] = "pushed my darling hello my baby"; |
| 3528 scoped_ptr<SpdyFrame> stream2_body_base( |
| 3529 spdy_util_.ConstructSpdyBodyFrame( |
| 3530 2, kPushedData, strlen(kPushedData), true)); |
| 3531 const size_t kChunkSize = strlen(kPushedData) / 4; |
| 3532 scoped_ptr<SpdyFrame> stream2_body1( |
| 3533 new SpdyFrame(stream2_body_base->data(), kChunkSize, false)); |
| 3534 scoped_ptr<SpdyFrame> stream2_body2( |
| 3535 new SpdyFrame(stream2_body_base->data() + kChunkSize, kChunkSize, false)); |
| 3536 scoped_ptr<SpdyFrame> stream2_body3( |
| 3537 new SpdyFrame(stream2_body_base->data() + 2 * kChunkSize, |
| 3538 kChunkSize, false)); |
| 3539 scoped_ptr<SpdyFrame> stream2_body4( |
| 3540 new SpdyFrame(stream2_body_base->data() + 3 * kChunkSize, |
| 3541 stream2_body_base->size() - 3 * kChunkSize, false)); |
| 3656 MockRead reads[] = { | 3542 MockRead reads[] = { |
| 3657 CreateMockRead(*stream1_reply, 2), | 3543 CreateMockRead(*stream1_reply, 2), |
| 3658 CreateMockRead(*stream2_syn, 3), | 3544 CreateMockRead(*stream2_syn, 3), |
| 3659 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame1), | 3545 CreateMockRead(*stream2_body1, 4), |
| 3660 arraysize(kPushBodyFrame1), 4), | 3546 CreateMockRead(*stream2_body2, 5), |
| 3661 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame2), | 3547 CreateMockRead(*stream2_body3, 6), |
| 3662 arraysize(kPushBodyFrame2) - 1, 5), | 3548 CreateMockRead(*stream2_body4, 7), |
| 3663 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame3), | |
| 3664 arraysize(kPushBodyFrame3) - 1, 6), | |
| 3665 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame4), | |
| 3666 arraysize(kPushBodyFrame4) - 1, 7), | |
| 3667 CreateMockRead(*stream1_body, 8, SYNCHRONOUS), | 3549 CreateMockRead(*stream1_body, 8, SYNCHRONOUS), |
| 3668 MockRead(ASYNC, ERR_IO_PENDING, 9), // Force a pause | 3550 MockRead(ASYNC, ERR_IO_PENDING, 9), // Force a pause |
| 3669 }; | 3551 }; |
| 3670 | 3552 |
| 3671 HttpResponseInfo response; | 3553 HttpResponseInfo response; |
| 3672 HttpResponseInfo response2; | 3554 HttpResponseInfo response2; |
| 3673 std::string expected_push_result("pushed my darling hello my baby"); | 3555 std::string expected_push_result("pushed my darling hello my baby"); |
| 3674 OrderedSocketData data(reads, arraysize(reads), | 3556 OrderedSocketData data(reads, arraysize(reads), |
| 3675 writes, arraysize(writes)); | 3557 writes, arraysize(writes)); |
| 3676 RunServerPushTest(&data, | 3558 RunServerPushTest(&data, &response, &response2, kPushedData); |
| 3677 &response, | |
| 3678 &response2, | |
| 3679 expected_push_result); | |
| 3680 | 3559 |
| 3681 // Verify the SYN_REPLY. | 3560 // Verify the SYN_REPLY. |
| 3682 EXPECT_TRUE(response.headers.get() != NULL); | 3561 EXPECT_TRUE(response.headers.get() != NULL); |
| 3683 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3562 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 3684 | 3563 |
| 3685 // Verify the pushed stream. | 3564 // Verify the pushed stream. |
| 3686 EXPECT_TRUE(response2.headers.get() != NULL); | 3565 EXPECT_TRUE(response2.headers.get() != NULL); |
| 3687 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 3566 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
| 3688 } | 3567 } |
| 3689 | 3568 |
| 3690 TEST_P(SpdyNetworkTransactionTest, ServerPushMultipleDataFrameInterrupted) { | 3569 TEST_P(SpdyNetworkTransactionTest, ServerPushMultipleDataFrameInterrupted) { |
| 3691 if (GetParam().protocol > kProtoSPDY3) | |
| 3692 return; | |
| 3693 | |
| 3694 static const unsigned char kPushBodyFrame1[] = { | |
| 3695 0x00, 0x00, 0x00, 0x02, // header, ID | |
| 3696 0x01, 0x00, 0x00, 0x1F, // FIN, length | |
| 3697 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | |
| 3698 }; | |
| 3699 static const char kPushBodyFrame2[] = " my darling"; | |
| 3700 static const char kPushBodyFrame3[] = " hello"; | |
| 3701 static const char kPushBodyFrame4[] = " my baby"; | |
| 3702 | |
| 3703 scoped_ptr<SpdyFrame> stream1_syn( | 3570 scoped_ptr<SpdyFrame> stream1_syn( |
| 3704 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 3571 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 3705 scoped_ptr<SpdyFrame> stream1_body( | 3572 scoped_ptr<SpdyFrame> stream1_body( |
| 3706 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 3573 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 3707 MockWrite writes[] = { | 3574 MockWrite writes[] = { |
| 3708 CreateMockWrite(*stream1_syn, 1), | 3575 CreateMockWrite(*stream1_syn, 1), |
| 3709 }; | 3576 }; |
| 3710 | 3577 |
| 3711 scoped_ptr<SpdyFrame> | 3578 scoped_ptr<SpdyFrame> |
| 3712 stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 3579 stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 3713 scoped_ptr<SpdyFrame> | 3580 scoped_ptr<SpdyFrame> |
| 3714 stream2_syn(spdy_util_.ConstructSpdyPush(NULL, | 3581 stream2_syn(spdy_util_.ConstructSpdyPush(NULL, |
| 3715 0, | 3582 0, |
| 3716 2, | 3583 2, |
| 3717 1, | 3584 1, |
| 3718 "http://www.google.com/foo.dat")); | 3585 "http://www.google.com/foo.dat")); |
| 3586 static const char kPushedData[] = "pushed my darling hello my baby"; |
| 3587 scoped_ptr<SpdyFrame> stream2_body_base( |
| 3588 spdy_util_.ConstructSpdyBodyFrame( |
| 3589 2, kPushedData, strlen(kPushedData), true)); |
| 3590 const size_t kChunkSize = strlen(kPushedData) / 4; |
| 3591 scoped_ptr<SpdyFrame> stream2_body1( |
| 3592 new SpdyFrame(stream2_body_base->data(), kChunkSize, false)); |
| 3593 scoped_ptr<SpdyFrame> stream2_body2( |
| 3594 new SpdyFrame(stream2_body_base->data() + kChunkSize, kChunkSize, false)); |
| 3595 scoped_ptr<SpdyFrame> stream2_body3( |
| 3596 new SpdyFrame(stream2_body_base->data() + 2 * kChunkSize, |
| 3597 kChunkSize, false)); |
| 3598 scoped_ptr<SpdyFrame> stream2_body4( |
| 3599 new SpdyFrame(stream2_body_base->data() + 3 * kChunkSize, |
| 3600 stream2_body_base->size() - 3 * kChunkSize, false)); |
| 3719 MockRead reads[] = { | 3601 MockRead reads[] = { |
| 3720 CreateMockRead(*stream1_reply, 2), | 3602 CreateMockRead(*stream1_reply, 2), |
| 3721 CreateMockRead(*stream2_syn, 3), | 3603 CreateMockRead(*stream2_syn, 3), |
| 3722 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame1), | 3604 CreateMockRead(*stream2_body1, 4), |
| 3723 arraysize(kPushBodyFrame1), 4), | 3605 CreateMockRead(*stream2_body2, 5), |
| 3724 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame2), | |
| 3725 arraysize(kPushBodyFrame2) - 1, 5), | |
| 3726 MockRead(ASYNC, ERR_IO_PENDING, 6), // Force a pause | 3606 MockRead(ASYNC, ERR_IO_PENDING, 6), // Force a pause |
| 3727 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame3), | 3607 CreateMockRead(*stream2_body3, 7), |
| 3728 arraysize(kPushBodyFrame3) - 1, 7), | 3608 CreateMockRead(*stream2_body4, 8), |
| 3729 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame4), | |
| 3730 arraysize(kPushBodyFrame4) - 1, 8), | |
| 3731 CreateMockRead(*stream1_body.get(), 9, SYNCHRONOUS), | 3609 CreateMockRead(*stream1_body.get(), 9, SYNCHRONOUS), |
| 3732 MockRead(ASYNC, ERR_IO_PENDING, 10) // Force a pause. | 3610 MockRead(ASYNC, ERR_IO_PENDING, 10) // Force a pause. |
| 3733 }; | 3611 }; |
| 3734 | 3612 |
| 3735 HttpResponseInfo response; | 3613 HttpResponseInfo response; |
| 3736 HttpResponseInfo response2; | 3614 HttpResponseInfo response2; |
| 3737 std::string expected_push_result("pushed my darling hello my baby"); | |
| 3738 OrderedSocketData data(reads, arraysize(reads), | 3615 OrderedSocketData data(reads, arraysize(reads), |
| 3739 writes, arraysize(writes)); | 3616 writes, arraysize(writes)); |
| 3740 RunServerPushTest(&data, | 3617 RunServerPushTest(&data, &response, &response2, kPushedData); |
| 3741 &response, | |
| 3742 &response2, | |
| 3743 expected_push_result); | |
| 3744 | 3618 |
| 3745 // Verify the SYN_REPLY. | 3619 // Verify the SYN_REPLY. |
| 3746 EXPECT_TRUE(response.headers.get() != NULL); | 3620 EXPECT_TRUE(response.headers.get() != NULL); |
| 3747 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3621 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 3748 | 3622 |
| 3749 // Verify the pushed stream. | 3623 // Verify the pushed stream. |
| 3750 EXPECT_TRUE(response2.headers.get() != NULL); | 3624 EXPECT_TRUE(response2.headers.get() != NULL); |
| 3751 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 3625 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
| 3752 } | 3626 } |
| 3753 | 3627 |
| 3754 TEST_P(SpdyNetworkTransactionTest, ServerPushInvalidAssociatedStreamID0) { | 3628 TEST_P(SpdyNetworkTransactionTest, ServerPushInvalidAssociatedStreamID0) { |
| 3755 if (GetParam().protocol > kProtoSPDY3) | |
| 3756 return; | |
| 3757 | |
| 3758 scoped_ptr<SpdyFrame> stream1_syn( | 3629 scoped_ptr<SpdyFrame> stream1_syn( |
| 3759 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 3630 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 3760 scoped_ptr<SpdyFrame> stream1_body( | 3631 scoped_ptr<SpdyFrame> stream1_body( |
| 3761 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 3632 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 3762 scoped_ptr<SpdyFrame> stream2_rst( | 3633 scoped_ptr<SpdyFrame> stream2_rst( |
| 3763 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_REFUSED_STREAM)); | 3634 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_REFUSED_STREAM)); |
| 3764 MockWrite writes[] = { | 3635 MockWrite writes[] = { |
| 3765 CreateMockWrite(*stream1_syn, 1), | 3636 CreateMockWrite(*stream1_syn, 1), |
| 3766 CreateMockWrite(*stream2_rst, 4), | 3637 CreateMockWrite(*stream2_rst, 4), |
| 3767 }; | 3638 }; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3809 << " Write index: " | 3680 << " Write index: " |
| 3810 << data.write_index(); | 3681 << data.write_index(); |
| 3811 | 3682 |
| 3812 // Verify the SYN_REPLY. | 3683 // Verify the SYN_REPLY. |
| 3813 HttpResponseInfo response = *trans->GetResponseInfo(); | 3684 HttpResponseInfo response = *trans->GetResponseInfo(); |
| 3814 EXPECT_TRUE(response.headers.get() != NULL); | 3685 EXPECT_TRUE(response.headers.get() != NULL); |
| 3815 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3686 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 3816 } | 3687 } |
| 3817 | 3688 |
| 3818 TEST_P(SpdyNetworkTransactionTest, ServerPushInvalidAssociatedStreamID9) { | 3689 TEST_P(SpdyNetworkTransactionTest, ServerPushInvalidAssociatedStreamID9) { |
| 3819 if (GetParam().protocol > kProtoSPDY3) | |
| 3820 return; | |
| 3821 | |
| 3822 scoped_ptr<SpdyFrame> stream1_syn( | 3690 scoped_ptr<SpdyFrame> stream1_syn( |
| 3823 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 3691 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 3824 scoped_ptr<SpdyFrame> stream1_body( | 3692 scoped_ptr<SpdyFrame> stream1_body( |
| 3825 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 3693 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 3826 scoped_ptr<SpdyFrame> stream2_rst( | 3694 scoped_ptr<SpdyFrame> stream2_rst( |
| 3827 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_INVALID_STREAM)); | 3695 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_INVALID_STREAM)); |
| 3828 MockWrite writes[] = { | 3696 MockWrite writes[] = { |
| 3829 CreateMockWrite(*stream1_syn, 1), | 3697 CreateMockWrite(*stream1_syn, 1), |
| 3830 CreateMockWrite(*stream2_rst, 4), | 3698 CreateMockWrite(*stream2_rst, 4), |
| 3831 }; | 3699 }; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3873 << " Write index: " | 3741 << " Write index: " |
| 3874 << data.write_index(); | 3742 << data.write_index(); |
| 3875 | 3743 |
| 3876 // Verify the SYN_REPLY. | 3744 // Verify the SYN_REPLY. |
| 3877 HttpResponseInfo response = *trans->GetResponseInfo(); | 3745 HttpResponseInfo response = *trans->GetResponseInfo(); |
| 3878 EXPECT_TRUE(response.headers.get() != NULL); | 3746 EXPECT_TRUE(response.headers.get() != NULL); |
| 3879 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3747 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 3880 } | 3748 } |
| 3881 | 3749 |
| 3882 TEST_P(SpdyNetworkTransactionTest, ServerPushNoURL) { | 3750 TEST_P(SpdyNetworkTransactionTest, ServerPushNoURL) { |
| 3883 if (GetParam().protocol > kProtoSPDY3) | |
| 3884 return; | |
| 3885 | |
| 3886 scoped_ptr<SpdyFrame> stream1_syn( | 3751 scoped_ptr<SpdyFrame> stream1_syn( |
| 3887 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 3752 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 3888 scoped_ptr<SpdyFrame> stream1_body( | 3753 scoped_ptr<SpdyFrame> stream1_body( |
| 3889 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 3754 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 3890 scoped_ptr<SpdyFrame> stream2_rst( | 3755 scoped_ptr<SpdyFrame> stream2_rst( |
| 3891 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_PROTOCOL_ERROR)); | 3756 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_PROTOCOL_ERROR)); |
| 3892 MockWrite writes[] = { | 3757 MockWrite writes[] = { |
| 3893 CreateMockWrite(*stream1_syn, 1), | 3758 CreateMockWrite(*stream1_syn, 1), |
| 3894 CreateMockWrite(*stream2_rst, 4), | 3759 CreateMockWrite(*stream2_rst, 4), |
| 3895 }; | 3760 }; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3945 | 3810 |
| 3946 // Verify the SYN_REPLY. | 3811 // Verify the SYN_REPLY. |
| 3947 HttpResponseInfo response = *trans->GetResponseInfo(); | 3812 HttpResponseInfo response = *trans->GetResponseInfo(); |
| 3948 EXPECT_TRUE(response.headers.get() != NULL); | 3813 EXPECT_TRUE(response.headers.get() != NULL); |
| 3949 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3814 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 3950 } | 3815 } |
| 3951 | 3816 |
| 3952 // Verify that various SynReply headers parse correctly through the | 3817 // Verify that various SynReply headers parse correctly through the |
| 3953 // HTTP layer. | 3818 // HTTP layer. |
| 3954 TEST_P(SpdyNetworkTransactionTest, SynReplyHeaders) { | 3819 TEST_P(SpdyNetworkTransactionTest, SynReplyHeaders) { |
| 3955 if (GetParam().protocol > kProtoSPDY3) | |
| 3956 return; | |
| 3957 | |
| 3958 struct SynReplyHeadersTests { | 3820 struct SynReplyHeadersTests { |
| 3959 int num_headers; | 3821 int num_headers; |
| 3960 const char* extra_headers[5]; | 3822 const char* extra_headers[5]; |
| 3961 SpdyHeaderBlock expected_headers; | 3823 SpdyHeaderBlock expected_headers; |
| 3962 } test_cases[] = { | 3824 } test_cases[] = { |
| 3963 // This uses a multi-valued cookie header. | 3825 // This uses a multi-valued cookie header. |
| 3964 { 2, | 3826 { 2, |
| 3965 { "cookie", "val1", | 3827 { "cookie", "val1", |
| 3966 "cookie", "val2", // will get appended separated by NULL | 3828 "cookie", "val2", // will get appended separated by NULL |
| 3967 NULL | 3829 NULL |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4035 header_block[name] += value; | 3897 header_block[name] += value; |
| 4036 } | 3898 } |
| 4037 } | 3899 } |
| 4038 EXPECT_EQ(test_cases[i].expected_headers, header_block); | 3900 EXPECT_EQ(test_cases[i].expected_headers, header_block); |
| 4039 } | 3901 } |
| 4040 } | 3902 } |
| 4041 | 3903 |
| 4042 // Verify that various SynReply headers parse vary fields correctly | 3904 // Verify that various SynReply headers parse vary fields correctly |
| 4043 // through the HTTP layer, and the response matches the request. | 3905 // through the HTTP layer, and the response matches the request. |
| 4044 TEST_P(SpdyNetworkTransactionTest, SynReplyHeadersVary) { | 3906 TEST_P(SpdyNetworkTransactionTest, SynReplyHeadersVary) { |
| 4045 if (GetParam().protocol > kProtoSPDY3) | |
| 4046 return; | |
| 4047 | |
| 4048 static const SpdyHeaderInfo syn_reply_info = { | 3907 static const SpdyHeaderInfo syn_reply_info = { |
| 4049 SYN_REPLY, // Syn Reply | 3908 SYN_REPLY, // Syn Reply |
| 4050 1, // Stream ID | 3909 1, // Stream ID |
| 4051 0, // Associated Stream ID | 3910 0, // Associated Stream ID |
| 4052 ConvertRequestPriorityToSpdyPriority( | 3911 ConvertRequestPriorityToSpdyPriority( |
| 4053 LOWEST, spdy_util_.spdy_version()), | 3912 LOWEST, spdy_util_.spdy_version()), |
| 4054 kSpdyCredentialSlotUnused, | 3913 kSpdyCredentialSlotUnused, |
| 4055 CONTROL_FLAG_NONE, // Control Flags | 3914 CONTROL_FLAG_NONE, // Control Flags |
| 4056 false, // Compressed | 3915 false, // Compressed |
| 4057 RST_STREAM_INVALID, // Status | 3916 RST_STREAM_INVALID, // Status |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4207 test_cases[i].num_headers[1], | 4066 test_cases[i].num_headers[1], |
| 4208 &reply_headers); | 4067 &reply_headers); |
| 4209 std::string expected_reply = | 4068 std::string expected_reply = |
| 4210 spdy_util_.ConstructSpdyReplyString(reply_headers); | 4069 spdy_util_.ConstructSpdyReplyString(reply_headers); |
| 4211 EXPECT_EQ(expected_reply, lines) << i; | 4070 EXPECT_EQ(expected_reply, lines) << i; |
| 4212 } | 4071 } |
| 4213 } | 4072 } |
| 4214 | 4073 |
| 4215 // Verify that we don't crash on invalid SynReply responses. | 4074 // Verify that we don't crash on invalid SynReply responses. |
| 4216 TEST_P(SpdyNetworkTransactionTest, InvalidSynReply) { | 4075 TEST_P(SpdyNetworkTransactionTest, InvalidSynReply) { |
| 4217 if (GetParam().protocol > kProtoSPDY3) | |
| 4218 return; | |
| 4219 | |
| 4220 const SpdyHeaderInfo kSynStartHeader = { | 4076 const SpdyHeaderInfo kSynStartHeader = { |
| 4221 SYN_REPLY, // Kind = SynReply | 4077 SYN_REPLY, // Kind = SynReply |
| 4222 1, // Stream ID | 4078 1, // Stream ID |
| 4223 0, // Associated stream ID | 4079 0, // Associated stream ID |
| 4224 ConvertRequestPriorityToSpdyPriority( | 4080 ConvertRequestPriorityToSpdyPriority( |
| 4225 LOWEST, spdy_util_.spdy_version()), | 4081 LOWEST, spdy_util_.spdy_version()), |
| 4226 kSpdyCredentialSlotUnused, | 4082 kSpdyCredentialSlotUnused, |
| 4227 CONTROL_FLAG_NONE, // Control Flags | 4083 CONTROL_FLAG_NONE, // Control Flags |
| 4228 false, // Compressed | 4084 false, // Compressed |
| 4229 RST_STREAM_INVALID, // Status | 4085 RST_STREAM_INVALID, // Status |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4282 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 4138 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 4283 BoundNetLog(), GetParam(), NULL); | 4139 BoundNetLog(), GetParam(), NULL); |
| 4284 helper.RunToCompletion(&data); | 4140 helper.RunToCompletion(&data); |
| 4285 TransactionHelperResult out = helper.output(); | 4141 TransactionHelperResult out = helper.output(); |
| 4286 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); | 4142 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); |
| 4287 } | 4143 } |
| 4288 } | 4144 } |
| 4289 | 4145 |
| 4290 // Verify that we don't crash on some corrupt frames. | 4146 // Verify that we don't crash on some corrupt frames. |
| 4291 TEST_P(SpdyNetworkTransactionTest, CorruptFrameSessionError) { | 4147 TEST_P(SpdyNetworkTransactionTest, CorruptFrameSessionError) { |
| 4292 if (GetParam().protocol > kProtoSPDY3) | |
| 4293 return; | |
| 4294 | |
| 4295 // This is the length field that's too short. | 4148 // This is the length field that's too short. |
| 4296 scoped_ptr<SpdyFrame> syn_reply_wrong_length( | 4149 scoped_ptr<SpdyFrame> syn_reply_wrong_length( |
| 4297 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 4150 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 4298 size_t wrong_size = syn_reply_wrong_length->size() - 4; | |
| 4299 BufferedSpdyFramer framer(spdy_util_.spdy_version(), false); | 4151 BufferedSpdyFramer framer(spdy_util_.spdy_version(), false); |
| 4152 size_t right_size = |
| 4153 (spdy_util_.spdy_version() < SPDY4) ? |
| 4154 syn_reply_wrong_length->size() - framer.GetControlFrameHeaderSize() : |
| 4155 syn_reply_wrong_length->size(); |
| 4156 size_t wrong_size = right_size - 4; |
| 4300 test::SetFrameLength(syn_reply_wrong_length.get(), | 4157 test::SetFrameLength(syn_reply_wrong_length.get(), |
| 4301 wrong_size - framer.GetControlFrameHeaderSize(), | 4158 wrong_size, |
| 4302 spdy_util_.spdy_version()); | 4159 spdy_util_.spdy_version()); |
| 4303 | 4160 |
| 4304 struct SynReplyTests { | 4161 struct SynReplyTests { |
| 4305 const SpdyFrame* syn_reply; | 4162 const SpdyFrame* syn_reply; |
| 4306 } test_cases[] = { | 4163 } test_cases[] = { |
| 4307 { syn_reply_wrong_length.get(), }, | 4164 { syn_reply_wrong_length.get(), }, |
| 4308 }; | 4165 }; |
| 4309 | 4166 |
| 4310 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { | 4167 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { |
| 4311 scoped_ptr<SpdyFrame> req( | 4168 scoped_ptr<SpdyFrame> req( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 4325 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 4182 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 4326 BoundNetLog(), GetParam(), NULL); | 4183 BoundNetLog(), GetParam(), NULL); |
| 4327 helper.RunToCompletion(&data); | 4184 helper.RunToCompletion(&data); |
| 4328 TransactionHelperResult out = helper.output(); | 4185 TransactionHelperResult out = helper.output(); |
| 4329 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); | 4186 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); |
| 4330 } | 4187 } |
| 4331 } | 4188 } |
| 4332 | 4189 |
| 4333 // Test that we shutdown correctly on write errors. | 4190 // Test that we shutdown correctly on write errors. |
| 4334 TEST_P(SpdyNetworkTransactionTest, WriteError) { | 4191 TEST_P(SpdyNetworkTransactionTest, WriteError) { |
| 4335 if (GetParam().protocol > kProtoSPDY3) | |
| 4336 return; | |
| 4337 | |
| 4338 scoped_ptr<SpdyFrame> req( | 4192 scoped_ptr<SpdyFrame> req( |
| 4339 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 4193 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 4340 MockWrite writes[] = { | 4194 MockWrite writes[] = { |
| 4341 // We'll write 10 bytes successfully | 4195 // We'll write 10 bytes successfully |
| 4342 MockWrite(ASYNC, req->data(), 10), | 4196 MockWrite(ASYNC, req->data(), 10), |
| 4343 // Followed by ERROR! | 4197 // Followed by ERROR! |
| 4344 MockWrite(ASYNC, ERR_FAILED), | 4198 MockWrite(ASYNC, ERR_FAILED), |
| 4345 }; | 4199 }; |
| 4346 | 4200 |
| 4347 DelayedSocketData data(2, NULL, 0, | 4201 DelayedSocketData data(2, NULL, 0, |
| 4348 writes, arraysize(writes)); | 4202 writes, arraysize(writes)); |
| 4349 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 4203 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 4350 BoundNetLog(), GetParam(), NULL); | 4204 BoundNetLog(), GetParam(), NULL); |
| 4351 helper.RunToCompletion(&data); | 4205 helper.RunToCompletion(&data); |
| 4352 TransactionHelperResult out = helper.output(); | 4206 TransactionHelperResult out = helper.output(); |
| 4353 EXPECT_EQ(ERR_FAILED, out.rv); | 4207 EXPECT_EQ(ERR_FAILED, out.rv); |
| 4354 data.Reset(); | 4208 data.Reset(); |
| 4355 } | 4209 } |
| 4356 | 4210 |
| 4357 // Test that partial writes work. | 4211 // Test that partial writes work. |
| 4358 TEST_P(SpdyNetworkTransactionTest, PartialWrite) { | 4212 TEST_P(SpdyNetworkTransactionTest, PartialWrite) { |
| 4359 if (GetParam().protocol > kProtoSPDY3) | |
| 4360 return; | |
| 4361 | |
| 4362 // Chop the SYN_STREAM frame into 5 chunks. | 4213 // Chop the SYN_STREAM frame into 5 chunks. |
| 4363 scoped_ptr<SpdyFrame> req( | 4214 scoped_ptr<SpdyFrame> req( |
| 4364 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 4215 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 4365 const int kChunks = 5; | 4216 const int kChunks = 5; |
| 4366 scoped_ptr<MockWrite[]> writes(ChopWriteFrame(*req.get(), kChunks)); | 4217 scoped_ptr<MockWrite[]> writes(ChopWriteFrame(*req.get(), kChunks)); |
| 4367 | 4218 |
| 4368 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 4219 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 4369 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 4220 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 4370 MockRead reads[] = { | 4221 MockRead reads[] = { |
| 4371 CreateMockRead(*resp), | 4222 CreateMockRead(*resp), |
| 4372 CreateMockRead(*body), | 4223 CreateMockRead(*body), |
| 4373 MockRead(ASYNC, 0, 0) // EOF | 4224 MockRead(ASYNC, 0, 0) // EOF |
| 4374 }; | 4225 }; |
| 4375 | 4226 |
| 4376 DelayedSocketData data(kChunks, reads, arraysize(reads), | 4227 DelayedSocketData data(kChunks, reads, arraysize(reads), |
| 4377 writes.get(), kChunks); | 4228 writes.get(), kChunks); |
| 4378 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 4229 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 4379 BoundNetLog(), GetParam(), NULL); | 4230 BoundNetLog(), GetParam(), NULL); |
| 4380 helper.RunToCompletion(&data); | 4231 helper.RunToCompletion(&data); |
| 4381 TransactionHelperResult out = helper.output(); | 4232 TransactionHelperResult out = helper.output(); |
| 4382 EXPECT_EQ(OK, out.rv); | 4233 EXPECT_EQ(OK, out.rv); |
| 4383 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 4234 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 4384 EXPECT_EQ("hello!", out.response_data); | 4235 EXPECT_EQ("hello!", out.response_data); |
| 4385 } | 4236 } |
| 4386 | 4237 |
| 4387 // In this test, we enable compression, but get a uncompressed SynReply from | 4238 // In this test, we enable compression, but get a uncompressed SynReply from |
| 4388 // the server. Verify that teardown is all clean. | 4239 // the server. Verify that teardown is all clean. |
| 4389 TEST_P(SpdyNetworkTransactionTest, DecompressFailureOnSynReply) { | 4240 TEST_P(SpdyNetworkTransactionTest, DecompressFailureOnSynReply) { |
| 4390 if (GetParam().protocol > kProtoSPDY3) | |
| 4391 return; | |
| 4392 | |
| 4393 scoped_ptr<SpdyFrame> compressed( | 4241 scoped_ptr<SpdyFrame> compressed( |
| 4394 spdy_util_.ConstructSpdyGet(NULL, 0, true, 1, LOWEST, true)); | 4242 spdy_util_.ConstructSpdyGet(NULL, 0, true, 1, LOWEST, true)); |
| 4395 scoped_ptr<SpdyFrame> rst( | 4243 scoped_ptr<SpdyFrame> rst( |
| 4396 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); | 4244 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); |
| 4397 MockWrite writes[] = { | 4245 MockWrite writes[] = { |
| 4398 CreateMockWrite(*compressed), | 4246 CreateMockWrite(*compressed), |
| 4399 }; | 4247 }; |
| 4400 | 4248 |
| 4401 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 4249 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 4402 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 4250 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 4403 MockRead reads[] = { | 4251 MockRead reads[] = { |
| 4404 CreateMockRead(*resp), | 4252 CreateMockRead(*resp), |
| 4405 }; | 4253 }; |
| 4406 | 4254 |
| 4407 DelayedSocketData data(1, reads, arraysize(reads), | 4255 DelayedSocketData data(1, reads, arraysize(reads), |
| 4408 writes, arraysize(writes)); | 4256 writes, arraysize(writes)); |
| 4409 SpdySessionDependencies* session_deps = | 4257 SpdySessionDependencies* session_deps = |
| 4410 CreateSpdySessionDependencies(GetParam()); | 4258 CreateSpdySessionDependencies(GetParam()); |
| 4411 session_deps->enable_compression = true; | 4259 session_deps->enable_compression = true; |
| 4412 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 4260 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 4413 BoundNetLog(), GetParam(), session_deps); | 4261 BoundNetLog(), GetParam(), session_deps); |
| 4414 helper.RunToCompletion(&data); | 4262 helper.RunToCompletion(&data); |
| 4415 TransactionHelperResult out = helper.output(); | 4263 TransactionHelperResult out = helper.output(); |
| 4416 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); | 4264 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); |
| 4417 data.Reset(); | 4265 data.Reset(); |
| 4418 } | 4266 } |
| 4419 | 4267 |
| 4420 // Test that the NetLog contains good data for a simple GET request. | 4268 // Test that the NetLog contains good data for a simple GET request. |
| 4421 TEST_P(SpdyNetworkTransactionTest, NetLog) { | 4269 TEST_P(SpdyNetworkTransactionTest, NetLog) { |
| 4422 if (GetParam().protocol > kProtoSPDY3) | |
| 4423 return; | |
| 4424 | |
| 4425 static const char* const kExtraHeaders[] = { | 4270 static const char* const kExtraHeaders[] = { |
| 4426 "user-agent", "Chrome", | 4271 "user-agent", "Chrome", |
| 4427 }; | 4272 }; |
| 4428 scoped_ptr<SpdyFrame> req( | 4273 scoped_ptr<SpdyFrame> req( |
| 4429 spdy_util_.ConstructSpdyGet(kExtraHeaders, 1, false, 1, LOWEST, true)); | 4274 spdy_util_.ConstructSpdyGet(kExtraHeaders, 1, false, 1, LOWEST, true)); |
| 4430 MockWrite writes[] = { CreateMockWrite(*req) }; | 4275 MockWrite writes[] = { CreateMockWrite(*req) }; |
| 4431 | 4276 |
| 4432 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 4277 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 4433 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 4278 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 4434 MockRead reads[] = { | 4279 MockRead reads[] = { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4503 EXPECT_NE(header_list->end(), header_list->Find(header)) << | 4348 EXPECT_NE(header_list->end(), header_list->Find(header)) << |
| 4504 "Header not found: " << *it; | 4349 "Header not found: " << *it; |
| 4505 } | 4350 } |
| 4506 } | 4351 } |
| 4507 | 4352 |
| 4508 // Since we buffer the IO from the stream to the renderer, this test verifies | 4353 // Since we buffer the IO from the stream to the renderer, this test verifies |
| 4509 // that when we read out the maximum amount of data (e.g. we received 50 bytes | 4354 // that when we read out the maximum amount of data (e.g. we received 50 bytes |
| 4510 // on the network, but issued a Read for only 5 of those bytes) that the data | 4355 // on the network, but issued a Read for only 5 of those bytes) that the data |
| 4511 // flow still works correctly. | 4356 // flow still works correctly. |
| 4512 TEST_P(SpdyNetworkTransactionTest, BufferFull) { | 4357 TEST_P(SpdyNetworkTransactionTest, BufferFull) { |
| 4513 if (GetParam().protocol > kProtoSPDY3) | |
| 4514 return; | |
| 4515 | |
| 4516 BufferedSpdyFramer framer(spdy_util_.spdy_version(), false); | 4358 BufferedSpdyFramer framer(spdy_util_.spdy_version(), false); |
| 4517 | 4359 |
| 4518 scoped_ptr<SpdyFrame> req( | 4360 scoped_ptr<SpdyFrame> req( |
| 4519 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 4361 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 4520 MockWrite writes[] = { CreateMockWrite(*req) }; | 4362 MockWrite writes[] = { CreateMockWrite(*req) }; |
| 4521 | 4363 |
| 4522 // 2 data frames in a single read. | 4364 // 2 data frames in a single read. |
| 4523 scoped_ptr<SpdyFrame> data_frame_1( | 4365 scoped_ptr<SpdyFrame> data_frame_1( |
| 4524 framer.CreateDataFrame(1, "goodby", 6, DATA_FLAG_NONE)); | 4366 framer.CreateDataFrame(1, "goodby", 6, DATA_FLAG_NONE)); |
| 4525 scoped_ptr<SpdyFrame> data_frame_2( | 4367 scoped_ptr<SpdyFrame> data_frame_2( |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4600 | 4442 |
| 4601 EXPECT_EQ(OK, out.rv); | 4443 EXPECT_EQ(OK, out.rv); |
| 4602 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 4444 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 4603 EXPECT_EQ("goodbye world", out.response_data); | 4445 EXPECT_EQ("goodbye world", out.response_data); |
| 4604 } | 4446 } |
| 4605 | 4447 |
| 4606 // Verify that basic buffering works; when multiple data frames arrive | 4448 // Verify that basic buffering works; when multiple data frames arrive |
| 4607 // at the same time, ensure that we don't notify a read completion for | 4449 // at the same time, ensure that we don't notify a read completion for |
| 4608 // each data frame individually. | 4450 // each data frame individually. |
| 4609 TEST_P(SpdyNetworkTransactionTest, Buffering) { | 4451 TEST_P(SpdyNetworkTransactionTest, Buffering) { |
| 4610 if (GetParam().protocol > kProtoSPDY3) | |
| 4611 return; | |
| 4612 | |
| 4613 BufferedSpdyFramer framer(spdy_util_.spdy_version(), false); | 4452 BufferedSpdyFramer framer(spdy_util_.spdy_version(), false); |
| 4614 | 4453 |
| 4615 scoped_ptr<SpdyFrame> req( | 4454 scoped_ptr<SpdyFrame> req( |
| 4616 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 4455 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 4617 MockWrite writes[] = { CreateMockWrite(*req) }; | 4456 MockWrite writes[] = { CreateMockWrite(*req) }; |
| 4618 | 4457 |
| 4619 // 4 data frames in a single read. | 4458 // 4 data frames in a single read. |
| 4620 scoped_ptr<SpdyFrame> data_frame( | 4459 scoped_ptr<SpdyFrame> data_frame( |
| 4621 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); | 4460 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); |
| 4622 scoped_ptr<SpdyFrame> data_frame_fin( | 4461 scoped_ptr<SpdyFrame> data_frame_fin( |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4698 // Verify that we consumed all test data. | 4537 // Verify that we consumed all test data. |
| 4699 helper.VerifyDataConsumed(); | 4538 helper.VerifyDataConsumed(); |
| 4700 | 4539 |
| 4701 EXPECT_EQ(OK, out.rv); | 4540 EXPECT_EQ(OK, out.rv); |
| 4702 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 4541 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 4703 EXPECT_EQ("messagemessagemessagemessage", out.response_data); | 4542 EXPECT_EQ("messagemessagemessagemessage", out.response_data); |
| 4704 } | 4543 } |
| 4705 | 4544 |
| 4706 // Verify the case where we buffer data but read it after it has been buffered. | 4545 // Verify the case where we buffer data but read it after it has been buffered. |
| 4707 TEST_P(SpdyNetworkTransactionTest, BufferedAll) { | 4546 TEST_P(SpdyNetworkTransactionTest, BufferedAll) { |
| 4708 if (GetParam().protocol > kProtoSPDY3) | |
| 4709 return; | |
| 4710 | |
| 4711 BufferedSpdyFramer framer(spdy_util_.spdy_version(), false); | 4547 BufferedSpdyFramer framer(spdy_util_.spdy_version(), false); |
| 4712 | 4548 |
| 4713 scoped_ptr<SpdyFrame> req( | 4549 scoped_ptr<SpdyFrame> req( |
| 4714 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 4550 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 4715 MockWrite writes[] = { CreateMockWrite(*req) }; | 4551 MockWrite writes[] = { CreateMockWrite(*req) }; |
| 4716 | 4552 |
| 4717 // 5 data frames in a single read. | 4553 // 5 data frames in a single read. |
| 4718 scoped_ptr<SpdyFrame> syn_reply( | 4554 scoped_ptr<SpdyFrame> syn_reply( |
| 4719 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 4555 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 4720 // turn off FIN bit | 4556 // turn off FIN bit |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4795 // Verify that we consumed all test data. | 4631 // Verify that we consumed all test data. |
| 4796 helper.VerifyDataConsumed(); | 4632 helper.VerifyDataConsumed(); |
| 4797 | 4633 |
| 4798 EXPECT_EQ(OK, out.rv); | 4634 EXPECT_EQ(OK, out.rv); |
| 4799 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 4635 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 4800 EXPECT_EQ("messagemessagemessagemessage", out.response_data); | 4636 EXPECT_EQ("messagemessagemessagemessage", out.response_data); |
| 4801 } | 4637 } |
| 4802 | 4638 |
| 4803 // Verify the case where we buffer data and close the connection. | 4639 // Verify the case where we buffer data and close the connection. |
| 4804 TEST_P(SpdyNetworkTransactionTest, BufferedClosed) { | 4640 TEST_P(SpdyNetworkTransactionTest, BufferedClosed) { |
| 4805 if (GetParam().protocol > kProtoSPDY3) | |
| 4806 return; | |
| 4807 | |
| 4808 BufferedSpdyFramer framer(spdy_util_.spdy_version(), false); | 4641 BufferedSpdyFramer framer(spdy_util_.spdy_version(), false); |
| 4809 | 4642 |
| 4810 scoped_ptr<SpdyFrame> req( | 4643 scoped_ptr<SpdyFrame> req( |
| 4811 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 4644 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 4812 MockWrite writes[] = { CreateMockWrite(*req) }; | 4645 MockWrite writes[] = { CreateMockWrite(*req) }; |
| 4813 | 4646 |
| 4814 // All data frames in a single read. | 4647 // All data frames in a single read. |
| 4815 // NOTE: We don't FIN the stream. | 4648 // NOTE: We don't FIN the stream. |
| 4816 scoped_ptr<SpdyFrame> data_frame( | 4649 scoped_ptr<SpdyFrame> data_frame( |
| 4817 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); | 4650 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4889 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the | 4722 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the |
| 4890 // MockClientSocketFactory) are still alive. | 4723 // MockClientSocketFactory) are still alive. |
| 4891 base::MessageLoop::current()->RunUntilIdle(); | 4724 base::MessageLoop::current()->RunUntilIdle(); |
| 4892 | 4725 |
| 4893 // Verify that we consumed all test data. | 4726 // Verify that we consumed all test data. |
| 4894 helper.VerifyDataConsumed(); | 4727 helper.VerifyDataConsumed(); |
| 4895 } | 4728 } |
| 4896 | 4729 |
| 4897 // Verify the case where we buffer data and cancel the transaction. | 4730 // Verify the case where we buffer data and cancel the transaction. |
| 4898 TEST_P(SpdyNetworkTransactionTest, BufferedCancelled) { | 4731 TEST_P(SpdyNetworkTransactionTest, BufferedCancelled) { |
| 4899 if (GetParam().protocol > kProtoSPDY3) | |
| 4900 return; | |
| 4901 | |
| 4902 BufferedSpdyFramer framer(spdy_util_.spdy_version(), false); | 4732 BufferedSpdyFramer framer(spdy_util_.spdy_version(), false); |
| 4903 | 4733 |
| 4904 scoped_ptr<SpdyFrame> req( | 4734 scoped_ptr<SpdyFrame> req( |
| 4905 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 4735 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 4906 MockWrite writes[] = { CreateMockWrite(*req) }; | 4736 MockWrite writes[] = { CreateMockWrite(*req) }; |
| 4907 | 4737 |
| 4908 // NOTE: We don't FIN the stream. | 4738 // NOTE: We don't FIN the stream. |
| 4909 scoped_ptr<SpdyFrame> data_frame( | 4739 scoped_ptr<SpdyFrame> data_frame( |
| 4910 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); | 4740 framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); |
| 4911 | 4741 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4964 // to run for the final time. | 4794 // to run for the final time. |
| 4965 base::MessageLoop::current()->RunUntilIdle(); | 4795 base::MessageLoop::current()->RunUntilIdle(); |
| 4966 | 4796 |
| 4967 // Verify that we consumed all test data. | 4797 // Verify that we consumed all test data. |
| 4968 helper.VerifyDataConsumed(); | 4798 helper.VerifyDataConsumed(); |
| 4969 } | 4799 } |
| 4970 | 4800 |
| 4971 // Test that if the server requests persistence of settings, that we save | 4801 // Test that if the server requests persistence of settings, that we save |
| 4972 // the settings in the HttpServerProperties. | 4802 // the settings in the HttpServerProperties. |
| 4973 TEST_P(SpdyNetworkTransactionTest, SettingsSaved) { | 4803 TEST_P(SpdyNetworkTransactionTest, SettingsSaved) { |
| 4974 if (GetParam().protocol > kProtoSPDY3) | |
| 4975 return; | |
| 4976 | |
| 4977 static const SpdyHeaderInfo kSynReplyInfo = { | 4804 static const SpdyHeaderInfo kSynReplyInfo = { |
| 4978 SYN_REPLY, // Syn Reply | 4805 SYN_REPLY, // Syn Reply |
| 4979 1, // Stream ID | 4806 1, // Stream ID |
| 4980 0, // Associated Stream ID | 4807 0, // Associated Stream ID |
| 4981 ConvertRequestPriorityToSpdyPriority( | 4808 ConvertRequestPriorityToSpdyPriority( |
| 4982 LOWEST, spdy_util_.spdy_version()), | 4809 LOWEST, spdy_util_.spdy_version()), |
| 4983 kSpdyCredentialSlotUnused, | 4810 kSpdyCredentialSlotUnused, |
| 4984 CONTROL_FLAG_NONE, // Control Flags | 4811 CONTROL_FLAG_NONE, // Control Flags |
| 4985 false, // Compressed | 4812 false, // Compressed |
| 4986 RST_STREAM_INVALID, // Status | 4813 RST_STREAM_INVALID, // Status |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5071 EXPECT_TRUE(it3 != settings_map.end()); | 4898 EXPECT_TRUE(it3 != settings_map.end()); |
| 5072 SettingsFlagsAndValue flags_and_value3 = it3->second; | 4899 SettingsFlagsAndValue flags_and_value3 = it3->second; |
| 5073 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value3.first); | 4900 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value3.first); |
| 5074 EXPECT_EQ(kSampleValue3, flags_and_value3.second); | 4901 EXPECT_EQ(kSampleValue3, flags_and_value3.second); |
| 5075 } | 4902 } |
| 5076 } | 4903 } |
| 5077 | 4904 |
| 5078 // Test that when there are settings saved that they are sent back to the | 4905 // Test that when there are settings saved that they are sent back to the |
| 5079 // server upon session establishment. | 4906 // server upon session establishment. |
| 5080 TEST_P(SpdyNetworkTransactionTest, SettingsPlayback) { | 4907 TEST_P(SpdyNetworkTransactionTest, SettingsPlayback) { |
| 5081 if (GetParam().protocol > kProtoSPDY3) | |
| 5082 return; | |
| 5083 | |
| 5084 static const SpdyHeaderInfo kSynReplyInfo = { | 4908 static const SpdyHeaderInfo kSynReplyInfo = { |
| 5085 SYN_REPLY, // Syn Reply | 4909 SYN_REPLY, // Syn Reply |
| 5086 1, // Stream ID | 4910 1, // Stream ID |
| 5087 0, // Associated Stream ID | 4911 0, // Associated Stream ID |
| 5088 ConvertRequestPriorityToSpdyPriority( | 4912 ConvertRequestPriorityToSpdyPriority( |
| 5089 LOWEST, spdy_util_.spdy_version()), | 4913 LOWEST, spdy_util_.spdy_version()), |
| 5090 kSpdyCredentialSlotUnused, | 4914 kSpdyCredentialSlotUnused, |
| 5091 CONTROL_FLAG_NONE, // Control Flags | 4915 CONTROL_FLAG_NONE, // Control Flags |
| 5092 false, // Compressed | 4916 false, // Compressed |
| 5093 RST_STREAM_INVALID, // Status | 4917 RST_STREAM_INVALID, // Status |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5186 // Verify the second persisted setting. | 5010 // Verify the second persisted setting. |
| 5187 SettingsMap::const_iterator it2 = settings_map.find(kSampleId2); | 5011 SettingsMap::const_iterator it2 = settings_map.find(kSampleId2); |
| 5188 EXPECT_TRUE(it2 != settings_map.end()); | 5012 EXPECT_TRUE(it2 != settings_map.end()); |
| 5189 SettingsFlagsAndValue flags_and_value2 = it2->second; | 5013 SettingsFlagsAndValue flags_and_value2 = it2->second; |
| 5190 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value2.first); | 5014 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value2.first); |
| 5191 EXPECT_EQ(kSampleValue2, flags_and_value2.second); | 5015 EXPECT_EQ(kSampleValue2, flags_and_value2.second); |
| 5192 } | 5016 } |
| 5193 } | 5017 } |
| 5194 | 5018 |
| 5195 TEST_P(SpdyNetworkTransactionTest, GoAwayWithActiveStream) { | 5019 TEST_P(SpdyNetworkTransactionTest, GoAwayWithActiveStream) { |
| 5196 if (GetParam().protocol > kProtoSPDY3) | |
| 5197 return; | |
| 5198 | |
| 5199 scoped_ptr<SpdyFrame> req( | 5020 scoped_ptr<SpdyFrame> req( |
| 5200 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 5021 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 5201 MockWrite writes[] = { CreateMockWrite(*req) }; | 5022 MockWrite writes[] = { CreateMockWrite(*req) }; |
| 5202 | 5023 |
| 5203 scoped_ptr<SpdyFrame> go_away(spdy_util_.ConstructSpdyGoAway()); | 5024 scoped_ptr<SpdyFrame> go_away(spdy_util_.ConstructSpdyGoAway()); |
| 5204 MockRead reads[] = { | 5025 MockRead reads[] = { |
| 5205 CreateMockRead(*go_away), | 5026 CreateMockRead(*go_away), |
| 5206 MockRead(ASYNC, 0, 0), // EOF | 5027 MockRead(ASYNC, 0, 0), // EOF |
| 5207 }; | 5028 }; |
| 5208 | 5029 |
| 5209 DelayedSocketData data(1, reads, arraysize(reads), | 5030 DelayedSocketData data(1, reads, arraysize(reads), |
| 5210 writes, arraysize(writes)); | 5031 writes, arraysize(writes)); |
| 5211 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 5032 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 5212 BoundNetLog(), GetParam(), NULL); | 5033 BoundNetLog(), GetParam(), NULL); |
| 5213 helper.AddData(&data); | 5034 helper.AddData(&data); |
| 5214 helper.RunToCompletion(&data); | 5035 helper.RunToCompletion(&data); |
| 5215 TransactionHelperResult out = helper.output(); | 5036 TransactionHelperResult out = helper.output(); |
| 5216 EXPECT_EQ(ERR_ABORTED, out.rv); | 5037 EXPECT_EQ(ERR_ABORTED, out.rv); |
| 5217 } | 5038 } |
| 5218 | 5039 |
| 5219 TEST_P(SpdyNetworkTransactionTest, CloseWithActiveStream) { | 5040 TEST_P(SpdyNetworkTransactionTest, CloseWithActiveStream) { |
| 5220 if (GetParam().protocol > kProtoSPDY3) | |
| 5221 return; | |
| 5222 | |
| 5223 scoped_ptr<SpdyFrame> req( | 5041 scoped_ptr<SpdyFrame> req( |
| 5224 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 5042 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 5225 MockWrite writes[] = { CreateMockWrite(*req) }; | 5043 MockWrite writes[] = { CreateMockWrite(*req) }; |
| 5226 | 5044 |
| 5227 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 5045 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 5228 MockRead reads[] = { | 5046 MockRead reads[] = { |
| 5229 CreateMockRead(*resp), | 5047 CreateMockRead(*resp), |
| 5230 MockRead(SYNCHRONOUS, 0, 0) // EOF | 5048 MockRead(SYNCHRONOUS, 0, 0) // EOF |
| 5231 }; | 5049 }; |
| 5232 | 5050 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 5252 EXPECT_TRUE(response->was_fetched_via_spdy); | 5070 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 5253 out.rv = ReadTransaction(trans, &out.response_data); | 5071 out.rv = ReadTransaction(trans, &out.response_data); |
| 5254 EXPECT_EQ(ERR_CONNECTION_CLOSED, out.rv); | 5072 EXPECT_EQ(ERR_CONNECTION_CLOSED, out.rv); |
| 5255 | 5073 |
| 5256 // Verify that we consumed all test data. | 5074 // Verify that we consumed all test data. |
| 5257 helper.VerifyDataConsumed(); | 5075 helper.VerifyDataConsumed(); |
| 5258 } | 5076 } |
| 5259 | 5077 |
| 5260 // Test to make sure we can correctly connect through a proxy. | 5078 // Test to make sure we can correctly connect through a proxy. |
| 5261 TEST_P(SpdyNetworkTransactionTest, ProxyConnect) { | 5079 TEST_P(SpdyNetworkTransactionTest, ProxyConnect) { |
| 5262 if (GetParam().protocol > kProtoSPDY3) | |
| 5263 return; | |
| 5264 | |
| 5265 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 5080 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 5266 BoundNetLog(), GetParam(), NULL); | 5081 BoundNetLog(), GetParam(), NULL); |
| 5267 helper.session_deps().reset(CreateSpdySessionDependencies( | 5082 helper.session_deps().reset(CreateSpdySessionDependencies( |
| 5268 GetParam(), | 5083 GetParam(), |
| 5269 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70"))); | 5084 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70"))); |
| 5270 helper.SetSession(make_scoped_refptr( | 5085 helper.SetSession(make_scoped_refptr( |
| 5271 SpdySessionDependencies::SpdyCreateSession(helper.session_deps().get()))); | 5086 SpdySessionDependencies::SpdyCreateSession(helper.session_deps().get()))); |
| 5272 helper.RunPreTestSetup(); | 5087 helper.RunPreTestSetup(); |
| 5273 HttpNetworkTransaction* trans = helper.trans(); | 5088 HttpNetworkTransaction* trans = helper.trans(); |
| 5274 | 5089 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5358 std::string response_data; | 5173 std::string response_data; |
| 5359 ASSERT_EQ(OK, ReadTransaction(trans, &response_data)); | 5174 ASSERT_EQ(OK, ReadTransaction(trans, &response_data)); |
| 5360 EXPECT_EQ("hello!", response_data); | 5175 EXPECT_EQ("hello!", response_data); |
| 5361 helper.VerifyDataConsumed(); | 5176 helper.VerifyDataConsumed(); |
| 5362 } | 5177 } |
| 5363 | 5178 |
| 5364 // Test to make sure we can correctly connect through a proxy to www.google.com, | 5179 // Test to make sure we can correctly connect through a proxy to www.google.com, |
| 5365 // if there already exists a direct spdy connection to www.google.com. See | 5180 // if there already exists a direct spdy connection to www.google.com. See |
| 5366 // http://crbug.com/49874 | 5181 // http://crbug.com/49874 |
| 5367 TEST_P(SpdyNetworkTransactionTest, DirectConnectProxyReconnect) { | 5182 TEST_P(SpdyNetworkTransactionTest, DirectConnectProxyReconnect) { |
| 5368 if (GetParam().protocol > kProtoSPDY3) | |
| 5369 return; | |
| 5370 | |
| 5371 // When setting up the first transaction, we store the SpdySessionPool so that | 5183 // When setting up the first transaction, we store the SpdySessionPool so that |
| 5372 // we can use the same pool in the second transaction. | 5184 // we can use the same pool in the second transaction. |
| 5373 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 5185 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 5374 BoundNetLog(), GetParam(), NULL); | 5186 BoundNetLog(), GetParam(), NULL); |
| 5375 | 5187 |
| 5376 // Use a proxy service which returns a proxy fallback list from DIRECT to | 5188 // Use a proxy service which returns a proxy fallback list from DIRECT to |
| 5377 // myproxy:70. For this test there will be no fallback, so it is equivalent | 5189 // myproxy:70. For this test there will be no fallback, so it is equivalent |
| 5378 // to simply DIRECT. The reason for appending the second proxy is to verify | 5190 // to simply DIRECT. The reason for appending the second proxy is to verify |
| 5379 // that the session pool key used does is just "DIRECT". | 5191 // that the session pool key used does is just "DIRECT". |
| 5380 helper.session_deps().reset(CreateSpdySessionDependencies( | 5192 helper.session_deps().reset(CreateSpdySessionDependencies( |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5542 | 5354 |
| 5543 data.CompleteRead(); | 5355 data.CompleteRead(); |
| 5544 helper_proxy.VerifyDataConsumed(); | 5356 helper_proxy.VerifyDataConsumed(); |
| 5545 } | 5357 } |
| 5546 | 5358 |
| 5547 // When we get a TCP-level RST, we need to retry a HttpNetworkTransaction | 5359 // When we get a TCP-level RST, we need to retry a HttpNetworkTransaction |
| 5548 // on a new connection, if the connection was previously known to be good. | 5360 // on a new connection, if the connection was previously known to be good. |
| 5549 // This can happen when a server reboots without saying goodbye, or when | 5361 // This can happen when a server reboots without saying goodbye, or when |
| 5550 // we're behind a NAT that masked the RST. | 5362 // we're behind a NAT that masked the RST. |
| 5551 TEST_P(SpdyNetworkTransactionTest, VerifyRetryOnConnectionReset) { | 5363 TEST_P(SpdyNetworkTransactionTest, VerifyRetryOnConnectionReset) { |
| 5552 if (GetParam().protocol > kProtoSPDY3) | |
| 5553 return; | |
| 5554 | |
| 5555 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 5364 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 5556 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 5365 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 5557 MockRead reads[] = { | 5366 MockRead reads[] = { |
| 5558 CreateMockRead(*resp), | 5367 CreateMockRead(*resp), |
| 5559 CreateMockRead(*body), | 5368 CreateMockRead(*body), |
| 5560 MockRead(ASYNC, ERR_IO_PENDING), | 5369 MockRead(ASYNC, ERR_IO_PENDING), |
| 5561 MockRead(ASYNC, ERR_CONNECTION_RESET), | 5370 MockRead(ASYNC, ERR_CONNECTION_RESET), |
| 5562 }; | 5371 }; |
| 5563 | 5372 |
| 5564 MockRead reads2[] = { | 5373 MockRead reads2[] = { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5623 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 5432 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 5624 EXPECT_EQ("hello!", response_data); | 5433 EXPECT_EQ("hello!", response_data); |
| 5625 } | 5434 } |
| 5626 | 5435 |
| 5627 helper.VerifyDataConsumed(); | 5436 helper.VerifyDataConsumed(); |
| 5628 } | 5437 } |
| 5629 } | 5438 } |
| 5630 | 5439 |
| 5631 // Test that turning SPDY on and off works properly. | 5440 // Test that turning SPDY on and off works properly. |
| 5632 TEST_P(SpdyNetworkTransactionTest, SpdyOnOffToggle) { | 5441 TEST_P(SpdyNetworkTransactionTest, SpdyOnOffToggle) { |
| 5633 if (GetParam().protocol > kProtoSPDY3) | |
| 5634 return; | |
| 5635 | |
| 5636 net::HttpStreamFactory::set_spdy_enabled(true); | 5442 net::HttpStreamFactory::set_spdy_enabled(true); |
| 5637 scoped_ptr<SpdyFrame> req( | 5443 scoped_ptr<SpdyFrame> req( |
| 5638 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 5444 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 5639 MockWrite spdy_writes[] = { CreateMockWrite(*req) }; | 5445 MockWrite spdy_writes[] = { CreateMockWrite(*req) }; |
| 5640 | 5446 |
| 5641 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 5447 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 5642 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 5448 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 5643 MockRead spdy_reads[] = { | 5449 MockRead spdy_reads[] = { |
| 5644 CreateMockRead(*resp), | 5450 CreateMockRead(*resp), |
| 5645 CreateMockRead(*body), | 5451 CreateMockRead(*body), |
| (...skipping 24 matching lines...) Expand all Loading... |
| 5670 TransactionHelperResult out2 = helper2.output(); | 5476 TransactionHelperResult out2 = helper2.output(); |
| 5671 EXPECT_EQ(OK, out2.rv); | 5477 EXPECT_EQ(OK, out2.rv); |
| 5672 EXPECT_EQ("HTTP/1.1 200 OK", out2.status_line); | 5478 EXPECT_EQ("HTTP/1.1 200 OK", out2.status_line); |
| 5673 EXPECT_EQ("hello from http", out2.response_data); | 5479 EXPECT_EQ("hello from http", out2.response_data); |
| 5674 | 5480 |
| 5675 net::HttpStreamFactory::set_spdy_enabled(true); | 5481 net::HttpStreamFactory::set_spdy_enabled(true); |
| 5676 } | 5482 } |
| 5677 | 5483 |
| 5678 // Tests that Basic authentication works over SPDY | 5484 // Tests that Basic authentication works over SPDY |
| 5679 TEST_P(SpdyNetworkTransactionTest, SpdyBasicAuth) { | 5485 TEST_P(SpdyNetworkTransactionTest, SpdyBasicAuth) { |
| 5680 if (GetParam().protocol > kProtoSPDY3) | |
| 5681 return; | |
| 5682 | |
| 5683 net::HttpStreamFactory::set_spdy_enabled(true); | 5486 net::HttpStreamFactory::set_spdy_enabled(true); |
| 5684 | 5487 |
| 5685 // The first request will be a bare GET, the second request will be a | 5488 // The first request will be a bare GET, the second request will be a |
| 5686 // GET with an Authorization header. | 5489 // GET with an Authorization header. |
| 5687 scoped_ptr<SpdyFrame> req_get( | 5490 scoped_ptr<SpdyFrame> req_get( |
| 5688 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 5491 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 5689 const char* const kExtraAuthorizationHeaders[] = { | 5492 const char* const kExtraAuthorizationHeaders[] = { |
| 5690 "authorization", "Basic Zm9vOmJhcg==" | 5493 "authorization", "Basic Zm9vOmJhcg==" |
| 5691 }; | 5494 }; |
| 5692 scoped_ptr<SpdyFrame> req_get_authorization( | 5495 scoped_ptr<SpdyFrame> req_get_authorization( |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5763 // TODO(cbentzel): This is actually the same response object as before, but | 5566 // TODO(cbentzel): This is actually the same response object as before, but |
| 5764 // data has changed. | 5567 // data has changed. |
| 5765 const HttpResponseInfo* const response_restart = trans->GetResponseInfo(); | 5568 const HttpResponseInfo* const response_restart = trans->GetResponseInfo(); |
| 5766 ASSERT_TRUE(response_restart != NULL); | 5569 ASSERT_TRUE(response_restart != NULL); |
| 5767 ASSERT_TRUE(response_restart->headers.get() != NULL); | 5570 ASSERT_TRUE(response_restart->headers.get() != NULL); |
| 5768 EXPECT_EQ(200, response_restart->headers->response_code()); | 5571 EXPECT_EQ(200, response_restart->headers->response_code()); |
| 5769 EXPECT_TRUE(response_restart->auth_challenge.get() == NULL); | 5572 EXPECT_TRUE(response_restart->auth_challenge.get() == NULL); |
| 5770 } | 5573 } |
| 5771 | 5574 |
| 5772 TEST_P(SpdyNetworkTransactionTest, ServerPushWithHeaders) { | 5575 TEST_P(SpdyNetworkTransactionTest, ServerPushWithHeaders) { |
| 5773 if (GetParam().protocol > kProtoSPDY3) | |
| 5774 return; | |
| 5775 | |
| 5776 static const unsigned char kPushBodyFrame[] = { | |
| 5777 0x00, 0x00, 0x00, 0x02, // header, ID | |
| 5778 0x01, 0x00, 0x00, 0x06, // FIN, length | |
| 5779 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | |
| 5780 }; | |
| 5781 scoped_ptr<SpdyFrame> stream1_syn( | 5576 scoped_ptr<SpdyFrame> stream1_syn( |
| 5782 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 5577 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 5783 scoped_ptr<SpdyFrame> stream1_body( | 5578 scoped_ptr<SpdyFrame> stream1_body( |
| 5784 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 5579 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 5785 MockWrite writes[] = { | 5580 MockWrite writes[] = { |
| 5786 CreateMockWrite(*stream1_syn, 1), | 5581 CreateMockWrite(*stream1_syn, 1), |
| 5787 }; | 5582 }; |
| 5788 | 5583 |
| 5789 scoped_ptr<SpdyHeaderBlock> initial_headers(new SpdyHeaderBlock()); | 5584 scoped_ptr<SpdyHeaderBlock> initial_headers(new SpdyHeaderBlock()); |
| 5790 spdy_util_.AddUrlToHeaderBlock( | 5585 spdy_util_.AddUrlToHeaderBlock( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 5806 spdy_util_.ConstructSpdyControlFrame(late_headers.Pass(), | 5601 spdy_util_.ConstructSpdyControlFrame(late_headers.Pass(), |
| 5807 false, | 5602 false, |
| 5808 2, | 5603 2, |
| 5809 LOWEST, | 5604 LOWEST, |
| 5810 HEADERS, | 5605 HEADERS, |
| 5811 CONTROL_FLAG_NONE, | 5606 CONTROL_FLAG_NONE, |
| 5812 0)); | 5607 0)); |
| 5813 | 5608 |
| 5814 scoped_ptr<SpdyFrame> | 5609 scoped_ptr<SpdyFrame> |
| 5815 stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 5610 stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 5611 const char kPushedData[] = "pushed"; |
| 5612 scoped_ptr<SpdyFrame> stream2_body( |
| 5613 spdy_util_.ConstructSpdyBodyFrame( |
| 5614 2, kPushedData, strlen(kPushedData), true)); |
| 5816 MockRead reads[] = { | 5615 MockRead reads[] = { |
| 5817 CreateMockRead(*stream1_reply, 2), | 5616 CreateMockRead(*stream1_reply, 2), |
| 5818 CreateMockRead(*stream2_syn, 3), | 5617 CreateMockRead(*stream2_syn, 3), |
| 5819 CreateMockRead(*stream2_headers, 4), | 5618 CreateMockRead(*stream2_headers, 4), |
| 5820 CreateMockRead(*stream1_body, 5, SYNCHRONOUS), | 5619 CreateMockRead(*stream1_body, 5, SYNCHRONOUS), |
| 5821 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame), | 5620 CreateMockRead(*stream2_body, 5), |
| 5822 arraysize(kPushBodyFrame), 6), | |
| 5823 MockRead(ASYNC, ERR_IO_PENDING, 7), // Force a pause | 5621 MockRead(ASYNC, ERR_IO_PENDING, 7), // Force a pause |
| 5824 }; | 5622 }; |
| 5825 | 5623 |
| 5826 HttpResponseInfo response; | 5624 HttpResponseInfo response; |
| 5827 HttpResponseInfo response2; | 5625 HttpResponseInfo response2; |
| 5828 std::string expected_push_result("pushed"); | 5626 std::string expected_push_result("pushed"); |
| 5829 OrderedSocketData data(reads, arraysize(reads), | 5627 OrderedSocketData data(reads, arraysize(reads), |
| 5830 writes, arraysize(writes)); | 5628 writes, arraysize(writes)); |
| 5831 RunServerPushTest(&data, | 5629 RunServerPushTest(&data, |
| 5832 &response, | 5630 &response, |
| 5833 &response2, | 5631 &response2, |
| 5834 expected_push_result); | 5632 expected_push_result); |
| 5835 | 5633 |
| 5836 // Verify the SYN_REPLY. | 5634 // Verify the SYN_REPLY. |
| 5837 EXPECT_TRUE(response.headers.get() != NULL); | 5635 EXPECT_TRUE(response.headers.get() != NULL); |
| 5838 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5636 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 5839 | 5637 |
| 5840 // Verify the pushed stream. | 5638 // Verify the pushed stream. |
| 5841 EXPECT_TRUE(response2.headers.get() != NULL); | 5639 EXPECT_TRUE(response2.headers.get() != NULL); |
| 5842 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 5640 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
| 5843 } | 5641 } |
| 5844 | 5642 |
| 5845 TEST_P(SpdyNetworkTransactionTest, ServerPushClaimBeforeHeaders) { | 5643 TEST_P(SpdyNetworkTransactionTest, ServerPushClaimBeforeHeaders) { |
| 5846 if (GetParam().protocol > kProtoSPDY3) | |
| 5847 return; | |
| 5848 | |
| 5849 // We push a stream and attempt to claim it before the headers come down. | 5644 // We push a stream and attempt to claim it before the headers come down. |
| 5850 static const unsigned char kPushBodyFrame[] = { | |
| 5851 0x00, 0x00, 0x00, 0x02, // header, ID | |
| 5852 0x01, 0x00, 0x00, 0x06, // FIN, length | |
| 5853 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | |
| 5854 }; | |
| 5855 scoped_ptr<SpdyFrame> stream1_syn( | 5645 scoped_ptr<SpdyFrame> stream1_syn( |
| 5856 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 5646 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 5857 scoped_ptr<SpdyFrame> stream1_body( | 5647 scoped_ptr<SpdyFrame> stream1_body( |
| 5858 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 5648 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 5859 MockWrite writes[] = { | 5649 MockWrite writes[] = { |
| 5860 CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS), | 5650 CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS), |
| 5861 }; | 5651 }; |
| 5862 | 5652 |
| 5863 scoped_ptr<SpdyHeaderBlock> initial_headers(new SpdyHeaderBlock()); | 5653 scoped_ptr<SpdyHeaderBlock> initial_headers(new SpdyHeaderBlock()); |
| 5864 spdy_util_.AddUrlToHeaderBlock( | 5654 spdy_util_.AddUrlToHeaderBlock( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 5880 spdy_util_.ConstructSpdyControlFrame(late_headers.Pass(), | 5670 spdy_util_.ConstructSpdyControlFrame(late_headers.Pass(), |
| 5881 false, | 5671 false, |
| 5882 2, | 5672 2, |
| 5883 LOWEST, | 5673 LOWEST, |
| 5884 HEADERS, | 5674 HEADERS, |
| 5885 CONTROL_FLAG_NONE, | 5675 CONTROL_FLAG_NONE, |
| 5886 0)); | 5676 0)); |
| 5887 | 5677 |
| 5888 scoped_ptr<SpdyFrame> | 5678 scoped_ptr<SpdyFrame> |
| 5889 stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 5679 stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 5680 const char kPushedData[] = "pushed"; |
| 5681 scoped_ptr<SpdyFrame> stream2_body( |
| 5682 spdy_util_.ConstructSpdyBodyFrame( |
| 5683 2, kPushedData, strlen(kPushedData), true)); |
| 5890 MockRead reads[] = { | 5684 MockRead reads[] = { |
| 5891 CreateMockRead(*stream1_reply, 1), | 5685 CreateMockRead(*stream1_reply, 1), |
| 5892 CreateMockRead(*stream2_syn, 2), | 5686 CreateMockRead(*stream2_syn, 2), |
| 5893 CreateMockRead(*stream1_body, 3), | 5687 CreateMockRead(*stream1_body, 3), |
| 5894 CreateMockRead(*stream2_headers, 4), | 5688 CreateMockRead(*stream2_headers, 4), |
| 5895 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame), | 5689 CreateMockRead(*stream2_body, 5), |
| 5896 arraysize(kPushBodyFrame), 5), | |
| 5897 MockRead(ASYNC, 0, 6), // EOF | 5690 MockRead(ASYNC, 0, 6), // EOF |
| 5898 }; | 5691 }; |
| 5899 | 5692 |
| 5900 HttpResponseInfo response; | 5693 HttpResponseInfo response; |
| 5901 HttpResponseInfo response2; | 5694 HttpResponseInfo response2; |
| 5902 std::string expected_push_result("pushed"); | 5695 std::string expected_push_result("pushed"); |
| 5903 DeterministicSocketData data(reads, arraysize(reads), | 5696 DeterministicSocketData data(reads, arraysize(reads), |
| 5904 writes, arraysize(writes)); | 5697 writes, arraysize(writes)); |
| 5905 | 5698 |
| 5906 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 5699 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5966 | 5759 |
| 5967 // Read the final EOF (which will close the session) | 5760 // Read the final EOF (which will close the session) |
| 5968 data.RunFor(1); | 5761 data.RunFor(1); |
| 5969 | 5762 |
| 5970 // Verify that we consumed all test data. | 5763 // Verify that we consumed all test data. |
| 5971 EXPECT_TRUE(data.at_read_eof()); | 5764 EXPECT_TRUE(data.at_read_eof()); |
| 5972 EXPECT_TRUE(data.at_write_eof()); | 5765 EXPECT_TRUE(data.at_write_eof()); |
| 5973 } | 5766 } |
| 5974 | 5767 |
| 5975 TEST_P(SpdyNetworkTransactionTest, ServerPushWithTwoHeaderFrames) { | 5768 TEST_P(SpdyNetworkTransactionTest, ServerPushWithTwoHeaderFrames) { |
| 5976 if (GetParam().protocol > kProtoSPDY3) | |
| 5977 return; | |
| 5978 | |
| 5979 // We push a stream and attempt to claim it before the headers come down. | 5769 // We push a stream and attempt to claim it before the headers come down. |
| 5980 static const unsigned char kPushBodyFrame[] = { | |
| 5981 0x00, 0x00, 0x00, 0x02, // header, ID | |
| 5982 0x01, 0x00, 0x00, 0x06, // FIN, length | |
| 5983 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | |
| 5984 }; | |
| 5985 scoped_ptr<SpdyFrame> stream1_syn( | 5770 scoped_ptr<SpdyFrame> stream1_syn( |
| 5986 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 5771 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 5987 scoped_ptr<SpdyFrame> stream1_body( | 5772 scoped_ptr<SpdyFrame> stream1_body( |
| 5988 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 5773 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 5989 MockWrite writes[] = { | 5774 MockWrite writes[] = { |
| 5990 CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS), | 5775 CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS), |
| 5991 }; | 5776 }; |
| 5992 | 5777 |
| 5993 scoped_ptr<SpdyHeaderBlock> initial_headers(new SpdyHeaderBlock()); | 5778 scoped_ptr<SpdyHeaderBlock> initial_headers(new SpdyHeaderBlock()); |
| 5994 spdy_util_.AddUrlToHeaderBlock( | 5779 spdy_util_.AddUrlToHeaderBlock( |
| (...skipping 25 matching lines...) Expand all Loading... |
| 6020 spdy_util_.ConstructSpdyControlFrame(late_headers.Pass(), | 5805 spdy_util_.ConstructSpdyControlFrame(late_headers.Pass(), |
| 6021 false, | 5806 false, |
| 6022 2, | 5807 2, |
| 6023 LOWEST, | 5808 LOWEST, |
| 6024 HEADERS, | 5809 HEADERS, |
| 6025 CONTROL_FLAG_NONE, | 5810 CONTROL_FLAG_NONE, |
| 6026 0)); | 5811 0)); |
| 6027 | 5812 |
| 6028 scoped_ptr<SpdyFrame> | 5813 scoped_ptr<SpdyFrame> |
| 6029 stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 5814 stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 5815 const char kPushedData[] = "pushed"; |
| 5816 scoped_ptr<SpdyFrame> stream2_body( |
| 5817 spdy_util_.ConstructSpdyBodyFrame( |
| 5818 2, kPushedData, strlen(kPushedData), true)); |
| 6030 MockRead reads[] = { | 5819 MockRead reads[] = { |
| 6031 CreateMockRead(*stream1_reply, 1), | 5820 CreateMockRead(*stream1_reply, 1), |
| 6032 CreateMockRead(*stream2_syn, 2), | 5821 CreateMockRead(*stream2_syn, 2), |
| 6033 CreateMockRead(*stream1_body, 3), | 5822 CreateMockRead(*stream1_body, 3), |
| 6034 CreateMockRead(*stream2_headers1, 4), | 5823 CreateMockRead(*stream2_headers1, 4), |
| 6035 CreateMockRead(*stream2_headers2, 5), | 5824 CreateMockRead(*stream2_headers2, 5), |
| 6036 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame), | 5825 CreateMockRead(*stream2_body, 6), |
| 6037 arraysize(kPushBodyFrame), 6), | |
| 6038 MockRead(ASYNC, 0, 7), // EOF | 5826 MockRead(ASYNC, 0, 7), // EOF |
| 6039 }; | 5827 }; |
| 6040 | 5828 |
| 6041 HttpResponseInfo response; | 5829 HttpResponseInfo response; |
| 6042 HttpResponseInfo response2; | 5830 HttpResponseInfo response2; |
| 6043 std::string expected_push_result("pushed"); | 5831 std::string expected_push_result("pushed"); |
| 6044 DeterministicSocketData data(reads, arraysize(reads), | 5832 DeterministicSocketData data(reads, arraysize(reads), |
| 6045 writes, arraysize(writes)); | 5833 writes, arraysize(writes)); |
| 6046 | 5834 |
| 6047 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 5835 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6120 | 5908 |
| 6121 // Read the final EOF (which will close the session) | 5909 // Read the final EOF (which will close the session) |
| 6122 data.RunFor(1); | 5910 data.RunFor(1); |
| 6123 | 5911 |
| 6124 // Verify that we consumed all test data. | 5912 // Verify that we consumed all test data. |
| 6125 EXPECT_TRUE(data.at_read_eof()); | 5913 EXPECT_TRUE(data.at_read_eof()); |
| 6126 EXPECT_TRUE(data.at_write_eof()); | 5914 EXPECT_TRUE(data.at_write_eof()); |
| 6127 } | 5915 } |
| 6128 | 5916 |
| 6129 TEST_P(SpdyNetworkTransactionTest, ServerPushWithNoStatusHeaderFrames) { | 5917 TEST_P(SpdyNetworkTransactionTest, ServerPushWithNoStatusHeaderFrames) { |
| 6130 if (GetParam().protocol > kProtoSPDY3) | |
| 6131 return; | |
| 6132 | |
| 6133 // We push a stream and attempt to claim it before the headers come down. | 5918 // We push a stream and attempt to claim it before the headers come down. |
| 6134 static const unsigned char kPushBodyFrame[] = { | |
| 6135 0x00, 0x00, 0x00, 0x02, // header, ID | |
| 6136 0x01, 0x00, 0x00, 0x06, // FIN, length | |
| 6137 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | |
| 6138 }; | |
| 6139 scoped_ptr<SpdyFrame> stream1_syn( | 5919 scoped_ptr<SpdyFrame> stream1_syn( |
| 6140 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 5920 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 6141 scoped_ptr<SpdyFrame> stream1_body( | 5921 scoped_ptr<SpdyFrame> stream1_body( |
| 6142 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 5922 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 6143 MockWrite writes[] = { | 5923 MockWrite writes[] = { |
| 6144 CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS), | 5924 CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS), |
| 6145 }; | 5925 }; |
| 6146 | 5926 |
| 6147 scoped_ptr<SpdyHeaderBlock> initial_headers(new SpdyHeaderBlock()); | 5927 scoped_ptr<SpdyHeaderBlock> initial_headers(new SpdyHeaderBlock()); |
| 6148 spdy_util_.AddUrlToHeaderBlock( | 5928 spdy_util_.AddUrlToHeaderBlock( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 6162 spdy_util_.ConstructSpdyControlFrame(middle_headers.Pass(), | 5942 spdy_util_.ConstructSpdyControlFrame(middle_headers.Pass(), |
| 6163 false, | 5943 false, |
| 6164 2, | 5944 2, |
| 6165 LOWEST, | 5945 LOWEST, |
| 6166 HEADERS, | 5946 HEADERS, |
| 6167 CONTROL_FLAG_NONE, | 5947 CONTROL_FLAG_NONE, |
| 6168 0)); | 5948 0)); |
| 6169 | 5949 |
| 6170 scoped_ptr<SpdyFrame> | 5950 scoped_ptr<SpdyFrame> |
| 6171 stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 5951 stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 5952 const char kPushedData[] = "pushed"; |
| 5953 scoped_ptr<SpdyFrame> stream2_body( |
| 5954 spdy_util_.ConstructSpdyBodyFrame( |
| 5955 2, kPushedData, strlen(kPushedData), true)); |
| 6172 MockRead reads[] = { | 5956 MockRead reads[] = { |
| 6173 CreateMockRead(*stream1_reply, 1), | 5957 CreateMockRead(*stream1_reply, 1), |
| 6174 CreateMockRead(*stream2_syn, 2), | 5958 CreateMockRead(*stream2_syn, 2), |
| 6175 CreateMockRead(*stream1_body, 3), | 5959 CreateMockRead(*stream1_body, 3), |
| 6176 CreateMockRead(*stream2_headers1, 4), | 5960 CreateMockRead(*stream2_headers1, 4), |
| 6177 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame), | 5961 CreateMockRead(*stream2_body, 5), |
| 6178 arraysize(kPushBodyFrame), 5), | |
| 6179 MockRead(ASYNC, 0, 6), // EOF | 5962 MockRead(ASYNC, 0, 6), // EOF |
| 6180 }; | 5963 }; |
| 6181 | 5964 |
| 6182 DeterministicSocketData data(reads, arraysize(reads), | 5965 DeterministicSocketData data(reads, arraysize(reads), |
| 6183 writes, arraysize(writes)); | 5966 writes, arraysize(writes)); |
| 6184 | 5967 |
| 6185 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 5968 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 6186 BoundNetLog(), GetParam(), NULL); | 5969 BoundNetLog(), GetParam(), NULL); |
| 6187 helper.SetDeterministic(); | 5970 helper.SetDeterministic(); |
| 6188 helper.AddDeterministicData(&data); | 5971 helper.AddDeterministicData(&data); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6238 | 6021 |
| 6239 // Read the final EOF (which will close the session). | 6022 // Read the final EOF (which will close the session). |
| 6240 data.RunFor(1); | 6023 data.RunFor(1); |
| 6241 | 6024 |
| 6242 // Verify that we consumed all test data. | 6025 // Verify that we consumed all test data. |
| 6243 EXPECT_TRUE(data.at_read_eof()); | 6026 EXPECT_TRUE(data.at_read_eof()); |
| 6244 EXPECT_TRUE(data.at_write_eof()); | 6027 EXPECT_TRUE(data.at_write_eof()); |
| 6245 } | 6028 } |
| 6246 | 6029 |
| 6247 TEST_P(SpdyNetworkTransactionTest, SynReplyWithHeaders) { | 6030 TEST_P(SpdyNetworkTransactionTest, SynReplyWithHeaders) { |
| 6248 if (GetParam().protocol > kProtoSPDY3) | |
| 6249 return; | |
| 6250 | |
| 6251 scoped_ptr<SpdyFrame> req( | 6031 scoped_ptr<SpdyFrame> req( |
| 6252 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 6032 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 6253 scoped_ptr<SpdyFrame> rst( | 6033 scoped_ptr<SpdyFrame> rst( |
| 6254 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); | 6034 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); |
| 6255 MockWrite writes[] = { | 6035 MockWrite writes[] = { |
| 6256 CreateMockWrite(*req), | 6036 CreateMockWrite(*req), |
| 6257 CreateMockWrite(*rst), | 6037 CreateMockWrite(*rst), |
| 6258 }; | 6038 }; |
| 6259 | 6039 |
| 6260 scoped_ptr<SpdyHeaderBlock> initial_headers(new SpdyHeaderBlock()); | 6040 scoped_ptr<SpdyHeaderBlock> initial_headers(new SpdyHeaderBlock()); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 6291 DelayedSocketData data(1, reads, arraysize(reads), | 6071 DelayedSocketData data(1, reads, arraysize(reads), |
| 6292 writes, arraysize(writes)); | 6072 writes, arraysize(writes)); |
| 6293 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 6073 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 6294 BoundNetLog(), GetParam(), NULL); | 6074 BoundNetLog(), GetParam(), NULL); |
| 6295 helper.RunToCompletion(&data); | 6075 helper.RunToCompletion(&data); |
| 6296 TransactionHelperResult out = helper.output(); | 6076 TransactionHelperResult out = helper.output(); |
| 6297 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); | 6077 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); |
| 6298 } | 6078 } |
| 6299 | 6079 |
| 6300 TEST_P(SpdyNetworkTransactionTest, SynReplyWithLateHeaders) { | 6080 TEST_P(SpdyNetworkTransactionTest, SynReplyWithLateHeaders) { |
| 6301 if (GetParam().protocol > kProtoSPDY3) | |
| 6302 return; | |
| 6303 | |
| 6304 scoped_ptr<SpdyFrame> req( | 6081 scoped_ptr<SpdyFrame> req( |
| 6305 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 6082 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 6306 scoped_ptr<SpdyFrame> rst( | 6083 scoped_ptr<SpdyFrame> rst( |
| 6307 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); | 6084 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); |
| 6308 MockWrite writes[] = { | 6085 MockWrite writes[] = { |
| 6309 CreateMockWrite(*req), | 6086 CreateMockWrite(*req), |
| 6310 CreateMockWrite(*rst), | 6087 CreateMockWrite(*rst), |
| 6311 }; | 6088 }; |
| 6312 | 6089 |
| 6313 scoped_ptr<SpdyHeaderBlock> initial_headers(new SpdyHeaderBlock()); | 6090 scoped_ptr<SpdyHeaderBlock> initial_headers(new SpdyHeaderBlock()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6347 DelayedSocketData data(1, reads, arraysize(reads), | 6124 DelayedSocketData data(1, reads, arraysize(reads), |
| 6348 writes, arraysize(writes)); | 6125 writes, arraysize(writes)); |
| 6349 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 6126 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 6350 BoundNetLog(), GetParam(), NULL); | 6127 BoundNetLog(), GetParam(), NULL); |
| 6351 helper.RunToCompletion(&data); | 6128 helper.RunToCompletion(&data); |
| 6352 TransactionHelperResult out = helper.output(); | 6129 TransactionHelperResult out = helper.output(); |
| 6353 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); | 6130 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); |
| 6354 } | 6131 } |
| 6355 | 6132 |
| 6356 TEST_P(SpdyNetworkTransactionTest, ServerPushCrossOriginCorrectness) { | 6133 TEST_P(SpdyNetworkTransactionTest, ServerPushCrossOriginCorrectness) { |
| 6357 if (GetParam().protocol > kProtoSPDY3) | |
| 6358 return; | |
| 6359 | |
| 6360 // In this test we want to verify that we can't accidentally push content | 6134 // In this test we want to verify that we can't accidentally push content |
| 6361 // which can't be pushed by this content server. | 6135 // which can't be pushed by this content server. |
| 6362 // This test assumes that: | 6136 // This test assumes that: |
| 6363 // - if we're requesting http://www.foo.com/barbaz | 6137 // - if we're requesting http://www.foo.com/barbaz |
| 6364 // - the browser has made a connection to "www.foo.com". | 6138 // - the browser has made a connection to "www.foo.com". |
| 6365 | 6139 |
| 6366 // A list of the URL to fetch, followed by the URL being pushed. | 6140 // A list of the URL to fetch, followed by the URL being pushed. |
| 6367 static const char* const kTestCases[] = { | 6141 static const char* const kTestCases[] = { |
| 6368 "http://www.google.com/foo.html", | 6142 "http://www.google.com/foo.html", |
| 6369 "http://www.google.com:81/foo.js", // Bad port | 6143 "http://www.google.com:81/foo.js", // Bad port |
| 6370 | 6144 |
| 6371 "http://www.google.com/foo.html", | 6145 "http://www.google.com/foo.html", |
| 6372 "https://www.google.com/foo.js", // Bad protocol | 6146 "https://www.google.com/foo.js", // Bad protocol |
| 6373 | 6147 |
| 6374 "http://www.google.com/foo.html", | 6148 "http://www.google.com/foo.html", |
| 6375 "ftp://www.google.com/foo.js", // Invalid Protocol | 6149 "ftp://www.google.com/foo.js", // Invalid Protocol |
| 6376 | 6150 |
| 6377 "http://www.google.com/foo.html", | 6151 "http://www.google.com/foo.html", |
| 6378 "http://blat.www.google.com/foo.js", // Cross subdomain | 6152 "http://blat.www.google.com/foo.js", // Cross subdomain |
| 6379 | 6153 |
| 6380 "http://www.google.com/foo.html", | 6154 "http://www.google.com/foo.html", |
| 6381 "http://www.foo.com/foo.js", // Cross domain | 6155 "http://www.foo.com/foo.js", // Cross domain |
| 6382 }; | 6156 }; |
| 6383 | 6157 |
| 6384 | |
| 6385 static const unsigned char kPushBodyFrame[] = { | |
| 6386 0x00, 0x00, 0x00, 0x02, // header, ID | |
| 6387 0x01, 0x00, 0x00, 0x06, // FIN, length | |
| 6388 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | |
| 6389 }; | |
| 6390 | |
| 6391 for (size_t index = 0; index < arraysize(kTestCases); index += 2) { | 6158 for (size_t index = 0; index < arraysize(kTestCases); index += 2) { |
| 6392 const char* url_to_fetch = kTestCases[index]; | 6159 const char* url_to_fetch = kTestCases[index]; |
| 6393 const char* url_to_push = kTestCases[index + 1]; | 6160 const char* url_to_push = kTestCases[index + 1]; |
| 6394 | 6161 |
| 6395 scoped_ptr<SpdyFrame> stream1_syn( | 6162 scoped_ptr<SpdyFrame> stream1_syn( |
| 6396 spdy_util_.ConstructSpdyGet(url_to_fetch, false, 1, LOWEST)); | 6163 spdy_util_.ConstructSpdyGet(url_to_fetch, false, 1, LOWEST)); |
| 6397 scoped_ptr<SpdyFrame> stream1_body( | 6164 scoped_ptr<SpdyFrame> stream1_body( |
| 6398 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 6165 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 6399 scoped_ptr<SpdyFrame> push_rst( | 6166 scoped_ptr<SpdyFrame> push_rst( |
| 6400 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_REFUSED_STREAM)); | 6167 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_REFUSED_STREAM)); |
| 6401 MockWrite writes[] = { | 6168 MockWrite writes[] = { |
| 6402 CreateMockWrite(*stream1_syn, 1), | 6169 CreateMockWrite(*stream1_syn, 1), |
| 6403 CreateMockWrite(*push_rst, 4), | 6170 CreateMockWrite(*push_rst, 4), |
| 6404 }; | 6171 }; |
| 6405 | 6172 |
| 6406 scoped_ptr<SpdyFrame> | 6173 scoped_ptr<SpdyFrame> |
| 6407 stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 6174 stream1_reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 6408 scoped_ptr<SpdyFrame> | 6175 scoped_ptr<SpdyFrame> |
| 6409 stream2_syn(spdy_util_.ConstructSpdyPush(NULL, | 6176 stream2_syn(spdy_util_.ConstructSpdyPush(NULL, |
| 6410 0, | 6177 0, |
| 6411 2, | 6178 2, |
| 6412 1, | 6179 1, |
| 6413 url_to_push)); | 6180 url_to_push)); |
| 6181 const char kPushedData[] = "pushed"; |
| 6182 scoped_ptr<SpdyFrame> stream2_body( |
| 6183 spdy_util_.ConstructSpdyBodyFrame( |
| 6184 2, kPushedData, strlen(kPushedData), true)); |
| 6414 scoped_ptr<SpdyFrame> rst( | 6185 scoped_ptr<SpdyFrame> rst( |
| 6415 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_CANCEL)); | 6186 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_CANCEL)); |
| 6416 | 6187 |
| 6417 MockRead reads[] = { | 6188 MockRead reads[] = { |
| 6418 CreateMockRead(*stream1_reply, 2), | 6189 CreateMockRead(*stream1_reply, 2), |
| 6419 CreateMockRead(*stream2_syn, 3), | 6190 CreateMockRead(*stream2_syn, 3), |
| 6420 CreateMockRead(*stream1_body, 5, SYNCHRONOUS), | 6191 CreateMockRead(*stream1_body, 5, SYNCHRONOUS), |
| 6421 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame), | 6192 CreateMockRead(*stream2_body, 6), |
| 6422 arraysize(kPushBodyFrame), 6), | |
| 6423 MockRead(ASYNC, ERR_IO_PENDING, 7), // Force a pause | 6193 MockRead(ASYNC, ERR_IO_PENDING, 7), // Force a pause |
| 6424 }; | 6194 }; |
| 6425 | 6195 |
| 6426 HttpResponseInfo response; | 6196 HttpResponseInfo response; |
| 6427 OrderedSocketData data(reads, arraysize(reads), | 6197 OrderedSocketData data(reads, arraysize(reads), |
| 6428 writes, arraysize(writes)); | 6198 writes, arraysize(writes)); |
| 6429 | 6199 |
| 6430 HttpRequestInfo request; | 6200 HttpRequestInfo request; |
| 6431 request.method = "GET"; | 6201 request.method = "GET"; |
| 6432 request.url = GURL(url_to_fetch); | 6202 request.url = GURL(url_to_fetch); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6466 | 6236 |
| 6467 VerifyStreamsClosed(helper); | 6237 VerifyStreamsClosed(helper); |
| 6468 | 6238 |
| 6469 // Verify the SYN_REPLY. | 6239 // Verify the SYN_REPLY. |
| 6470 EXPECT_TRUE(response.headers.get() != NULL); | 6240 EXPECT_TRUE(response.headers.get() != NULL); |
| 6471 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 6241 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 6472 } | 6242 } |
| 6473 } | 6243 } |
| 6474 | 6244 |
| 6475 TEST_P(SpdyNetworkTransactionTest, RetryAfterRefused) { | 6245 TEST_P(SpdyNetworkTransactionTest, RetryAfterRefused) { |
| 6476 if (GetParam().protocol > kProtoSPDY3) | |
| 6477 return; | |
| 6478 | |
| 6479 // Construct the request. | 6246 // Construct the request. |
| 6480 scoped_ptr<SpdyFrame> req( | 6247 scoped_ptr<SpdyFrame> req( |
| 6481 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 6248 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 6482 scoped_ptr<SpdyFrame> req2( | 6249 scoped_ptr<SpdyFrame> req2( |
| 6483 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); | 6250 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); |
| 6484 MockWrite writes[] = { | 6251 MockWrite writes[] = { |
| 6485 CreateMockWrite(*req, 1), | 6252 CreateMockWrite(*req, 1), |
| 6486 CreateMockWrite(*req2, 3), | 6253 CreateMockWrite(*req2, 3), |
| 6487 }; | 6254 }; |
| 6488 | 6255 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6525 << " Write index: " | 6292 << " Write index: " |
| 6526 << data.write_index(); | 6293 << data.write_index(); |
| 6527 | 6294 |
| 6528 // Verify the SYN_REPLY. | 6295 // Verify the SYN_REPLY. |
| 6529 HttpResponseInfo response = *trans->GetResponseInfo(); | 6296 HttpResponseInfo response = *trans->GetResponseInfo(); |
| 6530 EXPECT_TRUE(response.headers.get() != NULL); | 6297 EXPECT_TRUE(response.headers.get() != NULL); |
| 6531 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 6298 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 6532 } | 6299 } |
| 6533 | 6300 |
| 6534 TEST_P(SpdyNetworkTransactionTest, OutOfOrderSynStream) { | 6301 TEST_P(SpdyNetworkTransactionTest, OutOfOrderSynStream) { |
| 6535 if (GetParam().protocol > kProtoSPDY3) | |
| 6536 return; | |
| 6537 | |
| 6538 // This first request will start to establish the SpdySession. | 6302 // This first request will start to establish the SpdySession. |
| 6539 // Then we will start the second (MEDIUM priority) and then third | 6303 // Then we will start the second (MEDIUM priority) and then third |
| 6540 // (HIGHEST priority) request in such a way that the third will actually | 6304 // (HIGHEST priority) request in such a way that the third will actually |
| 6541 // start before the second, causing the second to be numbered differently | 6305 // start before the second, causing the second to be numbered differently |
| 6542 // than the order they were created. | 6306 // than the order they were created. |
| 6543 scoped_ptr<SpdyFrame> req1( | 6307 scoped_ptr<SpdyFrame> req1( |
| 6544 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 6308 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 6545 scoped_ptr<SpdyFrame> req2( | 6309 scoped_ptr<SpdyFrame> req2( |
| 6546 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, HIGHEST, true)); | 6310 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, HIGHEST, true)); |
| 6547 scoped_ptr<SpdyFrame> req3( | 6311 scoped_ptr<SpdyFrame> req3( |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6614 // And now we can allow everything else to run to completion. | 6378 // And now we can allow everything else to run to completion. |
| 6615 data.SetStop(10); | 6379 data.SetStop(10); |
| 6616 data.Run(); | 6380 data.Run(); |
| 6617 EXPECT_EQ(OK, callback2.WaitForResult()); | 6381 EXPECT_EQ(OK, callback2.WaitForResult()); |
| 6618 EXPECT_EQ(OK, callback3.WaitForResult()); | 6382 EXPECT_EQ(OK, callback3.WaitForResult()); |
| 6619 | 6383 |
| 6620 helper.VerifyDataConsumed(); | 6384 helper.VerifyDataConsumed(); |
| 6621 } | 6385 } |
| 6622 | 6386 |
| 6623 } // namespace net | 6387 } // namespace net |
| OLD | NEW |