OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/http/http_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 break; | 165 break; |
166 case SPDYSSL: | 166 case SPDYSSL: |
167 HttpStreamFactory::set_force_spdy_over_ssl(true); | 167 HttpStreamFactory::set_force_spdy_over_ssl(true); |
168 HttpStreamFactory::set_force_spdy_always(true); | 168 HttpStreamFactory::set_force_spdy_always(true); |
169 break; | 169 break; |
170 default: | 170 default: |
171 NOTREACHED(); | 171 NOTREACHED(); |
172 } | 172 } |
173 | 173 |
174 // We're now ready to use SSL-npn SPDY. | 174 // We're now ready to use SSL-npn SPDY. |
175 trans_.reset(new HttpNetworkTransaction(priority_, session_)); | 175 trans_.reset(new HttpNetworkTransaction(priority_, session_.get())); |
176 } | 176 } |
177 | 177 |
178 // Start the transaction, read some data, finish. | 178 // Start the transaction, read some data, finish. |
179 void RunDefaultTest() { | 179 void RunDefaultTest() { |
180 if (!StartDefaultTest()) | 180 if (!StartDefaultTest()) |
181 return; | 181 return; |
182 FinishDefaultTest(); | 182 FinishDefaultTest(); |
183 } | 183 } |
184 | 184 |
185 bool StartDefaultTest() { | 185 bool StartDefaultTest() { |
186 output_.rv = trans_->Start(&request_, callback.callback(), log_); | 186 output_.rv = trans_->Start(&request_, callback.callback(), log_); |
187 | 187 |
188 // We expect an IO Pending or some sort of error. | 188 // We expect an IO Pending or some sort of error. |
189 EXPECT_LT(output_.rv, 0); | 189 EXPECT_LT(output_.rv, 0); |
190 return output_.rv == ERR_IO_PENDING; | 190 return output_.rv == ERR_IO_PENDING; |
191 } | 191 } |
192 | 192 |
193 void FinishDefaultTest() { | 193 void FinishDefaultTest() { |
194 output_.rv = callback.WaitForResult(); | 194 output_.rv = callback.WaitForResult(); |
195 if (output_.rv != OK) { | 195 if (output_.rv != OK) { |
196 session_->spdy_session_pool()->CloseCurrentSessions(net::ERR_ABORTED); | 196 session_->spdy_session_pool()->CloseCurrentSessions(net::ERR_ABORTED); |
197 return; | 197 return; |
198 } | 198 } |
199 | 199 |
200 // Verify responses. | 200 // Verify responses. |
201 const HttpResponseInfo* response = trans_->GetResponseInfo(); | 201 const HttpResponseInfo* response = trans_->GetResponseInfo(); |
202 ASSERT_TRUE(response != NULL); | 202 ASSERT_TRUE(response != NULL); |
203 ASSERT_TRUE(response->headers != NULL); | 203 ASSERT_TRUE(response->headers.get() != NULL); |
204 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 204 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
205 EXPECT_EQ(spdy_enabled_, response->was_fetched_via_spdy); | 205 EXPECT_EQ(spdy_enabled_, response->was_fetched_via_spdy); |
206 EXPECT_EQ(spdy_enabled_, response->was_fetched_via_spdy); | 206 EXPECT_EQ(spdy_enabled_, response->was_fetched_via_spdy); |
207 if (HttpStreamFactory::spdy_enabled()) { | 207 if (HttpStreamFactory::spdy_enabled()) { |
208 EXPECT_EQ(HttpResponseInfo::CONNECTION_INFO_SPDY2, | 208 EXPECT_EQ(HttpResponseInfo::CONNECTION_INFO_SPDY2, |
209 response->connection_info); | 209 response->connection_info); |
210 } else { | 210 } else { |
211 EXPECT_EQ(HttpResponseInfo::CONNECTION_INFO_HTTP1, | 211 EXPECT_EQ(HttpResponseInfo::CONNECTION_INFO_HTTP1, |
212 response->connection_info); | 212 response->connection_info); |
213 } | 213 } |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 // the data for |trans|. | 483 // the data for |trans|. |
484 int ReadResult(HttpNetworkTransaction* trans, | 484 int ReadResult(HttpNetworkTransaction* trans, |
485 StaticSocketDataProvider* data, | 485 StaticSocketDataProvider* data, |
486 std::string* result) { | 486 std::string* result) { |
487 const int kSize = 3000; | 487 const int kSize = 3000; |
488 | 488 |
489 int bytes_read = 0; | 489 int bytes_read = 0; |
490 scoped_refptr<net::IOBufferWithSize> buf(new net::IOBufferWithSize(kSize)); | 490 scoped_refptr<net::IOBufferWithSize> buf(new net::IOBufferWithSize(kSize)); |
491 TestCompletionCallback callback; | 491 TestCompletionCallback callback; |
492 while (true) { | 492 while (true) { |
493 int rv = trans->Read(buf, kSize, callback.callback()); | 493 int rv = trans->Read(buf.get(), kSize, callback.callback()); |
494 if (rv == ERR_IO_PENDING) { | 494 if (rv == ERR_IO_PENDING) { |
495 // Multiple transactions may be in the data set. Keep pulling off | 495 // Multiple transactions may be in the data set. Keep pulling off |
496 // reads until we complete our callback. | 496 // reads until we complete our callback. |
497 while (!callback.have_result()) { | 497 while (!callback.have_result()) { |
498 data->CompleteRead(); | 498 data->CompleteRead(); |
499 base::MessageLoop::current()->RunUntilIdle(); | 499 base::MessageLoop::current()->RunUntilIdle(); |
500 } | 500 } |
501 rv = callback.WaitForResult(); | 501 rv = callback.WaitForResult(); |
502 } else if (rv <= 0) { | 502 } else if (rv <= 0) { |
503 break; | 503 break; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 | 540 |
541 // Start the transaction with basic parameters. | 541 // Start the transaction with basic parameters. |
542 TestCompletionCallback callback; | 542 TestCompletionCallback callback; |
543 int rv = trans->Start( | 543 int rv = trans->Start( |
544 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 544 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
545 EXPECT_EQ(ERR_IO_PENDING, rv); | 545 EXPECT_EQ(ERR_IO_PENDING, rv); |
546 rv = callback.WaitForResult(); | 546 rv = callback.WaitForResult(); |
547 | 547 |
548 // Request the pushed path. | 548 // Request the pushed path. |
549 scoped_ptr<HttpNetworkTransaction> trans2( | 549 scoped_ptr<HttpNetworkTransaction> trans2( |
550 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 550 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
551 rv = trans2->Start( | 551 rv = trans2->Start( |
552 &CreateGetPushRequest(), callback.callback(), BoundNetLog()); | 552 &CreateGetPushRequest(), callback.callback(), BoundNetLog()); |
553 EXPECT_EQ(ERR_IO_PENDING, rv); | 553 EXPECT_EQ(ERR_IO_PENDING, rv); |
554 base::MessageLoop::current()->RunUntilIdle(); | 554 base::MessageLoop::current()->RunUntilIdle(); |
555 | 555 |
556 // The data for the pushed path may be coming in more than 1 frame. Compile | 556 // The data for the pushed path may be coming in more than 1 frame. Compile |
557 // the results into a single string. | 557 // the results into a single string. |
558 | 558 |
559 // Read the server push body. | 559 // Read the server push body. |
560 std::string result2; | 560 std::string result2; |
(...skipping 22 matching lines...) Expand all Loading... |
583 | 583 |
584 static void DeleteSessionCallback(NormalSpdyTransactionHelper* helper, | 584 static void DeleteSessionCallback(NormalSpdyTransactionHelper* helper, |
585 int result) { | 585 int result) { |
586 helper->ResetTrans(); | 586 helper->ResetTrans(); |
587 } | 587 } |
588 | 588 |
589 static void StartTransactionCallback( | 589 static void StartTransactionCallback( |
590 const scoped_refptr<HttpNetworkSession>& session, | 590 const scoped_refptr<HttpNetworkSession>& session, |
591 int result) { | 591 int result) { |
592 scoped_ptr<HttpNetworkTransaction> trans( | 592 scoped_ptr<HttpNetworkTransaction> trans( |
593 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 593 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
594 TestCompletionCallback callback; | 594 TestCompletionCallback callback; |
595 HttpRequestInfo request; | 595 HttpRequestInfo request; |
596 request.method = "GET"; | 596 request.method = "GET"; |
597 request.url = GURL("http://www.google.com/"); | 597 request.url = GURL("http://www.google.com/"); |
598 request.load_flags = 0; | 598 request.load_flags = 0; |
599 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 599 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
600 EXPECT_EQ(ERR_IO_PENDING, rv); | 600 EXPECT_EQ(ERR_IO_PENDING, rv); |
601 callback.WaitForResult(); | 601 callback.WaitForResult(); |
602 } | 602 } |
603 | 603 |
(...skipping 19 matching lines...) Expand all Loading... |
623 ::testing::Values(SPDYNOSSL, SPDYSSL, SPDYNPN)); | 623 ::testing::Values(SPDYNOSSL, SPDYSSL, SPDYNPN)); |
624 | 624 |
625 | 625 |
626 // Verify HttpNetworkTransaction constructor. | 626 // Verify HttpNetworkTransaction constructor. |
627 TEST_P(SpdyNetworkTransactionSpdy2Test, Constructor) { | 627 TEST_P(SpdyNetworkTransactionSpdy2Test, Constructor) { |
628 scoped_ptr<SpdySessionDependencies> session_deps( | 628 scoped_ptr<SpdySessionDependencies> session_deps( |
629 CreateSpdySessionDependencies()); | 629 CreateSpdySessionDependencies()); |
630 scoped_refptr<HttpNetworkSession> session( | 630 scoped_refptr<HttpNetworkSession> session( |
631 SpdySessionDependencies::SpdyCreateSession(session_deps.get())); | 631 SpdySessionDependencies::SpdyCreateSession(session_deps.get())); |
632 scoped_ptr<HttpTransaction> trans( | 632 scoped_ptr<HttpTransaction> trans( |
633 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 633 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
634 } | 634 } |
635 | 635 |
636 TEST_P(SpdyNetworkTransactionSpdy2Test, Get) { | 636 TEST_P(SpdyNetworkTransactionSpdy2Test, Get) { |
637 // Construct the request. | 637 // Construct the request. |
638 scoped_ptr<SpdyFrame> req( | 638 scoped_ptr<SpdyFrame> req( |
639 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 639 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
640 MockWrite writes[] = { CreateMockWrite(*req) }; | 640 MockWrite writes[] = { CreateMockWrite(*req) }; |
641 | 641 |
642 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 642 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
643 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); | 643 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
767 TransactionHelperResult out; | 767 TransactionHelperResult out; |
768 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 768 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
769 BoundNetLog(), GetParam(), NULL); | 769 BoundNetLog(), GetParam(), NULL); |
770 helper.RunPreTestSetup(); | 770 helper.RunPreTestSetup(); |
771 helper.AddData(&data); | 771 helper.AddData(&data); |
772 // We require placeholder data because three get requests are sent out, so | 772 // We require placeholder data because three get requests are sent out, so |
773 // there needs to be three sets of SSL connection data. | 773 // there needs to be three sets of SSL connection data. |
774 helper.AddData(&data_placeholder); | 774 helper.AddData(&data_placeholder); |
775 helper.AddData(&data_placeholder); | 775 helper.AddData(&data_placeholder); |
776 scoped_ptr<HttpNetworkTransaction> trans1( | 776 scoped_ptr<HttpNetworkTransaction> trans1( |
777 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 777 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
778 scoped_ptr<HttpNetworkTransaction> trans2( | 778 scoped_ptr<HttpNetworkTransaction> trans2( |
779 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 779 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
780 scoped_ptr<HttpNetworkTransaction> trans3( | 780 scoped_ptr<HttpNetworkTransaction> trans3( |
781 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 781 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
782 | 782 |
783 TestCompletionCallback callback1; | 783 TestCompletionCallback callback1; |
784 TestCompletionCallback callback2; | 784 TestCompletionCallback callback2; |
785 TestCompletionCallback callback3; | 785 TestCompletionCallback callback3; |
786 | 786 |
787 HttpRequestInfo httpreq1 = CreateGetRequest(); | 787 HttpRequestInfo httpreq1 = CreateGetRequest(); |
788 HttpRequestInfo httpreq2 = CreateGetRequest(); | 788 HttpRequestInfo httpreq2 = CreateGetRequest(); |
789 HttpRequestInfo httpreq3 = CreateGetRequest(); | 789 HttpRequestInfo httpreq3 = CreateGetRequest(); |
790 | 790 |
791 out.rv = trans1->Start(&httpreq1, callback1.callback(), log); | 791 out.rv = trans1->Start(&httpreq1, callback1.callback(), log); |
792 ASSERT_EQ(ERR_IO_PENDING, out.rv); | 792 ASSERT_EQ(ERR_IO_PENDING, out.rv); |
793 out.rv = trans2->Start(&httpreq2, callback2.callback(), log); | 793 out.rv = trans2->Start(&httpreq2, callback2.callback(), log); |
794 ASSERT_EQ(ERR_IO_PENDING, out.rv); | 794 ASSERT_EQ(ERR_IO_PENDING, out.rv); |
795 out.rv = trans3->Start(&httpreq3, callback3.callback(), log); | 795 out.rv = trans3->Start(&httpreq3, callback3.callback(), log); |
796 ASSERT_EQ(ERR_IO_PENDING, out.rv); | 796 ASSERT_EQ(ERR_IO_PENDING, out.rv); |
797 | 797 |
798 out.rv = callback1.WaitForResult(); | 798 out.rv = callback1.WaitForResult(); |
799 ASSERT_EQ(OK, out.rv); | 799 ASSERT_EQ(OK, out.rv); |
800 out.rv = callback3.WaitForResult(); | 800 out.rv = callback3.WaitForResult(); |
801 ASSERT_EQ(OK, out.rv); | 801 ASSERT_EQ(OK, out.rv); |
802 | 802 |
803 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); | 803 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); |
804 EXPECT_TRUE(response1->headers != NULL); | 804 EXPECT_TRUE(response1->headers.get() != NULL); |
805 EXPECT_TRUE(response1->was_fetched_via_spdy); | 805 EXPECT_TRUE(response1->was_fetched_via_spdy); |
806 out.status_line = response1->headers->GetStatusLine(); | 806 out.status_line = response1->headers->GetStatusLine(); |
807 out.response_info = *response1; | 807 out.response_info = *response1; |
808 | 808 |
809 trans2->GetResponseInfo(); | 809 trans2->GetResponseInfo(); |
810 | 810 |
811 out.rv = ReadTransaction(trans1.get(), &out.response_data); | 811 out.rv = ReadTransaction(trans1.get(), &out.response_data); |
812 helper.VerifyDataConsumed(); | 812 helper.VerifyDataConsumed(); |
813 EXPECT_EQ(OK, out.rv); | 813 EXPECT_EQ(OK, out.rv); |
814 | 814 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 BoundNetLog log; | 854 BoundNetLog log; |
855 TransactionHelperResult out; | 855 TransactionHelperResult out; |
856 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 856 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
857 BoundNetLog(), GetParam(), NULL); | 857 BoundNetLog(), GetParam(), NULL); |
858 helper.RunPreTestSetup(); | 858 helper.RunPreTestSetup(); |
859 helper.AddData(&data); | 859 helper.AddData(&data); |
860 // We require placeholder data because two get requests are sent out, so | 860 // We require placeholder data because two get requests are sent out, so |
861 // there needs to be two sets of SSL connection data. | 861 // there needs to be two sets of SSL connection data. |
862 helper.AddData(&data_placeholder); | 862 helper.AddData(&data_placeholder); |
863 scoped_ptr<HttpNetworkTransaction> trans1( | 863 scoped_ptr<HttpNetworkTransaction> trans1( |
864 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 864 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
865 scoped_ptr<HttpNetworkTransaction> trans2( | 865 scoped_ptr<HttpNetworkTransaction> trans2( |
866 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 866 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
867 | 867 |
868 TestCompletionCallback callback1; | 868 TestCompletionCallback callback1; |
869 TestCompletionCallback callback2; | 869 TestCompletionCallback callback2; |
870 | 870 |
871 HttpRequestInfo httpreq1 = CreateGetRequest(); | 871 HttpRequestInfo httpreq1 = CreateGetRequest(); |
872 HttpRequestInfo httpreq2 = CreateGetRequest(); | 872 HttpRequestInfo httpreq2 = CreateGetRequest(); |
873 | 873 |
874 out.rv = trans1->Start(&httpreq1, callback1.callback(), log); | 874 out.rv = trans1->Start(&httpreq1, callback1.callback(), log); |
875 ASSERT_EQ(ERR_IO_PENDING, out.rv); | 875 ASSERT_EQ(ERR_IO_PENDING, out.rv); |
876 out.rv = trans2->Start(&httpreq2, callback2.callback(), log); | 876 out.rv = trans2->Start(&httpreq2, callback2.callback(), log); |
877 ASSERT_EQ(ERR_IO_PENDING, out.rv); | 877 ASSERT_EQ(ERR_IO_PENDING, out.rv); |
878 | 878 |
879 out.rv = callback1.WaitForResult(); | 879 out.rv = callback1.WaitForResult(); |
880 ASSERT_EQ(OK, out.rv); | 880 ASSERT_EQ(OK, out.rv); |
881 out.rv = callback2.WaitForResult(); | 881 out.rv = callback2.WaitForResult(); |
882 ASSERT_EQ(OK, out.rv); | 882 ASSERT_EQ(OK, out.rv); |
883 | 883 |
884 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); | 884 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); |
885 EXPECT_TRUE(response1->headers != NULL); | 885 EXPECT_TRUE(response1->headers.get() != NULL); |
886 EXPECT_TRUE(response1->was_fetched_via_spdy); | 886 EXPECT_TRUE(response1->was_fetched_via_spdy); |
887 out.status_line = response1->headers->GetStatusLine(); | 887 out.status_line = response1->headers->GetStatusLine(); |
888 out.response_info = *response1; | 888 out.response_info = *response1; |
889 out.rv = ReadTransaction(trans1.get(), &out.response_data); | 889 out.rv = ReadTransaction(trans1.get(), &out.response_data); |
890 EXPECT_EQ(OK, out.rv); | 890 EXPECT_EQ(OK, out.rv); |
891 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 891 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
892 EXPECT_EQ("hello!hello!", out.response_data); | 892 EXPECT_EQ("hello!hello!", out.response_data); |
893 | 893 |
894 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); | 894 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); |
895 EXPECT_TRUE(response2->headers != NULL); | 895 EXPECT_TRUE(response2->headers.get() != NULL); |
896 EXPECT_TRUE(response2->was_fetched_via_spdy); | 896 EXPECT_TRUE(response2->was_fetched_via_spdy); |
897 out.status_line = response2->headers->GetStatusLine(); | 897 out.status_line = response2->headers->GetStatusLine(); |
898 out.response_info = *response2; | 898 out.response_info = *response2; |
899 out.rv = ReadTransaction(trans2.get(), &out.response_data); | 899 out.rv = ReadTransaction(trans2.get(), &out.response_data); |
900 EXPECT_EQ(OK, out.rv); | 900 EXPECT_EQ(OK, out.rv); |
901 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 901 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
902 EXPECT_EQ("hello!hello!", out.response_data); | 902 EXPECT_EQ("hello!hello!", out.response_data); |
903 | 903 |
904 helper.VerifyDataConsumed(); | 904 helper.VerifyDataConsumed(); |
905 } | 905 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 943 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
944 BoundNetLog(), GetParam(), NULL); | 944 BoundNetLog(), GetParam(), NULL); |
945 helper.RunPreTestSetup(); | 945 helper.RunPreTestSetup(); |
946 helper.AddData(&preconnect_data); | 946 helper.AddData(&preconnect_data); |
947 // We require placeholder data because 3 connections are attempted (first is | 947 // We require placeholder data because 3 connections are attempted (first is |
948 // the preconnect, 2nd and 3rd are the never finished connections. | 948 // the preconnect, 2nd and 3rd are the never finished connections. |
949 helper.AddData(&data_placeholder); | 949 helper.AddData(&data_placeholder); |
950 helper.AddData(&data_placeholder); | 950 helper.AddData(&data_placeholder); |
951 | 951 |
952 scoped_ptr<HttpNetworkTransaction> trans1( | 952 scoped_ptr<HttpNetworkTransaction> trans1( |
953 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 953 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
954 scoped_ptr<HttpNetworkTransaction> trans2( | 954 scoped_ptr<HttpNetworkTransaction> trans2( |
955 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 955 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
956 | 956 |
957 TestCompletionCallback callback1; | 957 TestCompletionCallback callback1; |
958 TestCompletionCallback callback2; | 958 TestCompletionCallback callback2; |
959 | 959 |
960 HttpRequestInfo httpreq = CreateGetRequest(); | 960 HttpRequestInfo httpreq = CreateGetRequest(); |
961 | 961 |
962 // Preconnect the first. | 962 // Preconnect the first. |
963 SSLConfig preconnect_ssl_config; | 963 SSLConfig preconnect_ssl_config; |
964 helper.session()->ssl_config_service()->GetSSLConfig(&preconnect_ssl_config); | 964 helper.session()->ssl_config_service()->GetSSLConfig(&preconnect_ssl_config); |
965 HttpStreamFactory* http_stream_factory = | 965 HttpStreamFactory* http_stream_factory = |
(...skipping 10 matching lines...) Expand all Loading... |
976 ASSERT_EQ(ERR_IO_PENDING, out.rv); | 976 ASSERT_EQ(ERR_IO_PENDING, out.rv); |
977 out.rv = trans2->Start(&httpreq, callback2.callback(), log); | 977 out.rv = trans2->Start(&httpreq, callback2.callback(), log); |
978 ASSERT_EQ(ERR_IO_PENDING, out.rv); | 978 ASSERT_EQ(ERR_IO_PENDING, out.rv); |
979 | 979 |
980 out.rv = callback1.WaitForResult(); | 980 out.rv = callback1.WaitForResult(); |
981 ASSERT_EQ(OK, out.rv); | 981 ASSERT_EQ(OK, out.rv); |
982 out.rv = callback2.WaitForResult(); | 982 out.rv = callback2.WaitForResult(); |
983 ASSERT_EQ(OK, out.rv); | 983 ASSERT_EQ(OK, out.rv); |
984 | 984 |
985 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); | 985 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); |
986 EXPECT_TRUE(response1->headers != NULL); | 986 EXPECT_TRUE(response1->headers.get() != NULL); |
987 EXPECT_TRUE(response1->was_fetched_via_spdy); | 987 EXPECT_TRUE(response1->was_fetched_via_spdy); |
988 out.status_line = response1->headers->GetStatusLine(); | 988 out.status_line = response1->headers->GetStatusLine(); |
989 out.response_info = *response1; | 989 out.response_info = *response1; |
990 out.rv = ReadTransaction(trans1.get(), &out.response_data); | 990 out.rv = ReadTransaction(trans1.get(), &out.response_data); |
991 EXPECT_EQ(OK, out.rv); | 991 EXPECT_EQ(OK, out.rv); |
992 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 992 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
993 EXPECT_EQ("hello!hello!", out.response_data); | 993 EXPECT_EQ("hello!hello!", out.response_data); |
994 | 994 |
995 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); | 995 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); |
996 EXPECT_TRUE(response2->headers != NULL); | 996 EXPECT_TRUE(response2->headers.get() != NULL); |
997 EXPECT_TRUE(response2->was_fetched_via_spdy); | 997 EXPECT_TRUE(response2->was_fetched_via_spdy); |
998 out.status_line = response2->headers->GetStatusLine(); | 998 out.status_line = response2->headers->GetStatusLine(); |
999 out.response_info = *response2; | 999 out.response_info = *response2; |
1000 out.rv = ReadTransaction(trans2.get(), &out.response_data); | 1000 out.rv = ReadTransaction(trans2.get(), &out.response_data); |
1001 EXPECT_EQ(OK, out.rv); | 1001 EXPECT_EQ(OK, out.rv); |
1002 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 1002 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
1003 EXPECT_EQ("hello!hello!", out.response_data); | 1003 EXPECT_EQ("hello!hello!", out.response_data); |
1004 | 1004 |
1005 helper.VerifyDataConsumed(); | 1005 helper.VerifyDataConsumed(); |
1006 } | 1006 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1067 { | 1067 { |
1068 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 1068 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
1069 BoundNetLog(), GetParam(), NULL); | 1069 BoundNetLog(), GetParam(), NULL); |
1070 helper.RunPreTestSetup(); | 1070 helper.RunPreTestSetup(); |
1071 helper.AddData(&data); | 1071 helper.AddData(&data); |
1072 // We require placeholder data because three get requests are sent out, so | 1072 // We require placeholder data because three get requests are sent out, so |
1073 // there needs to be three sets of SSL connection data. | 1073 // there needs to be three sets of SSL connection data. |
1074 helper.AddData(&data_placeholder); | 1074 helper.AddData(&data_placeholder); |
1075 helper.AddData(&data_placeholder); | 1075 helper.AddData(&data_placeholder); |
1076 scoped_ptr<HttpNetworkTransaction> trans1( | 1076 scoped_ptr<HttpNetworkTransaction> trans1( |
1077 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 1077 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
1078 scoped_ptr<HttpNetworkTransaction> trans2( | 1078 scoped_ptr<HttpNetworkTransaction> trans2( |
1079 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 1079 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
1080 scoped_ptr<HttpNetworkTransaction> trans3( | 1080 scoped_ptr<HttpNetworkTransaction> trans3( |
1081 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 1081 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
1082 | 1082 |
1083 TestCompletionCallback callback1; | 1083 TestCompletionCallback callback1; |
1084 TestCompletionCallback callback2; | 1084 TestCompletionCallback callback2; |
1085 TestCompletionCallback callback3; | 1085 TestCompletionCallback callback3; |
1086 | 1086 |
1087 HttpRequestInfo httpreq1 = CreateGetRequest(); | 1087 HttpRequestInfo httpreq1 = CreateGetRequest(); |
1088 HttpRequestInfo httpreq2 = CreateGetRequest(); | 1088 HttpRequestInfo httpreq2 = CreateGetRequest(); |
1089 HttpRequestInfo httpreq3 = CreateGetRequest(); | 1089 HttpRequestInfo httpreq3 = CreateGetRequest(); |
1090 | 1090 |
1091 out.rv = trans1->Start(&httpreq1, callback1.callback(), log); | 1091 out.rv = trans1->Start(&httpreq1, callback1.callback(), log); |
1092 ASSERT_EQ(out.rv, ERR_IO_PENDING); | 1092 ASSERT_EQ(out.rv, ERR_IO_PENDING); |
1093 // Run transaction 1 through quickly to force a read of our SETTINGS | 1093 // Run transaction 1 through quickly to force a read of our SETTINGS |
1094 // frame. | 1094 // frame. |
1095 out.rv = callback1.WaitForResult(); | 1095 out.rv = callback1.WaitForResult(); |
1096 ASSERT_EQ(OK, out.rv); | 1096 ASSERT_EQ(OK, out.rv); |
1097 | 1097 |
1098 out.rv = trans2->Start(&httpreq2, callback2.callback(), log); | 1098 out.rv = trans2->Start(&httpreq2, callback2.callback(), log); |
1099 ASSERT_EQ(out.rv, ERR_IO_PENDING); | 1099 ASSERT_EQ(out.rv, ERR_IO_PENDING); |
1100 out.rv = trans3->Start(&httpreq3, callback3.callback(), log); | 1100 out.rv = trans3->Start(&httpreq3, callback3.callback(), log); |
1101 ASSERT_EQ(out.rv, ERR_IO_PENDING); | 1101 ASSERT_EQ(out.rv, ERR_IO_PENDING); |
1102 out.rv = callback2.WaitForResult(); | 1102 out.rv = callback2.WaitForResult(); |
1103 ASSERT_EQ(OK, out.rv); | 1103 ASSERT_EQ(OK, out.rv); |
1104 EXPECT_EQ(7U, data.read_index()); // i.e. the third trans was queued | 1104 EXPECT_EQ(7U, data.read_index()); // i.e. the third trans was queued |
1105 | 1105 |
1106 out.rv = callback3.WaitForResult(); | 1106 out.rv = callback3.WaitForResult(); |
1107 ASSERT_EQ(OK, out.rv); | 1107 ASSERT_EQ(OK, out.rv); |
1108 | 1108 |
1109 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); | 1109 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); |
1110 ASSERT_TRUE(response1 != NULL); | 1110 ASSERT_TRUE(response1 != NULL); |
1111 EXPECT_TRUE(response1->headers != NULL); | 1111 EXPECT_TRUE(response1->headers.get() != NULL); |
1112 EXPECT_TRUE(response1->was_fetched_via_spdy); | 1112 EXPECT_TRUE(response1->was_fetched_via_spdy); |
1113 out.status_line = response1->headers->GetStatusLine(); | 1113 out.status_line = response1->headers->GetStatusLine(); |
1114 out.response_info = *response1; | 1114 out.response_info = *response1; |
1115 out.rv = ReadTransaction(trans1.get(), &out.response_data); | 1115 out.rv = ReadTransaction(trans1.get(), &out.response_data); |
1116 EXPECT_EQ(OK, out.rv); | 1116 EXPECT_EQ(OK, out.rv); |
1117 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 1117 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
1118 EXPECT_EQ("hello!hello!", out.response_data); | 1118 EXPECT_EQ("hello!hello!", out.response_data); |
1119 | 1119 |
1120 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); | 1120 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); |
1121 out.status_line = response2->headers->GetStatusLine(); | 1121 out.status_line = response2->headers->GetStatusLine(); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1206 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 1206 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
1207 BoundNetLog(), GetParam(), NULL); | 1207 BoundNetLog(), GetParam(), NULL); |
1208 helper.RunPreTestSetup(); | 1208 helper.RunPreTestSetup(); |
1209 helper.AddData(&data); | 1209 helper.AddData(&data); |
1210 // We require placeholder data because four get requests are sent out, so | 1210 // We require placeholder data because four get requests are sent out, so |
1211 // there needs to be four sets of SSL connection data. | 1211 // there needs to be four sets of SSL connection data. |
1212 helper.AddData(&data_placeholder); | 1212 helper.AddData(&data_placeholder); |
1213 helper.AddData(&data_placeholder); | 1213 helper.AddData(&data_placeholder); |
1214 helper.AddData(&data_placeholder); | 1214 helper.AddData(&data_placeholder); |
1215 scoped_ptr<HttpNetworkTransaction> trans1( | 1215 scoped_ptr<HttpNetworkTransaction> trans1( |
1216 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 1216 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
1217 scoped_ptr<HttpNetworkTransaction> trans2( | 1217 scoped_ptr<HttpNetworkTransaction> trans2( |
1218 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 1218 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
1219 scoped_ptr<HttpNetworkTransaction> trans3( | 1219 scoped_ptr<HttpNetworkTransaction> trans3( |
1220 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 1220 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
1221 scoped_ptr<HttpNetworkTransaction> trans4( | 1221 scoped_ptr<HttpNetworkTransaction> trans4( |
1222 new HttpNetworkTransaction(HIGHEST, helper.session())); | 1222 new HttpNetworkTransaction(HIGHEST, helper.session().get())); |
1223 | 1223 |
1224 TestCompletionCallback callback1; | 1224 TestCompletionCallback callback1; |
1225 TestCompletionCallback callback2; | 1225 TestCompletionCallback callback2; |
1226 TestCompletionCallback callback3; | 1226 TestCompletionCallback callback3; |
1227 TestCompletionCallback callback4; | 1227 TestCompletionCallback callback4; |
1228 | 1228 |
1229 HttpRequestInfo httpreq1 = CreateGetRequest(); | 1229 HttpRequestInfo httpreq1 = CreateGetRequest(); |
1230 HttpRequestInfo httpreq2 = CreateGetRequest(); | 1230 HttpRequestInfo httpreq2 = CreateGetRequest(); |
1231 HttpRequestInfo httpreq3 = CreateGetRequest(); | 1231 HttpRequestInfo httpreq3 = CreateGetRequest(); |
1232 HttpRequestInfo httpreq4 = CreateGetRequest(); | 1232 HttpRequestInfo httpreq4 = CreateGetRequest(); |
(...skipping 12 matching lines...) Expand all Loading... |
1245 ASSERT_EQ(ERR_IO_PENDING, out.rv); | 1245 ASSERT_EQ(ERR_IO_PENDING, out.rv); |
1246 | 1246 |
1247 out.rv = callback2.WaitForResult(); | 1247 out.rv = callback2.WaitForResult(); |
1248 ASSERT_EQ(OK, out.rv); | 1248 ASSERT_EQ(OK, out.rv); |
1249 EXPECT_EQ(data.read_index(), 7U); // i.e. the third & fourth trans queued | 1249 EXPECT_EQ(data.read_index(), 7U); // i.e. the third & fourth trans queued |
1250 | 1250 |
1251 out.rv = callback3.WaitForResult(); | 1251 out.rv = callback3.WaitForResult(); |
1252 ASSERT_EQ(OK, out.rv); | 1252 ASSERT_EQ(OK, out.rv); |
1253 | 1253 |
1254 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); | 1254 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); |
1255 EXPECT_TRUE(response1->headers != NULL); | 1255 EXPECT_TRUE(response1->headers.get() != NULL); |
1256 EXPECT_TRUE(response1->was_fetched_via_spdy); | 1256 EXPECT_TRUE(response1->was_fetched_via_spdy); |
1257 out.status_line = response1->headers->GetStatusLine(); | 1257 out.status_line = response1->headers->GetStatusLine(); |
1258 out.response_info = *response1; | 1258 out.response_info = *response1; |
1259 out.rv = ReadTransaction(trans1.get(), &out.response_data); | 1259 out.rv = ReadTransaction(trans1.get(), &out.response_data); |
1260 EXPECT_EQ(OK, out.rv); | 1260 EXPECT_EQ(OK, out.rv); |
1261 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 1261 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
1262 EXPECT_EQ("hello!hello!", out.response_data); | 1262 EXPECT_EQ("hello!hello!", out.response_data); |
1263 | 1263 |
1264 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); | 1264 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); |
1265 out.status_line = response2->headers->GetStatusLine(); | 1265 out.status_line = response2->headers->GetStatusLine(); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1339 TransactionHelperResult out; | 1339 TransactionHelperResult out; |
1340 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 1340 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
1341 BoundNetLog(), GetParam(), NULL); | 1341 BoundNetLog(), GetParam(), NULL); |
1342 helper.RunPreTestSetup(); | 1342 helper.RunPreTestSetup(); |
1343 helper.AddData(&data); | 1343 helper.AddData(&data); |
1344 // We require placeholder data because three get requests are sent out, so | 1344 // We require placeholder data because three get requests are sent out, so |
1345 // there needs to be three sets of SSL connection data. | 1345 // there needs to be three sets of SSL connection data. |
1346 helper.AddData(&data_placeholder); | 1346 helper.AddData(&data_placeholder); |
1347 helper.AddData(&data_placeholder); | 1347 helper.AddData(&data_placeholder); |
1348 scoped_ptr<HttpNetworkTransaction> trans1( | 1348 scoped_ptr<HttpNetworkTransaction> trans1( |
1349 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 1349 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
1350 scoped_ptr<HttpNetworkTransaction> trans2( | 1350 scoped_ptr<HttpNetworkTransaction> trans2( |
1351 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 1351 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
1352 scoped_ptr<HttpNetworkTransaction> trans3( | 1352 scoped_ptr<HttpNetworkTransaction> trans3( |
1353 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 1353 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
1354 | 1354 |
1355 TestCompletionCallback callback1; | 1355 TestCompletionCallback callback1; |
1356 TestCompletionCallback callback2; | 1356 TestCompletionCallback callback2; |
1357 TestCompletionCallback callback3; | 1357 TestCompletionCallback callback3; |
1358 | 1358 |
1359 HttpRequestInfo httpreq1 = CreateGetRequest(); | 1359 HttpRequestInfo httpreq1 = CreateGetRequest(); |
1360 HttpRequestInfo httpreq2 = CreateGetRequest(); | 1360 HttpRequestInfo httpreq2 = CreateGetRequest(); |
1361 HttpRequestInfo httpreq3 = CreateGetRequest(); | 1361 HttpRequestInfo httpreq3 = CreateGetRequest(); |
1362 | 1362 |
1363 out.rv = trans1->Start(&httpreq1, callback1.callback(), log); | 1363 out.rv = trans1->Start(&httpreq1, callback1.callback(), log); |
1364 ASSERT_EQ(out.rv, ERR_IO_PENDING); | 1364 ASSERT_EQ(out.rv, ERR_IO_PENDING); |
1365 // Run transaction 1 through quickly to force a read of our SETTINGS frame. | 1365 // Run transaction 1 through quickly to force a read of our SETTINGS frame. |
1366 out.rv = callback1.WaitForResult(); | 1366 out.rv = callback1.WaitForResult(); |
1367 ASSERT_EQ(OK, out.rv); | 1367 ASSERT_EQ(OK, out.rv); |
1368 | 1368 |
1369 out.rv = trans2->Start(&httpreq2, callback2.callback(), log); | 1369 out.rv = trans2->Start(&httpreq2, callback2.callback(), log); |
1370 ASSERT_EQ(out.rv, ERR_IO_PENDING); | 1370 ASSERT_EQ(out.rv, ERR_IO_PENDING); |
1371 out.rv = trans3->Start(&httpreq3, callback3.callback(), log); | 1371 out.rv = trans3->Start(&httpreq3, callback3.callback(), log); |
1372 delete trans3.release(); | 1372 delete trans3.release(); |
1373 ASSERT_EQ(out.rv, ERR_IO_PENDING); | 1373 ASSERT_EQ(out.rv, ERR_IO_PENDING); |
1374 out.rv = callback2.WaitForResult(); | 1374 out.rv = callback2.WaitForResult(); |
1375 ASSERT_EQ(OK, out.rv); | 1375 ASSERT_EQ(OK, out.rv); |
1376 | 1376 |
1377 EXPECT_EQ(8U, data.read_index()); | 1377 EXPECT_EQ(8U, data.read_index()); |
1378 | 1378 |
1379 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); | 1379 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); |
1380 ASSERT_TRUE(response1 != NULL); | 1380 ASSERT_TRUE(response1 != NULL); |
1381 EXPECT_TRUE(response1->headers != NULL); | 1381 EXPECT_TRUE(response1->headers.get() != NULL); |
1382 EXPECT_TRUE(response1->was_fetched_via_spdy); | 1382 EXPECT_TRUE(response1->was_fetched_via_spdy); |
1383 out.status_line = response1->headers->GetStatusLine(); | 1383 out.status_line = response1->headers->GetStatusLine(); |
1384 out.response_info = *response1; | 1384 out.response_info = *response1; |
1385 out.rv = ReadTransaction(trans1.get(), &out.response_data); | 1385 out.rv = ReadTransaction(trans1.get(), &out.response_data); |
1386 EXPECT_EQ(OK, out.rv); | 1386 EXPECT_EQ(OK, out.rv); |
1387 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 1387 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
1388 EXPECT_EQ("hello!hello!", out.response_data); | 1388 EXPECT_EQ("hello!hello!", out.response_data); |
1389 | 1389 |
1390 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); | 1390 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); |
1391 ASSERT_TRUE(response2 != NULL); | 1391 ASSERT_TRUE(response2 != NULL); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1470 BoundNetLog log; | 1470 BoundNetLog log; |
1471 TransactionHelperResult out; | 1471 TransactionHelperResult out; |
1472 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 1472 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
1473 BoundNetLog(), GetParam(), NULL); | 1473 BoundNetLog(), GetParam(), NULL); |
1474 helper.RunPreTestSetup(); | 1474 helper.RunPreTestSetup(); |
1475 helper.AddData(&data); | 1475 helper.AddData(&data); |
1476 // We require placeholder data because three get requests are sent out, so | 1476 // We require placeholder data because three get requests are sent out, so |
1477 // there needs to be three sets of SSL connection data. | 1477 // there needs to be three sets of SSL connection data. |
1478 helper.AddData(&data_placeholder); | 1478 helper.AddData(&data_placeholder); |
1479 helper.AddData(&data_placeholder); | 1479 helper.AddData(&data_placeholder); |
1480 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, helper.session()); | 1480 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, helper.session().get()); |
1481 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, helper.session()); | 1481 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, helper.session().get()); |
1482 HttpNetworkTransaction* trans3( | 1482 HttpNetworkTransaction* trans3( |
1483 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 1483 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
1484 | 1484 |
1485 TestCompletionCallback callback1; | 1485 TestCompletionCallback callback1; |
1486 TestCompletionCallback callback2; | 1486 TestCompletionCallback callback2; |
1487 KillerCallback callback3(trans3); | 1487 KillerCallback callback3(trans3); |
1488 | 1488 |
1489 HttpRequestInfo httpreq1 = CreateGetRequest(); | 1489 HttpRequestInfo httpreq1 = CreateGetRequest(); |
1490 HttpRequestInfo httpreq2 = CreateGetRequest(); | 1490 HttpRequestInfo httpreq2 = CreateGetRequest(); |
1491 HttpRequestInfo httpreq3 = CreateGetRequest(); | 1491 HttpRequestInfo httpreq3 = CreateGetRequest(); |
1492 | 1492 |
1493 out.rv = trans1.Start(&httpreq1, callback1.callback(), log); | 1493 out.rv = trans1.Start(&httpreq1, callback1.callback(), log); |
1494 ASSERT_EQ(out.rv, ERR_IO_PENDING); | 1494 ASSERT_EQ(out.rv, ERR_IO_PENDING); |
1495 // Run transaction 1 through quickly to force a read of our SETTINGS frame. | 1495 // Run transaction 1 through quickly to force a read of our SETTINGS frame. |
1496 out.rv = callback1.WaitForResult(); | 1496 out.rv = callback1.WaitForResult(); |
1497 ASSERT_EQ(OK, out.rv); | 1497 ASSERT_EQ(OK, out.rv); |
1498 | 1498 |
1499 out.rv = trans2.Start(&httpreq2, callback2.callback(), log); | 1499 out.rv = trans2.Start(&httpreq2, callback2.callback(), log); |
1500 ASSERT_EQ(out.rv, ERR_IO_PENDING); | 1500 ASSERT_EQ(out.rv, ERR_IO_PENDING); |
1501 out.rv = trans3->Start(&httpreq3, callback3.callback(), log); | 1501 out.rv = trans3->Start(&httpreq3, callback3.callback(), log); |
1502 ASSERT_EQ(out.rv, ERR_IO_PENDING); | 1502 ASSERT_EQ(out.rv, ERR_IO_PENDING); |
1503 out.rv = callback3.WaitForResult(); | 1503 out.rv = callback3.WaitForResult(); |
1504 ASSERT_EQ(ERR_ABORTED, out.rv); | 1504 ASSERT_EQ(ERR_ABORTED, out.rv); |
1505 | 1505 |
1506 EXPECT_EQ(6U, data.read_index()); | 1506 EXPECT_EQ(6U, data.read_index()); |
1507 | 1507 |
1508 const HttpResponseInfo* response1 = trans1.GetResponseInfo(); | 1508 const HttpResponseInfo* response1 = trans1.GetResponseInfo(); |
1509 ASSERT_TRUE(response1 != NULL); | 1509 ASSERT_TRUE(response1 != NULL); |
1510 EXPECT_TRUE(response1->headers != NULL); | 1510 EXPECT_TRUE(response1->headers.get() != NULL); |
1511 EXPECT_TRUE(response1->was_fetched_via_spdy); | 1511 EXPECT_TRUE(response1->was_fetched_via_spdy); |
1512 out.status_line = response1->headers->GetStatusLine(); | 1512 out.status_line = response1->headers->GetStatusLine(); |
1513 out.response_info = *response1; | 1513 out.response_info = *response1; |
1514 out.rv = ReadTransaction(&trans1, &out.response_data); | 1514 out.rv = ReadTransaction(&trans1, &out.response_data); |
1515 EXPECT_EQ(OK, out.rv); | 1515 EXPECT_EQ(OK, out.rv); |
1516 | 1516 |
1517 const HttpResponseInfo* response2 = trans2.GetResponseInfo(); | 1517 const HttpResponseInfo* response2 = trans2.GetResponseInfo(); |
1518 ASSERT_TRUE(response2 != NULL); | 1518 ASSERT_TRUE(response2 != NULL); |
1519 out.status_line = response2->headers->GetStatusLine(); | 1519 out.status_line = response2->headers->GetStatusLine(); |
1520 out.response_info = *response2; | 1520 out.response_info = *response2; |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2066 HttpNetworkTransaction* trans = helper.trans(); | 2066 HttpNetworkTransaction* trans = helper.trans(); |
2067 | 2067 |
2068 TestCompletionCallback callback; | 2068 TestCompletionCallback callback; |
2069 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); | 2069 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); |
2070 EXPECT_EQ(ERR_IO_PENDING, rv); | 2070 EXPECT_EQ(ERR_IO_PENDING, rv); |
2071 rv = callback.WaitForResult(); | 2071 rv = callback.WaitForResult(); |
2072 EXPECT_EQ(OK, rv); | 2072 EXPECT_EQ(OK, rv); |
2073 | 2073 |
2074 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2074 const HttpResponseInfo* response = trans->GetResponseInfo(); |
2075 ASSERT_TRUE(response != NULL); | 2075 ASSERT_TRUE(response != NULL); |
2076 EXPECT_TRUE(response->headers != NULL); | 2076 EXPECT_TRUE(response->headers.get() != NULL); |
2077 EXPECT_TRUE(response->was_fetched_via_spdy); | 2077 EXPECT_TRUE(response->was_fetched_via_spdy); |
2078 std::string response_data; | 2078 std::string response_data; |
2079 rv = ReadTransaction(trans, &response_data); | 2079 rv = ReadTransaction(trans, &response_data); |
2080 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, rv); | 2080 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, rv); |
2081 | 2081 |
2082 helper.VerifyDataConsumed(); | 2082 helper.VerifyDataConsumed(); |
2083 } | 2083 } |
2084 | 2084 |
2085 TEST_P(SpdyNetworkTransactionSpdy2Test, ResetReplyWithTransferEncoding) { | 2085 TEST_P(SpdyNetworkTransactionSpdy2Test, ResetReplyWithTransferEncoding) { |
2086 // Construct the request. | 2086 // Construct the request. |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2282 | 2282 |
2283 // Start the transaction with basic parameters. | 2283 // Start the transaction with basic parameters. |
2284 TestCompletionCallback callback; | 2284 TestCompletionCallback callback; |
2285 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); | 2285 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); |
2286 EXPECT_EQ(ERR_IO_PENDING, rv); | 2286 EXPECT_EQ(ERR_IO_PENDING, rv); |
2287 rv = callback.WaitForResult(); | 2287 rv = callback.WaitForResult(); |
2288 | 2288 |
2289 const int kSize = 3000; | 2289 const int kSize = 3000; |
2290 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSize)); | 2290 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSize)); |
2291 rv = trans->Read( | 2291 rv = trans->Read( |
2292 buf, kSize, | 2292 buf.get(), |
| 2293 kSize, |
2293 base::Bind(&SpdyNetworkTransactionSpdy2Test::StartTransactionCallback, | 2294 base::Bind(&SpdyNetworkTransactionSpdy2Test::StartTransactionCallback, |
2294 helper.session())); | 2295 helper.session())); |
2295 // This forces an err_IO_pending, which sets the callback. | 2296 // This forces an err_IO_pending, which sets the callback. |
2296 data.CompleteRead(); | 2297 data.CompleteRead(); |
2297 // This finishes the read. | 2298 // This finishes the read. |
2298 data.CompleteRead(); | 2299 data.CompleteRead(); |
2299 helper.VerifyDataConsumed(); | 2300 helper.VerifyDataConsumed(); |
2300 } | 2301 } |
2301 | 2302 |
2302 // Verify that the client can correctly deal with the user callback deleting the | 2303 // Verify that the client can correctly deal with the user callback deleting the |
(...skipping 26 matching lines...) Expand all Loading... |
2329 TestCompletionCallback callback; | 2330 TestCompletionCallback callback; |
2330 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); | 2331 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); |
2331 EXPECT_EQ(ERR_IO_PENDING, rv); | 2332 EXPECT_EQ(ERR_IO_PENDING, rv); |
2332 rv = callback.WaitForResult(); | 2333 rv = callback.WaitForResult(); |
2333 | 2334 |
2334 // Setup a user callback which will delete the session, and clear out the | 2335 // Setup a user callback which will delete the session, and clear out the |
2335 // memory holding the stream object. Note that the callback deletes trans. | 2336 // memory holding the stream object. Note that the callback deletes trans. |
2336 const int kSize = 3000; | 2337 const int kSize = 3000; |
2337 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSize)); | 2338 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSize)); |
2338 rv = trans->Read( | 2339 rv = trans->Read( |
2339 buf, kSize, | 2340 buf.get(), |
| 2341 kSize, |
2340 base::Bind(&SpdyNetworkTransactionSpdy2Test::DeleteSessionCallback, | 2342 base::Bind(&SpdyNetworkTransactionSpdy2Test::DeleteSessionCallback, |
2341 base::Unretained(&helper))); | 2343 base::Unretained(&helper))); |
2342 ASSERT_EQ(ERR_IO_PENDING, rv); | 2344 ASSERT_EQ(ERR_IO_PENDING, rv); |
2343 data.CompleteRead(); | 2345 data.CompleteRead(); |
2344 | 2346 |
2345 // Finish running rest of tasks. | 2347 // Finish running rest of tasks. |
2346 base::MessageLoop::current()->RunUntilIdle(); | 2348 base::MessageLoop::current()->RunUntilIdle(); |
2347 helper.VerifyDataConsumed(); | 2349 helper.VerifyDataConsumed(); |
2348 } | 2350 } |
2349 | 2351 |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2742 HttpResponseInfo response2; | 2744 HttpResponseInfo response2; |
2743 std::string expected_push_result("pushed"); | 2745 std::string expected_push_result("pushed"); |
2744 OrderedSocketData data(reads, arraysize(reads), | 2746 OrderedSocketData data(reads, arraysize(reads), |
2745 writes, arraysize(writes)); | 2747 writes, arraysize(writes)); |
2746 RunServerPushTest(&data, | 2748 RunServerPushTest(&data, |
2747 &response, | 2749 &response, |
2748 &response2, | 2750 &response2, |
2749 expected_push_result); | 2751 expected_push_result); |
2750 | 2752 |
2751 // Verify the SYN_REPLY. | 2753 // Verify the SYN_REPLY. |
2752 EXPECT_TRUE(response.headers != NULL); | 2754 EXPECT_TRUE(response.headers.get() != NULL); |
2753 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 2755 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
2754 | 2756 |
2755 // Verify the pushed stream. | 2757 // Verify the pushed stream. |
2756 EXPECT_TRUE(response2.headers != NULL); | 2758 EXPECT_TRUE(response2.headers.get() != NULL); |
2757 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 2759 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
2758 } | 2760 } |
2759 | 2761 |
2760 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushBeforeSynReply) { | 2762 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushBeforeSynReply) { |
2761 static const unsigned char kPushBodyFrame[] = { | 2763 static const unsigned char kPushBodyFrame[] = { |
2762 0x00, 0x00, 0x00, 0x02, // header, ID | 2764 0x00, 0x00, 0x00, 0x02, // header, ID |
2763 0x01, 0x00, 0x00, 0x06, // FIN, length | 2765 0x01, 0x00, 0x00, 0x06, // FIN, length |
2764 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | 2766 'p', 'u', 's', 'h', 'e', 'd' // "pushed" |
2765 }; | 2767 }; |
2766 scoped_ptr<SpdyFrame> stream1_syn( | 2768 scoped_ptr<SpdyFrame> stream1_syn( |
(...skipping 24 matching lines...) Expand all Loading... |
2791 HttpResponseInfo response2; | 2793 HttpResponseInfo response2; |
2792 std::string expected_push_result("pushed"); | 2794 std::string expected_push_result("pushed"); |
2793 OrderedSocketData data(reads, arraysize(reads), | 2795 OrderedSocketData data(reads, arraysize(reads), |
2794 writes, arraysize(writes)); | 2796 writes, arraysize(writes)); |
2795 RunServerPushTest(&data, | 2797 RunServerPushTest(&data, |
2796 &response, | 2798 &response, |
2797 &response2, | 2799 &response2, |
2798 expected_push_result); | 2800 expected_push_result); |
2799 | 2801 |
2800 // Verify the SYN_REPLY. | 2802 // Verify the SYN_REPLY. |
2801 EXPECT_TRUE(response.headers != NULL); | 2803 EXPECT_TRUE(response.headers.get() != NULL); |
2802 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 2804 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
2803 | 2805 |
2804 // Verify the pushed stream. | 2806 // Verify the pushed stream. |
2805 EXPECT_TRUE(response2.headers != NULL); | 2807 EXPECT_TRUE(response2.headers.get() != NULL); |
2806 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 2808 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
2807 } | 2809 } |
2808 | 2810 |
2809 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushSingleDataFrame2) { | 2811 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushSingleDataFrame2) { |
2810 static const unsigned char kPushBodyFrame[] = { | 2812 static const unsigned char kPushBodyFrame[] = { |
2811 0x00, 0x00, 0x00, 0x02, // header, ID | 2813 0x00, 0x00, 0x00, 0x02, // header, ID |
2812 0x01, 0x00, 0x00, 0x06, // FIN, length | 2814 0x01, 0x00, 0x00, 0x06, // FIN, length |
2813 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | 2815 'p', 'u', 's', 'h', 'e', 'd' // "pushed" |
2814 }; | 2816 }; |
2815 scoped_ptr<SpdyFrame> stream1_syn( | 2817 scoped_ptr<SpdyFrame> stream1_syn( |
(...skipping 23 matching lines...) Expand all Loading... |
2839 HttpResponseInfo response2; | 2841 HttpResponseInfo response2; |
2840 std::string expected_push_result("pushed"); | 2842 std::string expected_push_result("pushed"); |
2841 OrderedSocketData data(reads, arraysize(reads), | 2843 OrderedSocketData data(reads, arraysize(reads), |
2842 writes, arraysize(writes)); | 2844 writes, arraysize(writes)); |
2843 RunServerPushTest(&data, | 2845 RunServerPushTest(&data, |
2844 &response, | 2846 &response, |
2845 &response2, | 2847 &response2, |
2846 expected_push_result); | 2848 expected_push_result); |
2847 | 2849 |
2848 // Verify the SYN_REPLY. | 2850 // Verify the SYN_REPLY. |
2849 EXPECT_TRUE(response.headers != NULL); | 2851 EXPECT_TRUE(response.headers.get() != NULL); |
2850 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 2852 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
2851 | 2853 |
2852 // Verify the pushed stream. | 2854 // Verify the pushed stream. |
2853 EXPECT_TRUE(response2.headers != NULL); | 2855 EXPECT_TRUE(response2.headers.get() != NULL); |
2854 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 2856 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
2855 } | 2857 } |
2856 | 2858 |
2857 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushServerAborted) { | 2859 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushServerAborted) { |
2858 scoped_ptr<SpdyFrame> stream1_syn( | 2860 scoped_ptr<SpdyFrame> stream1_syn( |
2859 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 2861 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
2860 scoped_ptr<SpdyFrame> stream1_body(ConstructSpdyBodyFrame(1, true)); | 2862 scoped_ptr<SpdyFrame> stream1_body(ConstructSpdyBodyFrame(1, true)); |
2861 MockWrite writes[] = { | 2863 MockWrite writes[] = { |
2862 CreateMockWrite(*stream1_syn, 1), | 2864 CreateMockWrite(*stream1_syn, 1), |
2863 }; | 2865 }; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2903 << data.read_count() | 2905 << data.read_count() |
2904 << " Read index: " | 2906 << " Read index: " |
2905 << data.read_index(); | 2907 << data.read_index(); |
2906 EXPECT_TRUE(data.at_write_eof()) << "Write count: " | 2908 EXPECT_TRUE(data.at_write_eof()) << "Write count: " |
2907 << data.write_count() | 2909 << data.write_count() |
2908 << " Write index: " | 2910 << " Write index: " |
2909 << data.write_index(); | 2911 << data.write_index(); |
2910 | 2912 |
2911 // Verify the SYN_REPLY. | 2913 // Verify the SYN_REPLY. |
2912 HttpResponseInfo response = *trans->GetResponseInfo(); | 2914 HttpResponseInfo response = *trans->GetResponseInfo(); |
2913 EXPECT_TRUE(response.headers != NULL); | 2915 EXPECT_TRUE(response.headers.get() != NULL); |
2914 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 2916 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
2915 } | 2917 } |
2916 | 2918 |
2917 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushDuplicate) { | 2919 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushDuplicate) { |
2918 // Verify that we don't leak streams and that we properly send a reset | 2920 // Verify that we don't leak streams and that we properly send a reset |
2919 // if the server pushes the same stream twice. | 2921 // if the server pushes the same stream twice. |
2920 static const unsigned char kPushBodyFrame[] = { | 2922 static const unsigned char kPushBodyFrame[] = { |
2921 0x00, 0x00, 0x00, 0x02, // header, ID | 2923 0x00, 0x00, 0x00, 0x02, // header, ID |
2922 0x01, 0x00, 0x00, 0x06, // FIN, length | 2924 0x01, 0x00, 0x00, 0x06, // FIN, length |
2923 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | 2925 'p', 'u', 's', 'h', 'e', 'd' // "pushed" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2961 HttpResponseInfo response2; | 2963 HttpResponseInfo response2; |
2962 std::string expected_push_result("pushed"); | 2964 std::string expected_push_result("pushed"); |
2963 OrderedSocketData data(reads, arraysize(reads), | 2965 OrderedSocketData data(reads, arraysize(reads), |
2964 writes, arraysize(writes)); | 2966 writes, arraysize(writes)); |
2965 RunServerPushTest(&data, | 2967 RunServerPushTest(&data, |
2966 &response, | 2968 &response, |
2967 &response2, | 2969 &response2, |
2968 expected_push_result); | 2970 expected_push_result); |
2969 | 2971 |
2970 // Verify the SYN_REPLY. | 2972 // Verify the SYN_REPLY. |
2971 EXPECT_TRUE(response.headers != NULL); | 2973 EXPECT_TRUE(response.headers.get() != NULL); |
2972 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 2974 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
2973 | 2975 |
2974 // Verify the pushed stream. | 2976 // Verify the pushed stream. |
2975 EXPECT_TRUE(response2.headers != NULL); | 2977 EXPECT_TRUE(response2.headers.get() != NULL); |
2976 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 2978 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
2977 } | 2979 } |
2978 | 2980 |
2979 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushMultipleDataFrame) { | 2981 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushMultipleDataFrame) { |
2980 static const unsigned char kPushBodyFrame1[] = { | 2982 static const unsigned char kPushBodyFrame1[] = { |
2981 0x00, 0x00, 0x00, 0x02, // header, ID | 2983 0x00, 0x00, 0x00, 0x02, // header, ID |
2982 0x01, 0x00, 0x00, 0x1F, // FIN, length | 2984 0x01, 0x00, 0x00, 0x1F, // FIN, length |
2983 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | 2985 'p', 'u', 's', 'h', 'e', 'd' // "pushed" |
2984 }; | 2986 }; |
2985 static const char kPushBodyFrame2[] = " my darling"; | 2987 static const char kPushBodyFrame2[] = " my darling"; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3020 HttpResponseInfo response2; | 3022 HttpResponseInfo response2; |
3021 std::string expected_push_result("pushed my darling hello my baby"); | 3023 std::string expected_push_result("pushed my darling hello my baby"); |
3022 OrderedSocketData data(reads, arraysize(reads), | 3024 OrderedSocketData data(reads, arraysize(reads), |
3023 writes, arraysize(writes)); | 3025 writes, arraysize(writes)); |
3024 RunServerPushTest(&data, | 3026 RunServerPushTest(&data, |
3025 &response, | 3027 &response, |
3026 &response2, | 3028 &response2, |
3027 expected_push_result); | 3029 expected_push_result); |
3028 | 3030 |
3029 // Verify the SYN_REPLY. | 3031 // Verify the SYN_REPLY. |
3030 EXPECT_TRUE(response.headers != NULL); | 3032 EXPECT_TRUE(response.headers.get() != NULL); |
3031 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3033 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
3032 | 3034 |
3033 // Verify the pushed stream. | 3035 // Verify the pushed stream. |
3034 EXPECT_TRUE(response2.headers != NULL); | 3036 EXPECT_TRUE(response2.headers.get() != NULL); |
3035 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 3037 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
3036 } | 3038 } |
3037 | 3039 |
3038 TEST_P(SpdyNetworkTransactionSpdy2Test, | 3040 TEST_P(SpdyNetworkTransactionSpdy2Test, |
3039 ServerPushMultipleDataFrameInterrupted) { | 3041 ServerPushMultipleDataFrameInterrupted) { |
3040 static const unsigned char kPushBodyFrame1[] = { | 3042 static const unsigned char kPushBodyFrame1[] = { |
3041 0x00, 0x00, 0x00, 0x02, // header, ID | 3043 0x00, 0x00, 0x00, 0x02, // header, ID |
3042 0x01, 0x00, 0x00, 0x1F, // FIN, length | 3044 0x01, 0x00, 0x00, 0x1F, // FIN, length |
3043 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | 3045 'p', 'u', 's', 'h', 'e', 'd' // "pushed" |
3044 }; | 3046 }; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3081 HttpResponseInfo response2; | 3083 HttpResponseInfo response2; |
3082 std::string expected_push_result("pushed my darling hello my baby"); | 3084 std::string expected_push_result("pushed my darling hello my baby"); |
3083 OrderedSocketData data(reads, arraysize(reads), | 3085 OrderedSocketData data(reads, arraysize(reads), |
3084 writes, arraysize(writes)); | 3086 writes, arraysize(writes)); |
3085 RunServerPushTest(&data, | 3087 RunServerPushTest(&data, |
3086 &response, | 3088 &response, |
3087 &response2, | 3089 &response2, |
3088 expected_push_result); | 3090 expected_push_result); |
3089 | 3091 |
3090 // Verify the SYN_REPLY. | 3092 // Verify the SYN_REPLY. |
3091 EXPECT_TRUE(response.headers != NULL); | 3093 EXPECT_TRUE(response.headers.get() != NULL); |
3092 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3094 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
3093 | 3095 |
3094 // Verify the pushed stream. | 3096 // Verify the pushed stream. |
3095 EXPECT_TRUE(response2.headers != NULL); | 3097 EXPECT_TRUE(response2.headers.get() != NULL); |
3096 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 3098 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
3097 } | 3099 } |
3098 | 3100 |
3099 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushInvalidAssociatedStreamID0) { | 3101 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushInvalidAssociatedStreamID0) { |
3100 scoped_ptr<SpdyFrame> stream1_syn( | 3102 scoped_ptr<SpdyFrame> stream1_syn( |
3101 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 3103 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
3102 scoped_ptr<SpdyFrame> stream1_body(ConstructSpdyBodyFrame(1, true)); | 3104 scoped_ptr<SpdyFrame> stream1_body(ConstructSpdyBodyFrame(1, true)); |
3103 scoped_ptr<SpdyFrame> stream2_rst( | 3105 scoped_ptr<SpdyFrame> stream2_rst( |
3104 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_REFUSED_STREAM)); | 3106 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_REFUSED_STREAM)); |
3105 MockWrite writes[] = { | 3107 MockWrite writes[] = { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3145 << data.read_count() | 3147 << data.read_count() |
3146 << " Read index: " | 3148 << " Read index: " |
3147 << data.read_index(); | 3149 << data.read_index(); |
3148 EXPECT_TRUE(data.at_write_eof()) << "Write count: " | 3150 EXPECT_TRUE(data.at_write_eof()) << "Write count: " |
3149 << data.write_count() | 3151 << data.write_count() |
3150 << " Write index: " | 3152 << " Write index: " |
3151 << data.write_index(); | 3153 << data.write_index(); |
3152 | 3154 |
3153 // Verify the SYN_REPLY. | 3155 // Verify the SYN_REPLY. |
3154 HttpResponseInfo response = *trans->GetResponseInfo(); | 3156 HttpResponseInfo response = *trans->GetResponseInfo(); |
3155 EXPECT_TRUE(response.headers != NULL); | 3157 EXPECT_TRUE(response.headers.get() != NULL); |
3156 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3158 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
3157 } | 3159 } |
3158 | 3160 |
3159 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushInvalidAssociatedStreamID9) { | 3161 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushInvalidAssociatedStreamID9) { |
3160 scoped_ptr<SpdyFrame> stream1_syn( | 3162 scoped_ptr<SpdyFrame> stream1_syn( |
3161 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 3163 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
3162 scoped_ptr<SpdyFrame> stream1_body(ConstructSpdyBodyFrame(1, true)); | 3164 scoped_ptr<SpdyFrame> stream1_body(ConstructSpdyBodyFrame(1, true)); |
3163 scoped_ptr<SpdyFrame> stream2_rst( | 3165 scoped_ptr<SpdyFrame> stream2_rst( |
3164 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_INVALID_STREAM)); | 3166 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_INVALID_STREAM)); |
3165 MockWrite writes[] = { | 3167 MockWrite writes[] = { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3205 << data.read_count() | 3207 << data.read_count() |
3206 << " Read index: " | 3208 << " Read index: " |
3207 << data.read_index(); | 3209 << data.read_index(); |
3208 EXPECT_TRUE(data.at_write_eof()) << "Write count: " | 3210 EXPECT_TRUE(data.at_write_eof()) << "Write count: " |
3209 << data.write_count() | 3211 << data.write_count() |
3210 << " Write index: " | 3212 << " Write index: " |
3211 << data.write_index(); | 3213 << data.write_index(); |
3212 | 3214 |
3213 // Verify the SYN_REPLY. | 3215 // Verify the SYN_REPLY. |
3214 HttpResponseInfo response = *trans->GetResponseInfo(); | 3216 HttpResponseInfo response = *trans->GetResponseInfo(); |
3215 EXPECT_TRUE(response.headers != NULL); | 3217 EXPECT_TRUE(response.headers.get() != NULL); |
3216 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3218 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
3217 } | 3219 } |
3218 | 3220 |
3219 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushNoURL) { | 3221 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushNoURL) { |
3220 scoped_ptr<SpdyFrame> stream1_syn( | 3222 scoped_ptr<SpdyFrame> stream1_syn( |
3221 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 3223 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
3222 scoped_ptr<SpdyFrame> stream1_body(ConstructSpdyBodyFrame(1, true)); | 3224 scoped_ptr<SpdyFrame> stream1_body(ConstructSpdyBodyFrame(1, true)); |
3223 scoped_ptr<SpdyFrame> stream2_rst( | 3225 scoped_ptr<SpdyFrame> stream2_rst( |
3224 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_PROTOCOL_ERROR)); | 3226 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_PROTOCOL_ERROR)); |
3225 MockWrite writes[] = { | 3227 MockWrite writes[] = { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3260 << data.read_count() | 3262 << data.read_count() |
3261 << " Read index: " | 3263 << " Read index: " |
3262 << data.read_index(); | 3264 << data.read_index(); |
3263 EXPECT_TRUE(data.at_write_eof()) << "Write count: " | 3265 EXPECT_TRUE(data.at_write_eof()) << "Write count: " |
3264 << data.write_count() | 3266 << data.write_count() |
3265 << " Write index: " | 3267 << " Write index: " |
3266 << data.write_index(); | 3268 << data.write_index(); |
3267 | 3269 |
3268 // Verify the SYN_REPLY. | 3270 // Verify the SYN_REPLY. |
3269 HttpResponseInfo response = *trans->GetResponseInfo(); | 3271 HttpResponseInfo response = *trans->GetResponseInfo(); |
3270 EXPECT_TRUE(response.headers != NULL); | 3272 EXPECT_TRUE(response.headers.get() != NULL); |
3271 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3273 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
3272 } | 3274 } |
3273 | 3275 |
3274 // Verify that various SynReply headers parse correctly through the | 3276 // Verify that various SynReply headers parse correctly through the |
3275 // HTTP layer. | 3277 // HTTP layer. |
3276 TEST_P(SpdyNetworkTransactionSpdy2Test, SynReplyHeaders) { | 3278 TEST_P(SpdyNetworkTransactionSpdy2Test, SynReplyHeaders) { |
3277 struct SynReplyHeadersTests { | 3279 struct SynReplyHeadersTests { |
3278 int num_headers; | 3280 int num_headers; |
3279 const char* extra_headers[5]; | 3281 const char* extra_headers[5]; |
3280 const char* expected_headers; | 3282 const char* expected_headers; |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3840 HttpNetworkTransaction* trans = helper.trans(); | 3842 HttpNetworkTransaction* trans = helper.trans(); |
3841 int rv = trans->Start( | 3843 int rv = trans->Start( |
3842 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 3844 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
3843 EXPECT_EQ(ERR_IO_PENDING, rv); | 3845 EXPECT_EQ(ERR_IO_PENDING, rv); |
3844 | 3846 |
3845 TransactionHelperResult out = helper.output(); | 3847 TransactionHelperResult out = helper.output(); |
3846 out.rv = callback.WaitForResult(); | 3848 out.rv = callback.WaitForResult(); |
3847 EXPECT_EQ(out.rv, OK); | 3849 EXPECT_EQ(out.rv, OK); |
3848 | 3850 |
3849 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3851 const HttpResponseInfo* response = trans->GetResponseInfo(); |
3850 EXPECT_TRUE(response->headers != NULL); | 3852 EXPECT_TRUE(response->headers.get() != NULL); |
3851 EXPECT_TRUE(response->was_fetched_via_spdy); | 3853 EXPECT_TRUE(response->was_fetched_via_spdy); |
3852 out.status_line = response->headers->GetStatusLine(); | 3854 out.status_line = response->headers->GetStatusLine(); |
3853 out.response_info = *response; // Make a copy so we can verify. | 3855 out.response_info = *response; // Make a copy so we can verify. |
3854 | 3856 |
3855 // Read Data | 3857 // Read Data |
3856 TestCompletionCallback read_callback; | 3858 TestCompletionCallback read_callback; |
3857 | 3859 |
3858 std::string content; | 3860 std::string content; |
3859 do { | 3861 do { |
3860 // Read small chunks at a time. | 3862 // Read small chunks at a time. |
3861 const int kSmallReadSize = 3; | 3863 const int kSmallReadSize = 3; |
3862 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSmallReadSize)); | 3864 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSmallReadSize)); |
3863 rv = trans->Read(buf, kSmallReadSize, read_callback.callback()); | 3865 rv = trans->Read(buf.get(), kSmallReadSize, read_callback.callback()); |
3864 if (rv == net::ERR_IO_PENDING) { | 3866 if (rv == net::ERR_IO_PENDING) { |
3865 data.CompleteRead(); | 3867 data.CompleteRead(); |
3866 rv = read_callback.WaitForResult(); | 3868 rv = read_callback.WaitForResult(); |
3867 } | 3869 } |
3868 if (rv > 0) { | 3870 if (rv > 0) { |
3869 content.append(buf->data(), rv); | 3871 content.append(buf->data(), rv); |
3870 } else if (rv < 0) { | 3872 } else if (rv < 0) { |
3871 NOTREACHED(); | 3873 NOTREACHED(); |
3872 } | 3874 } |
3873 } while (rv > 0); | 3875 } while (rv > 0); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3932 TestCompletionCallback callback; | 3934 TestCompletionCallback callback; |
3933 int rv = trans->Start( | 3935 int rv = trans->Start( |
3934 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 3936 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
3935 EXPECT_EQ(ERR_IO_PENDING, rv); | 3937 EXPECT_EQ(ERR_IO_PENDING, rv); |
3936 | 3938 |
3937 TransactionHelperResult out = helper.output(); | 3939 TransactionHelperResult out = helper.output(); |
3938 out.rv = callback.WaitForResult(); | 3940 out.rv = callback.WaitForResult(); |
3939 EXPECT_EQ(out.rv, OK); | 3941 EXPECT_EQ(out.rv, OK); |
3940 | 3942 |
3941 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3943 const HttpResponseInfo* response = trans->GetResponseInfo(); |
3942 EXPECT_TRUE(response->headers != NULL); | 3944 EXPECT_TRUE(response->headers.get() != NULL); |
3943 EXPECT_TRUE(response->was_fetched_via_spdy); | 3945 EXPECT_TRUE(response->was_fetched_via_spdy); |
3944 out.status_line = response->headers->GetStatusLine(); | 3946 out.status_line = response->headers->GetStatusLine(); |
3945 out.response_info = *response; // Make a copy so we can verify. | 3947 out.response_info = *response; // Make a copy so we can verify. |
3946 | 3948 |
3947 // Read Data | 3949 // Read Data |
3948 TestCompletionCallback read_callback; | 3950 TestCompletionCallback read_callback; |
3949 | 3951 |
3950 std::string content; | 3952 std::string content; |
3951 int reads_completed = 0; | 3953 int reads_completed = 0; |
3952 do { | 3954 do { |
3953 // Read small chunks at a time. | 3955 // Read small chunks at a time. |
3954 const int kSmallReadSize = 14; | 3956 const int kSmallReadSize = 14; |
3955 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSmallReadSize)); | 3957 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSmallReadSize)); |
3956 rv = trans->Read(buf, kSmallReadSize, read_callback.callback()); | 3958 rv = trans->Read(buf.get(), kSmallReadSize, read_callback.callback()); |
3957 if (rv == net::ERR_IO_PENDING) { | 3959 if (rv == net::ERR_IO_PENDING) { |
3958 data.CompleteRead(); | 3960 data.CompleteRead(); |
3959 rv = read_callback.WaitForResult(); | 3961 rv = read_callback.WaitForResult(); |
3960 } | 3962 } |
3961 if (rv > 0) { | 3963 if (rv > 0) { |
3962 EXPECT_EQ(kSmallReadSize, rv); | 3964 EXPECT_EQ(kSmallReadSize, rv); |
3963 content.append(buf->data(), rv); | 3965 content.append(buf->data(), rv); |
3964 } else if (rv < 0) { | 3966 } else if (rv < 0) { |
3965 FAIL() << "Unexpected read error: " << rv; | 3967 FAIL() << "Unexpected read error: " << rv; |
3966 } | 3968 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4029 TestCompletionCallback callback; | 4031 TestCompletionCallback callback; |
4030 int rv = trans->Start( | 4032 int rv = trans->Start( |
4031 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 4033 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
4032 EXPECT_EQ(ERR_IO_PENDING, rv); | 4034 EXPECT_EQ(ERR_IO_PENDING, rv); |
4033 | 4035 |
4034 TransactionHelperResult out = helper.output(); | 4036 TransactionHelperResult out = helper.output(); |
4035 out.rv = callback.WaitForResult(); | 4037 out.rv = callback.WaitForResult(); |
4036 EXPECT_EQ(out.rv, OK); | 4038 EXPECT_EQ(out.rv, OK); |
4037 | 4039 |
4038 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4040 const HttpResponseInfo* response = trans->GetResponseInfo(); |
4039 EXPECT_TRUE(response->headers != NULL); | 4041 EXPECT_TRUE(response->headers.get() != NULL); |
4040 EXPECT_TRUE(response->was_fetched_via_spdy); | 4042 EXPECT_TRUE(response->was_fetched_via_spdy); |
4041 out.status_line = response->headers->GetStatusLine(); | 4043 out.status_line = response->headers->GetStatusLine(); |
4042 out.response_info = *response; // Make a copy so we can verify. | 4044 out.response_info = *response; // Make a copy so we can verify. |
4043 | 4045 |
4044 // Read Data | 4046 // Read Data |
4045 TestCompletionCallback read_callback; | 4047 TestCompletionCallback read_callback; |
4046 | 4048 |
4047 std::string content; | 4049 std::string content; |
4048 int reads_completed = 0; | 4050 int reads_completed = 0; |
4049 do { | 4051 do { |
4050 // Read small chunks at a time. | 4052 // Read small chunks at a time. |
4051 const int kSmallReadSize = 14; | 4053 const int kSmallReadSize = 14; |
4052 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSmallReadSize)); | 4054 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSmallReadSize)); |
4053 rv = trans->Read(buf, kSmallReadSize, read_callback.callback()); | 4055 rv = trans->Read(buf.get(), kSmallReadSize, read_callback.callback()); |
4054 if (rv > 0) { | 4056 if (rv > 0) { |
4055 EXPECT_EQ(kSmallReadSize, rv); | 4057 EXPECT_EQ(kSmallReadSize, rv); |
4056 content.append(buf->data(), rv); | 4058 content.append(buf->data(), rv); |
4057 } else if (rv < 0) { | 4059 } else if (rv < 0) { |
4058 FAIL() << "Unexpected read error: " << rv; | 4060 FAIL() << "Unexpected read error: " << rv; |
4059 } | 4061 } |
4060 reads_completed++; | 4062 reads_completed++; |
4061 } while (rv > 0); | 4063 } while (rv > 0); |
4062 | 4064 |
4063 EXPECT_EQ(3, reads_completed); | 4065 EXPECT_EQ(3, reads_completed); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4119 | 4121 |
4120 int rv = trans->Start( | 4122 int rv = trans->Start( |
4121 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 4123 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
4122 EXPECT_EQ(ERR_IO_PENDING, rv); | 4124 EXPECT_EQ(ERR_IO_PENDING, rv); |
4123 | 4125 |
4124 TransactionHelperResult out = helper.output(); | 4126 TransactionHelperResult out = helper.output(); |
4125 out.rv = callback.WaitForResult(); | 4127 out.rv = callback.WaitForResult(); |
4126 EXPECT_EQ(out.rv, OK); | 4128 EXPECT_EQ(out.rv, OK); |
4127 | 4129 |
4128 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4130 const HttpResponseInfo* response = trans->GetResponseInfo(); |
4129 EXPECT_TRUE(response->headers != NULL); | 4131 EXPECT_TRUE(response->headers.get() != NULL); |
4130 EXPECT_TRUE(response->was_fetched_via_spdy); | 4132 EXPECT_TRUE(response->was_fetched_via_spdy); |
4131 out.status_line = response->headers->GetStatusLine(); | 4133 out.status_line = response->headers->GetStatusLine(); |
4132 out.response_info = *response; // Make a copy so we can verify. | 4134 out.response_info = *response; // Make a copy so we can verify. |
4133 | 4135 |
4134 // Read Data | 4136 // Read Data |
4135 TestCompletionCallback read_callback; | 4137 TestCompletionCallback read_callback; |
4136 | 4138 |
4137 std::string content; | 4139 std::string content; |
4138 int reads_completed = 0; | 4140 int reads_completed = 0; |
4139 do { | 4141 do { |
4140 // Read small chunks at a time. | 4142 // Read small chunks at a time. |
4141 const int kSmallReadSize = 14; | 4143 const int kSmallReadSize = 14; |
4142 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSmallReadSize)); | 4144 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSmallReadSize)); |
4143 rv = trans->Read(buf, kSmallReadSize, read_callback.callback()); | 4145 rv = trans->Read(buf.get(), kSmallReadSize, read_callback.callback()); |
4144 if (rv == net::ERR_IO_PENDING) { | 4146 if (rv == net::ERR_IO_PENDING) { |
4145 data.CompleteRead(); | 4147 data.CompleteRead(); |
4146 rv = read_callback.WaitForResult(); | 4148 rv = read_callback.WaitForResult(); |
4147 } | 4149 } |
4148 if (rv > 0) { | 4150 if (rv > 0) { |
4149 content.append(buf->data(), rv); | 4151 content.append(buf->data(), rv); |
4150 } else if (rv < 0) { | 4152 } else if (rv < 0) { |
4151 // This test intentionally closes the connection, and will get an error. | 4153 // This test intentionally closes the connection, and will get an error. |
4152 EXPECT_EQ(ERR_CONNECTION_CLOSED, rv); | 4154 EXPECT_EQ(ERR_CONNECTION_CLOSED, rv); |
4153 break; | 4155 break; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4199 | 4201 |
4200 int rv = trans->Start( | 4202 int rv = trans->Start( |
4201 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 4203 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
4202 EXPECT_EQ(ERR_IO_PENDING, rv); | 4204 EXPECT_EQ(ERR_IO_PENDING, rv); |
4203 | 4205 |
4204 TransactionHelperResult out = helper.output(); | 4206 TransactionHelperResult out = helper.output(); |
4205 out.rv = callback.WaitForResult(); | 4207 out.rv = callback.WaitForResult(); |
4206 EXPECT_EQ(out.rv, OK); | 4208 EXPECT_EQ(out.rv, OK); |
4207 | 4209 |
4208 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4210 const HttpResponseInfo* response = trans->GetResponseInfo(); |
4209 EXPECT_TRUE(response->headers != NULL); | 4211 EXPECT_TRUE(response->headers.get() != NULL); |
4210 EXPECT_TRUE(response->was_fetched_via_spdy); | 4212 EXPECT_TRUE(response->was_fetched_via_spdy); |
4211 out.status_line = response->headers->GetStatusLine(); | 4213 out.status_line = response->headers->GetStatusLine(); |
4212 out.response_info = *response; // Make a copy so we can verify. | 4214 out.response_info = *response; // Make a copy so we can verify. |
4213 | 4215 |
4214 // Read Data | 4216 // Read Data |
4215 TestCompletionCallback read_callback; | 4217 TestCompletionCallback read_callback; |
4216 | 4218 |
4217 do { | 4219 do { |
4218 const int kReadSize = 256; | 4220 const int kReadSize = 256; |
4219 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kReadSize)); | 4221 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kReadSize)); |
4220 rv = trans->Read(buf, kReadSize, read_callback.callback()); | 4222 rv = trans->Read(buf.get(), kReadSize, read_callback.callback()); |
4221 if (rv == net::ERR_IO_PENDING) { | 4223 if (rv == net::ERR_IO_PENDING) { |
4222 // Complete the read now, which causes buffering to start. | 4224 // Complete the read now, which causes buffering to start. |
4223 data.CompleteRead(); | 4225 data.CompleteRead(); |
4224 // Destroy the transaction, causing the stream to get cancelled | 4226 // Destroy the transaction, causing the stream to get cancelled |
4225 // and orphaning the buffered IO task. | 4227 // and orphaning the buffered IO task. |
4226 helper.ResetTrans(); | 4228 helper.ResetTrans(); |
4227 break; | 4229 break; |
4228 } | 4230 } |
4229 // We shouldn't get here in this test. | 4231 // We shouldn't get here in this test. |
4230 FAIL() << "Unexpected read: " << rv; | 4232 FAIL() << "Unexpected read: " << rv; |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4507 | 4509 |
4508 TestCompletionCallback callback; | 4510 TestCompletionCallback callback; |
4509 TransactionHelperResult out; | 4511 TransactionHelperResult out; |
4510 out.rv = trans->Start(&CreateGetRequest(), callback.callback(), log); | 4512 out.rv = trans->Start(&CreateGetRequest(), callback.callback(), log); |
4511 | 4513 |
4512 EXPECT_EQ(out.rv, ERR_IO_PENDING); | 4514 EXPECT_EQ(out.rv, ERR_IO_PENDING); |
4513 out.rv = callback.WaitForResult(); | 4515 out.rv = callback.WaitForResult(); |
4514 EXPECT_EQ(out.rv, OK); | 4516 EXPECT_EQ(out.rv, OK); |
4515 | 4517 |
4516 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4518 const HttpResponseInfo* response = trans->GetResponseInfo(); |
4517 EXPECT_TRUE(response->headers != NULL); | 4519 EXPECT_TRUE(response->headers.get() != NULL); |
4518 EXPECT_TRUE(response->was_fetched_via_spdy); | 4520 EXPECT_TRUE(response->was_fetched_via_spdy); |
4519 out.rv = ReadTransaction(trans, &out.response_data); | 4521 out.rv = ReadTransaction(trans, &out.response_data); |
4520 EXPECT_EQ(ERR_CONNECTION_CLOSED, out.rv); | 4522 EXPECT_EQ(ERR_CONNECTION_CLOSED, out.rv); |
4521 | 4523 |
4522 // Verify that we consumed all test data. | 4524 // Verify that we consumed all test data. |
4523 helper.VerifyDataConsumed(); | 4525 helper.VerifyDataConsumed(); |
4524 } | 4526 } |
4525 | 4527 |
4526 // Test to make sure we can correctly connect through a proxy. | 4528 // Test to make sure we can correctly connect through a proxy. |
4527 TEST_P(SpdyNetworkTransactionSpdy2Test, ProxyConnect) { | 4529 TEST_P(SpdyNetworkTransactionSpdy2Test, ProxyConnect) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4607 | 4609 |
4608 int rv = trans->Start( | 4610 int rv = trans->Start( |
4609 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 4611 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
4610 EXPECT_EQ(ERR_IO_PENDING, rv); | 4612 EXPECT_EQ(ERR_IO_PENDING, rv); |
4611 | 4613 |
4612 rv = callback.WaitForResult(); | 4614 rv = callback.WaitForResult(); |
4613 EXPECT_EQ(0, rv); | 4615 EXPECT_EQ(0, rv); |
4614 | 4616 |
4615 // Verify the SYN_REPLY. | 4617 // Verify the SYN_REPLY. |
4616 HttpResponseInfo response = *trans->GetResponseInfo(); | 4618 HttpResponseInfo response = *trans->GetResponseInfo(); |
4617 EXPECT_TRUE(response.headers != NULL); | 4619 EXPECT_TRUE(response.headers.get() != NULL); |
4618 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 4620 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
4619 | 4621 |
4620 std::string response_data; | 4622 std::string response_data; |
4621 ASSERT_EQ(OK, ReadTransaction(trans, &response_data)); | 4623 ASSERT_EQ(OK, ReadTransaction(trans, &response_data)); |
4622 EXPECT_EQ("hello!", response_data); | 4624 EXPECT_EQ("hello!", response_data); |
4623 helper.VerifyDataConsumed(); | 4625 helper.VerifyDataConsumed(); |
4624 } | 4626 } |
4625 | 4627 |
4626 // Test to make sure we can correctly connect through a proxy to www.google.com, | 4628 // Test to make sure we can correctly connect through a proxy to www.google.com, |
4627 // if there already exists a direct spdy connection to www.google.com. See | 4629 // if there already exists a direct spdy connection to www.google.com. See |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4665 TestCompletionCallback callback; | 4667 TestCompletionCallback callback; |
4666 TransactionHelperResult out; | 4668 TransactionHelperResult out; |
4667 out.rv = trans->Start( | 4669 out.rv = trans->Start( |
4668 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 4670 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
4669 | 4671 |
4670 EXPECT_EQ(out.rv, ERR_IO_PENDING); | 4672 EXPECT_EQ(out.rv, ERR_IO_PENDING); |
4671 out.rv = callback.WaitForResult(); | 4673 out.rv = callback.WaitForResult(); |
4672 EXPECT_EQ(out.rv, OK); | 4674 EXPECT_EQ(out.rv, OK); |
4673 | 4675 |
4674 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4676 const HttpResponseInfo* response = trans->GetResponseInfo(); |
4675 EXPECT_TRUE(response->headers != NULL); | 4677 EXPECT_TRUE(response->headers.get() != NULL); |
4676 EXPECT_TRUE(response->was_fetched_via_spdy); | 4678 EXPECT_TRUE(response->was_fetched_via_spdy); |
4677 out.rv = ReadTransaction(trans, &out.response_data); | 4679 out.rv = ReadTransaction(trans, &out.response_data); |
4678 EXPECT_EQ(OK, out.rv); | 4680 EXPECT_EQ(OK, out.rv); |
4679 out.status_line = response->headers->GetStatusLine(); | 4681 out.status_line = response->headers->GetStatusLine(); |
4680 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 4682 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
4681 EXPECT_EQ("hello!", out.response_data); | 4683 EXPECT_EQ("hello!", out.response_data); |
4682 | 4684 |
4683 // Check that the SpdySession is still in the SpdySessionPool. | 4685 // Check that the SpdySession is still in the SpdySessionPool. |
4684 HostPortPair host_port_pair("www.google.com", helper.port()); | 4686 HostPortPair host_port_pair("www.google.com", helper.port()); |
4685 SpdySessionKey session_pool_key_direct( | 4687 SpdySessionKey session_pool_key_direct( |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4782 | 4784 |
4783 HttpNetworkTransaction* trans_proxy = helper_proxy.trans(); | 4785 HttpNetworkTransaction* trans_proxy = helper_proxy.trans(); |
4784 TestCompletionCallback callback_proxy; | 4786 TestCompletionCallback callback_proxy; |
4785 int rv = trans_proxy->Start( | 4787 int rv = trans_proxy->Start( |
4786 &request_proxy, callback_proxy.callback(), BoundNetLog()); | 4788 &request_proxy, callback_proxy.callback(), BoundNetLog()); |
4787 EXPECT_EQ(ERR_IO_PENDING, rv); | 4789 EXPECT_EQ(ERR_IO_PENDING, rv); |
4788 rv = callback_proxy.WaitForResult(); | 4790 rv = callback_proxy.WaitForResult(); |
4789 EXPECT_EQ(0, rv); | 4791 EXPECT_EQ(0, rv); |
4790 | 4792 |
4791 HttpResponseInfo response_proxy = *trans_proxy->GetResponseInfo(); | 4793 HttpResponseInfo response_proxy = *trans_proxy->GetResponseInfo(); |
4792 EXPECT_TRUE(response_proxy.headers != NULL); | 4794 EXPECT_TRUE(response_proxy.headers.get() != NULL); |
4793 EXPECT_EQ("HTTP/1.1 200 OK", response_proxy.headers->GetStatusLine()); | 4795 EXPECT_EQ("HTTP/1.1 200 OK", response_proxy.headers->GetStatusLine()); |
4794 | 4796 |
4795 std::string response_data; | 4797 std::string response_data; |
4796 ASSERT_EQ(OK, ReadTransaction(trans_proxy, &response_data)); | 4798 ASSERT_EQ(OK, ReadTransaction(trans_proxy, &response_data)); |
4797 EXPECT_EQ("hello!", response_data); | 4799 EXPECT_EQ("hello!", response_data); |
4798 | 4800 |
4799 data.CompleteRead(); | 4801 data.CompleteRead(); |
4800 helper_proxy.VerifyDataConsumed(); | 4802 helper_proxy.VerifyDataConsumed(); |
4801 } | 4803 } |
4802 | 4804 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4837 DelayedSocketData data2(1, reads2, arraysize(reads2), NULL, 0); | 4839 DelayedSocketData data2(1, reads2, arraysize(reads2), NULL, 0); |
4838 | 4840 |
4839 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 4841 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
4840 BoundNetLog(), GetParam(), NULL); | 4842 BoundNetLog(), GetParam(), NULL); |
4841 helper.AddData(&data1); | 4843 helper.AddData(&data1); |
4842 helper.AddData(&data2); | 4844 helper.AddData(&data2); |
4843 helper.RunPreTestSetup(); | 4845 helper.RunPreTestSetup(); |
4844 | 4846 |
4845 for (int i = 0; i < 2; ++i) { | 4847 for (int i = 0; i < 2; ++i) { |
4846 scoped_ptr<HttpNetworkTransaction> trans( | 4848 scoped_ptr<HttpNetworkTransaction> trans( |
4847 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 4849 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
4848 | 4850 |
4849 TestCompletionCallback callback; | 4851 TestCompletionCallback callback; |
4850 int rv = trans->Start( | 4852 int rv = trans->Start( |
4851 &helper.request(), callback.callback(), BoundNetLog()); | 4853 &helper.request(), callback.callback(), BoundNetLog()); |
4852 EXPECT_EQ(ERR_IO_PENDING, rv); | 4854 EXPECT_EQ(ERR_IO_PENDING, rv); |
4853 // On the second transaction, we trigger the RST. | 4855 // On the second transaction, we trigger the RST. |
4854 if (i == 1) { | 4856 if (i == 1) { |
4855 if (variant == VARIANT_RST_DURING_READ_COMPLETION) { | 4857 if (variant == VARIANT_RST_DURING_READ_COMPLETION) { |
4856 // Writes to the socket complete asynchronously on SPDY by running | 4858 // Writes to the socket complete asynchronously on SPDY by running |
4857 // through the message loop. Complete the write here. | 4859 // through the message loop. Complete the write here. |
4858 base::MessageLoop::current()->RunUntilIdle(); | 4860 base::MessageLoop::current()->RunUntilIdle(); |
4859 } | 4861 } |
4860 | 4862 |
4861 // Now schedule the ERR_CONNECTION_RESET. | 4863 // Now schedule the ERR_CONNECTION_RESET. |
4862 EXPECT_EQ(3u, data1.read_index()); | 4864 EXPECT_EQ(3u, data1.read_index()); |
4863 data1.CompleteRead(); | 4865 data1.CompleteRead(); |
4864 EXPECT_EQ(4u, data1.read_index()); | 4866 EXPECT_EQ(4u, data1.read_index()); |
4865 } | 4867 } |
4866 rv = callback.WaitForResult(); | 4868 rv = callback.WaitForResult(); |
4867 EXPECT_EQ(OK, rv); | 4869 EXPECT_EQ(OK, rv); |
4868 | 4870 |
4869 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4871 const HttpResponseInfo* response = trans->GetResponseInfo(); |
4870 ASSERT_TRUE(response != NULL); | 4872 ASSERT_TRUE(response != NULL); |
4871 EXPECT_TRUE(response->headers != NULL); | 4873 EXPECT_TRUE(response->headers.get() != NULL); |
4872 EXPECT_TRUE(response->was_fetched_via_spdy); | 4874 EXPECT_TRUE(response->was_fetched_via_spdy); |
4873 std::string response_data; | 4875 std::string response_data; |
4874 rv = ReadTransaction(trans.get(), &response_data); | 4876 rv = ReadTransaction(trans.get(), &response_data); |
4875 EXPECT_EQ(OK, rv); | 4877 EXPECT_EQ(OK, rv); |
4876 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 4878 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
4877 EXPECT_EQ("hello!", response_data); | 4879 EXPECT_EQ("hello!", response_data); |
4878 } | 4880 } |
4879 | 4881 |
4880 helper.VerifyDataConsumed(); | 4882 helper.VerifyDataConsumed(); |
4881 } | 4883 } |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4982 HttpNetworkTransaction* trans = helper.trans(); | 4984 HttpNetworkTransaction* trans = helper.trans(); |
4983 TestCompletionCallback callback; | 4985 TestCompletionCallback callback; |
4984 const int rv_start = trans->Start(&request, callback.callback(), net_log); | 4986 const int rv_start = trans->Start(&request, callback.callback(), net_log); |
4985 EXPECT_EQ(ERR_IO_PENDING, rv_start); | 4987 EXPECT_EQ(ERR_IO_PENDING, rv_start); |
4986 const int rv_start_complete = callback.WaitForResult(); | 4988 const int rv_start_complete = callback.WaitForResult(); |
4987 EXPECT_EQ(OK, rv_start_complete); | 4989 EXPECT_EQ(OK, rv_start_complete); |
4988 | 4990 |
4989 // Make sure the response has an auth challenge. | 4991 // Make sure the response has an auth challenge. |
4990 const HttpResponseInfo* const response_start = trans->GetResponseInfo(); | 4992 const HttpResponseInfo* const response_start = trans->GetResponseInfo(); |
4991 ASSERT_TRUE(response_start != NULL); | 4993 ASSERT_TRUE(response_start != NULL); |
4992 ASSERT_TRUE(response_start->headers != NULL); | 4994 ASSERT_TRUE(response_start->headers.get() != NULL); |
4993 EXPECT_EQ(401, response_start->headers->response_code()); | 4995 EXPECT_EQ(401, response_start->headers->response_code()); |
4994 EXPECT_TRUE(response_start->was_fetched_via_spdy); | 4996 EXPECT_TRUE(response_start->was_fetched_via_spdy); |
4995 AuthChallengeInfo* auth_challenge = response_start->auth_challenge.get(); | 4997 AuthChallengeInfo* auth_challenge = response_start->auth_challenge.get(); |
4996 ASSERT_TRUE(auth_challenge != NULL); | 4998 ASSERT_TRUE(auth_challenge != NULL); |
4997 EXPECT_FALSE(auth_challenge->is_proxy); | 4999 EXPECT_FALSE(auth_challenge->is_proxy); |
4998 EXPECT_EQ("basic", auth_challenge->scheme); | 5000 EXPECT_EQ("basic", auth_challenge->scheme); |
4999 EXPECT_EQ("MyRealm", auth_challenge->realm); | 5001 EXPECT_EQ("MyRealm", auth_challenge->realm); |
5000 | 5002 |
5001 // Restart with a username/password. | 5003 // Restart with a username/password. |
5002 AuthCredentials credentials(ASCIIToUTF16("foo"), ASCIIToUTF16("bar")); | 5004 AuthCredentials credentials(ASCIIToUTF16("foo"), ASCIIToUTF16("bar")); |
5003 TestCompletionCallback callback_restart; | 5005 TestCompletionCallback callback_restart; |
5004 const int rv_restart = trans->RestartWithAuth( | 5006 const int rv_restart = trans->RestartWithAuth( |
5005 credentials, callback_restart.callback()); | 5007 credentials, callback_restart.callback()); |
5006 EXPECT_EQ(ERR_IO_PENDING, rv_restart); | 5008 EXPECT_EQ(ERR_IO_PENDING, rv_restart); |
5007 const int rv_restart_complete = callback_restart.WaitForResult(); | 5009 const int rv_restart_complete = callback_restart.WaitForResult(); |
5008 EXPECT_EQ(OK, rv_restart_complete); | 5010 EXPECT_EQ(OK, rv_restart_complete); |
5009 // TODO(cbentzel): This is actually the same response object as before, but | 5011 // TODO(cbentzel): This is actually the same response object as before, but |
5010 // data has changed. | 5012 // data has changed. |
5011 const HttpResponseInfo* const response_restart = trans->GetResponseInfo(); | 5013 const HttpResponseInfo* const response_restart = trans->GetResponseInfo(); |
5012 ASSERT_TRUE(response_restart != NULL); | 5014 ASSERT_TRUE(response_restart != NULL); |
5013 ASSERT_TRUE(response_restart->headers != NULL); | 5015 ASSERT_TRUE(response_restart->headers.get() != NULL); |
5014 EXPECT_EQ(200, response_restart->headers->response_code()); | 5016 EXPECT_EQ(200, response_restart->headers->response_code()); |
5015 EXPECT_TRUE(response_restart->auth_challenge.get() == NULL); | 5017 EXPECT_TRUE(response_restart->auth_challenge.get() == NULL); |
5016 } | 5018 } |
5017 | 5019 |
5018 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushWithHeaders) { | 5020 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushWithHeaders) { |
5019 static const unsigned char kPushBodyFrame[] = { | 5021 static const unsigned char kPushBodyFrame[] = { |
5020 0x00, 0x00, 0x00, 0x02, // header, ID | 5022 0x00, 0x00, 0x00, 0x02, // header, ID |
5021 0x01, 0x00, 0x00, 0x06, // FIN, length | 5023 0x01, 0x00, 0x00, 0x06, // FIN, length |
5022 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | 5024 'p', 'u', 's', 'h', 'e', 'd' // "pushed" |
5023 }; | 5025 }; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5079 HttpResponseInfo response2; | 5081 HttpResponseInfo response2; |
5080 std::string expected_push_result("pushed"); | 5082 std::string expected_push_result("pushed"); |
5081 OrderedSocketData data(reads, arraysize(reads), | 5083 OrderedSocketData data(reads, arraysize(reads), |
5082 writes, arraysize(writes)); | 5084 writes, arraysize(writes)); |
5083 RunServerPushTest(&data, | 5085 RunServerPushTest(&data, |
5084 &response, | 5086 &response, |
5085 &response2, | 5087 &response2, |
5086 expected_push_result); | 5088 expected_push_result); |
5087 | 5089 |
5088 // Verify the SYN_REPLY. | 5090 // Verify the SYN_REPLY. |
5089 EXPECT_TRUE(response.headers != NULL); | 5091 EXPECT_TRUE(response.headers.get() != NULL); |
5090 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5092 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
5091 | 5093 |
5092 // Verify the pushed stream. | 5094 // Verify the pushed stream. |
5093 EXPECT_TRUE(response2.headers != NULL); | 5095 EXPECT_TRUE(response2.headers.get() != NULL); |
5094 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 5096 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
5095 } | 5097 } |
5096 | 5098 |
5097 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushClaimBeforeHeaders) { | 5099 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushClaimBeforeHeaders) { |
5098 // We push a stream and attempt to claim it before the headers come down. | 5100 // We push a stream and attempt to claim it before the headers come down. |
5099 static const unsigned char kPushBodyFrame[] = { | 5101 static const unsigned char kPushBodyFrame[] = { |
5100 0x00, 0x00, 0x00, 0x02, // header, ID | 5102 0x00, 0x00, 0x00, 0x02, // header, ID |
5101 0x01, 0x00, 0x00, 0x06, // FIN, length | 5103 0x01, 0x00, 0x00, 0x06, // FIN, length |
5102 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | 5104 'p', 'u', 's', 'h', 'e', 'd' // "pushed" |
5103 }; | 5105 }; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5179 int rv = trans->Start( | 5181 int rv = trans->Start( |
5180 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 5182 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
5181 EXPECT_EQ(ERR_IO_PENDING, rv); | 5183 EXPECT_EQ(ERR_IO_PENDING, rv); |
5182 data.Run(); | 5184 data.Run(); |
5183 rv = callback.WaitForResult(); | 5185 rv = callback.WaitForResult(); |
5184 EXPECT_EQ(0, rv); | 5186 EXPECT_EQ(0, rv); |
5185 | 5187 |
5186 // Request the pushed path. At this point, we've received the push, but the | 5188 // Request the pushed path. At this point, we've received the push, but the |
5187 // headers are not yet complete. | 5189 // headers are not yet complete. |
5188 scoped_ptr<HttpNetworkTransaction> trans2( | 5190 scoped_ptr<HttpNetworkTransaction> trans2( |
5189 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 5191 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
5190 rv = trans2->Start( | 5192 rv = trans2->Start( |
5191 &CreateGetPushRequest(), callback.callback(), BoundNetLog()); | 5193 &CreateGetPushRequest(), callback.callback(), BoundNetLog()); |
5192 EXPECT_EQ(ERR_IO_PENDING, rv); | 5194 EXPECT_EQ(ERR_IO_PENDING, rv); |
5193 data.RunFor(3); | 5195 data.RunFor(3); |
5194 base::MessageLoop::current()->RunUntilIdle(); | 5196 base::MessageLoop::current()->RunUntilIdle(); |
5195 | 5197 |
5196 // Read the server push body. | 5198 // Read the server push body. |
5197 std::string result2; | 5199 std::string result2; |
5198 ReadResult(trans2.get(), &data, &result2); | 5200 ReadResult(trans2.get(), &data, &result2); |
5199 // Read the response body. | 5201 // Read the response body. |
5200 std::string result; | 5202 std::string result; |
5201 ReadResult(trans, &data, &result); | 5203 ReadResult(trans, &data, &result); |
5202 | 5204 |
5203 // Verify that the received push data is same as the expected push data. | 5205 // Verify that the received push data is same as the expected push data. |
5204 EXPECT_EQ(result2.compare(expected_push_result), 0) | 5206 EXPECT_EQ(result2.compare(expected_push_result), 0) |
5205 << "Received data: " | 5207 << "Received data: " |
5206 << result2 | 5208 << result2 |
5207 << "||||| Expected data: " | 5209 << "||||| Expected data: " |
5208 << expected_push_result; | 5210 << expected_push_result; |
5209 | 5211 |
5210 // Verify the SYN_REPLY. | 5212 // Verify the SYN_REPLY. |
5211 // Copy the response info, because trans goes away. | 5213 // Copy the response info, because trans goes away. |
5212 response = *trans->GetResponseInfo(); | 5214 response = *trans->GetResponseInfo(); |
5213 response2 = *trans2->GetResponseInfo(); | 5215 response2 = *trans2->GetResponseInfo(); |
5214 | 5216 |
5215 VerifyStreamsClosed(helper); | 5217 VerifyStreamsClosed(helper); |
5216 | 5218 |
5217 // Verify the SYN_REPLY. | 5219 // Verify the SYN_REPLY. |
5218 EXPECT_TRUE(response.headers != NULL); | 5220 EXPECT_TRUE(response.headers.get() != NULL); |
5219 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5221 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
5220 | 5222 |
5221 // Verify the pushed stream. | 5223 // Verify the pushed stream. |
5222 EXPECT_TRUE(response2.headers != NULL); | 5224 EXPECT_TRUE(response2.headers.get() != NULL); |
5223 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 5225 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
5224 | 5226 |
5225 // Read the final EOF (which will close the session) | 5227 // Read the final EOF (which will close the session) |
5226 data.RunFor(1); | 5228 data.RunFor(1); |
5227 | 5229 |
5228 // Verify that we consumed all test data. | 5230 // Verify that we consumed all test data. |
5229 EXPECT_TRUE(data.at_read_eof()); | 5231 EXPECT_TRUE(data.at_read_eof()); |
5230 EXPECT_TRUE(data.at_write_eof()); | 5232 EXPECT_TRUE(data.at_write_eof()); |
5231 } | 5233 } |
5232 | 5234 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5329 int rv = trans->Start( | 5331 int rv = trans->Start( |
5330 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 5332 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
5331 EXPECT_EQ(ERR_IO_PENDING, rv); | 5333 EXPECT_EQ(ERR_IO_PENDING, rv); |
5332 data.Run(); | 5334 data.Run(); |
5333 rv = callback.WaitForResult(); | 5335 rv = callback.WaitForResult(); |
5334 EXPECT_EQ(0, rv); | 5336 EXPECT_EQ(0, rv); |
5335 | 5337 |
5336 // Request the pushed path. At this point, we've received the push, but the | 5338 // Request the pushed path. At this point, we've received the push, but the |
5337 // headers are not yet complete. | 5339 // headers are not yet complete. |
5338 scoped_ptr<HttpNetworkTransaction> trans2( | 5340 scoped_ptr<HttpNetworkTransaction> trans2( |
5339 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 5341 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
5340 rv = trans2->Start( | 5342 rv = trans2->Start( |
5341 &CreateGetPushRequest(), callback.callback(), BoundNetLog()); | 5343 &CreateGetPushRequest(), callback.callback(), BoundNetLog()); |
5342 EXPECT_EQ(ERR_IO_PENDING, rv); | 5344 EXPECT_EQ(ERR_IO_PENDING, rv); |
5343 data.RunFor(3); | 5345 data.RunFor(3); |
5344 base::MessageLoop::current()->RunUntilIdle(); | 5346 base::MessageLoop::current()->RunUntilIdle(); |
5345 | 5347 |
5346 // Read the server push body. | 5348 // Read the server push body. |
5347 std::string result2; | 5349 std::string result2; |
5348 ReadResult(trans2.get(), &data, &result2); | 5350 ReadResult(trans2.get(), &data, &result2); |
5349 // Read the response body. | 5351 // Read the response body. |
5350 std::string result; | 5352 std::string result; |
5351 ReadResult(trans, &data, &result); | 5353 ReadResult(trans, &data, &result); |
5352 | 5354 |
5353 // Verify that the received push data is same as the expected push data. | 5355 // Verify that the received push data is same as the expected push data. |
5354 EXPECT_EQ(result2.compare(expected_push_result), 0) | 5356 EXPECT_EQ(result2.compare(expected_push_result), 0) |
5355 << "Received data: " | 5357 << "Received data: " |
5356 << result2 | 5358 << result2 |
5357 << "||||| Expected data: " | 5359 << "||||| Expected data: " |
5358 << expected_push_result; | 5360 << expected_push_result; |
5359 | 5361 |
5360 // Verify the SYN_REPLY. | 5362 // Verify the SYN_REPLY. |
5361 // Copy the response info, because trans goes away. | 5363 // Copy the response info, because trans goes away. |
5362 response = *trans->GetResponseInfo(); | 5364 response = *trans->GetResponseInfo(); |
5363 response2 = *trans2->GetResponseInfo(); | 5365 response2 = *trans2->GetResponseInfo(); |
5364 | 5366 |
5365 VerifyStreamsClosed(helper); | 5367 VerifyStreamsClosed(helper); |
5366 | 5368 |
5367 // Verify the SYN_REPLY. | 5369 // Verify the SYN_REPLY. |
5368 EXPECT_TRUE(response.headers != NULL); | 5370 EXPECT_TRUE(response.headers.get() != NULL); |
5369 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5371 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
5370 | 5372 |
5371 // Verify the pushed stream. | 5373 // Verify the pushed stream. |
5372 EXPECT_TRUE(response2.headers != NULL); | 5374 EXPECT_TRUE(response2.headers.get() != NULL); |
5373 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 5375 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
5374 | 5376 |
5375 // Verify we got all the headers | 5377 // Verify we got all the headers |
5376 EXPECT_TRUE(response2.headers->HasHeaderValue( | 5378 EXPECT_TRUE(response2.headers->HasHeaderValue( |
5377 "url", | 5379 "url", |
5378 "http://www.google.com/foo.dat")); | 5380 "http://www.google.com/foo.dat")); |
5379 EXPECT_TRUE(response2.headers->HasHeaderValue("hello", "bye")); | 5381 EXPECT_TRUE(response2.headers->HasHeaderValue("hello", "bye")); |
5380 EXPECT_TRUE(response2.headers->HasHeaderValue("status", "200")); | 5382 EXPECT_TRUE(response2.headers->HasHeaderValue("status", "200")); |
5381 EXPECT_TRUE(response2.headers->HasHeaderValue("version", "HTTP/1.1")); | 5383 EXPECT_TRUE(response2.headers->HasHeaderValue("version", "HTTP/1.1")); |
5382 | 5384 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5466 int rv = trans->Start( | 5468 int rv = trans->Start( |
5467 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 5469 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
5468 EXPECT_EQ(ERR_IO_PENDING, rv); | 5470 EXPECT_EQ(ERR_IO_PENDING, rv); |
5469 data.Run(); | 5471 data.Run(); |
5470 rv = callback.WaitForResult(); | 5472 rv = callback.WaitForResult(); |
5471 EXPECT_EQ(0, rv); | 5473 EXPECT_EQ(0, rv); |
5472 | 5474 |
5473 // Request the pushed path. At this point, we've received the push, but the | 5475 // Request the pushed path. At this point, we've received the push, but the |
5474 // headers are not yet complete. | 5476 // headers are not yet complete. |
5475 scoped_ptr<HttpNetworkTransaction> trans2( | 5477 scoped_ptr<HttpNetworkTransaction> trans2( |
5476 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 5478 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
5477 rv = trans2->Start( | 5479 rv = trans2->Start( |
5478 &CreateGetPushRequest(), callback.callback(), BoundNetLog()); | 5480 &CreateGetPushRequest(), callback.callback(), BoundNetLog()); |
5479 EXPECT_EQ(ERR_IO_PENDING, rv); | 5481 EXPECT_EQ(ERR_IO_PENDING, rv); |
5480 data.RunFor(2); | 5482 data.RunFor(2); |
5481 base::MessageLoop::current()->RunUntilIdle(); | 5483 base::MessageLoop::current()->RunUntilIdle(); |
5482 | 5484 |
5483 // Read the server push body. | 5485 // Read the server push body. |
5484 std::string result2; | 5486 std::string result2; |
5485 ReadResult(trans2.get(), &data, &result2); | 5487 ReadResult(trans2.get(), &data, &result2); |
5486 // Read the response body. | 5488 // Read the response body. |
5487 std::string result; | 5489 std::string result; |
5488 ReadResult(trans, &data, &result); | 5490 ReadResult(trans, &data, &result); |
5489 EXPECT_EQ("hello!", result); | 5491 EXPECT_EQ("hello!", result); |
5490 | 5492 |
5491 // Verify that we haven't received any push data. | 5493 // Verify that we haven't received any push data. |
5492 EXPECT_EQ("", result2); | 5494 EXPECT_EQ("", result2); |
5493 | 5495 |
5494 // Verify the SYN_REPLY. | 5496 // Verify the SYN_REPLY. |
5495 // Copy the response info, because trans goes away. | 5497 // Copy the response info, because trans goes away. |
5496 HttpResponseInfo response = *trans->GetResponseInfo(); | 5498 HttpResponseInfo response = *trans->GetResponseInfo(); |
5497 ASSERT_TRUE(trans2->GetResponseInfo() == NULL); | 5499 ASSERT_TRUE(trans2->GetResponseInfo() == NULL); |
5498 | 5500 |
5499 VerifyStreamsClosed(helper); | 5501 VerifyStreamsClosed(helper); |
5500 | 5502 |
5501 // Verify the SYN_REPLY. | 5503 // Verify the SYN_REPLY. |
5502 EXPECT_TRUE(response.headers != NULL); | 5504 EXPECT_TRUE(response.headers.get() != NULL); |
5503 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5505 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
5504 | 5506 |
5505 // Read the final EOF (which will close the session). | 5507 // Read the final EOF (which will close the session). |
5506 data.RunFor(1); | 5508 data.RunFor(1); |
5507 | 5509 |
5508 // Verify that we consumed all test data. | 5510 // Verify that we consumed all test data. |
5509 EXPECT_TRUE(data.at_read_eof()); | 5511 EXPECT_TRUE(data.at_read_eof()); |
5510 EXPECT_TRUE(data.at_write_eof()); | 5512 EXPECT_TRUE(data.at_write_eof()); |
5511 } | 5513 } |
5512 | 5514 |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5783 EXPECT_TRUE(data.at_read_eof()); | 5785 EXPECT_TRUE(data.at_read_eof()); |
5784 EXPECT_TRUE(data.at_write_eof()); | 5786 EXPECT_TRUE(data.at_write_eof()); |
5785 | 5787 |
5786 // Verify the SYN_REPLY. | 5788 // Verify the SYN_REPLY. |
5787 // Copy the response info, because trans goes away. | 5789 // Copy the response info, because trans goes away. |
5788 response = *trans->GetResponseInfo(); | 5790 response = *trans->GetResponseInfo(); |
5789 | 5791 |
5790 VerifyStreamsClosed(helper); | 5792 VerifyStreamsClosed(helper); |
5791 | 5793 |
5792 // Verify the SYN_REPLY. | 5794 // Verify the SYN_REPLY. |
5793 EXPECT_TRUE(response.headers != NULL); | 5795 EXPECT_TRUE(response.headers.get() != NULL); |
5794 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5796 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
5795 } | 5797 } |
5796 } | 5798 } |
5797 | 5799 |
5798 TEST_P(SpdyNetworkTransactionSpdy2Test, RetryAfterRefused) { | 5800 TEST_P(SpdyNetworkTransactionSpdy2Test, RetryAfterRefused) { |
5799 // Construct the request. | 5801 // Construct the request. |
5800 scoped_ptr<SpdyFrame> req( | 5802 scoped_ptr<SpdyFrame> req( |
5801 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 5803 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
5802 scoped_ptr<SpdyFrame> req2( | 5804 scoped_ptr<SpdyFrame> req2( |
5803 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); | 5805 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5840 << data.read_count() | 5842 << data.read_count() |
5841 << " Read index: " | 5843 << " Read index: " |
5842 << data.read_index(); | 5844 << data.read_index(); |
5843 EXPECT_TRUE(data.at_write_eof()) << "Write count: " | 5845 EXPECT_TRUE(data.at_write_eof()) << "Write count: " |
5844 << data.write_count() | 5846 << data.write_count() |
5845 << " Write index: " | 5847 << " Write index: " |
5846 << data.write_index(); | 5848 << data.write_index(); |
5847 | 5849 |
5848 // Verify the SYN_REPLY. | 5850 // Verify the SYN_REPLY. |
5849 HttpResponseInfo response = *trans->GetResponseInfo(); | 5851 HttpResponseInfo response = *trans->GetResponseInfo(); |
5850 EXPECT_TRUE(response.headers != NULL); | 5852 EXPECT_TRUE(response.headers.get() != NULL); |
5851 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5853 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
5852 } | 5854 } |
5853 | 5855 |
5854 TEST_P(SpdyNetworkTransactionSpdy2Test, OutOfOrderSynStream) { | 5856 TEST_P(SpdyNetworkTransactionSpdy2Test, OutOfOrderSynStream) { |
5855 // This first request will start to establish the SpdySession. | 5857 // This first request will start to establish the SpdySession. |
5856 // Then we will start the second (MEDIUM priority) and then third | 5858 // Then we will start the second (MEDIUM priority) and then third |
5857 // (HIGHEST priority) request in such a way that the third will actually | 5859 // (HIGHEST priority) request in such a way that the third will actually |
5858 // start before the second, causing the second to be numbered differently | 5860 // start before the second, causing the second to be numbered differently |
5859 // than the order they were created. | 5861 // than the order they were created. |
5860 scoped_ptr<SpdyFrame> req1( | 5862 scoped_ptr<SpdyFrame> req1( |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5901 EXPECT_EQ(ERR_IO_PENDING, rv); | 5903 EXPECT_EQ(ERR_IO_PENDING, rv); |
5902 | 5904 |
5903 // Run the message loop, but do not allow the write to complete. | 5905 // Run the message loop, but do not allow the write to complete. |
5904 // This leaves the SpdySession with a write pending, which prevents | 5906 // This leaves the SpdySession with a write pending, which prevents |
5905 // SpdySession from attempting subsequent writes until this write completes. | 5907 // SpdySession from attempting subsequent writes until this write completes. |
5906 base::MessageLoop::current()->RunUntilIdle(); | 5908 base::MessageLoop::current()->RunUntilIdle(); |
5907 | 5909 |
5908 // Now, start both new transactions | 5910 // Now, start both new transactions |
5909 HttpRequestInfo info2 = CreateGetRequest(); | 5911 HttpRequestInfo info2 = CreateGetRequest(); |
5910 TestCompletionCallback callback2; | 5912 TestCompletionCallback callback2; |
5911 scoped_ptr<HttpNetworkTransaction> trans2( | 5913 scoped_ptr<HttpNetworkTransaction> trans2( |
5912 new HttpNetworkTransaction(MEDIUM, helper.session())); | 5914 new HttpNetworkTransaction(MEDIUM, helper.session().get())); |
5913 rv = trans2->Start(&info2, callback2.callback(), BoundNetLog()); | 5915 rv = trans2->Start(&info2, callback2.callback(), BoundNetLog()); |
5914 EXPECT_EQ(ERR_IO_PENDING, rv); | 5916 EXPECT_EQ(ERR_IO_PENDING, rv); |
5915 base::MessageLoop::current()->RunUntilIdle(); | 5917 base::MessageLoop::current()->RunUntilIdle(); |
5916 | 5918 |
5917 HttpRequestInfo info3 = CreateGetRequest(); | 5919 HttpRequestInfo info3 = CreateGetRequest(); |
5918 TestCompletionCallback callback3; | 5920 TestCompletionCallback callback3; |
5919 scoped_ptr<HttpNetworkTransaction> trans3( | 5921 scoped_ptr<HttpNetworkTransaction> trans3( |
5920 new HttpNetworkTransaction(HIGHEST, helper.session())); | 5922 new HttpNetworkTransaction(HIGHEST, helper.session().get())); |
5921 rv = trans3->Start(&info3, callback3.callback(), BoundNetLog()); | 5923 rv = trans3->Start(&info3, callback3.callback(), BoundNetLog()); |
5922 EXPECT_EQ(ERR_IO_PENDING, rv); | 5924 EXPECT_EQ(ERR_IO_PENDING, rv); |
5923 base::MessageLoop::current()->RunUntilIdle(); | 5925 base::MessageLoop::current()->RunUntilIdle(); |
5924 | 5926 |
5925 // We now have two SYN_STREAM frames queued up which will be | 5927 // We now have two SYN_STREAM frames queued up which will be |
5926 // dequeued only once the first write completes, which we | 5928 // dequeued only once the first write completes, which we |
5927 // now allow to happen. | 5929 // now allow to happen. |
5928 data.RunFor(2); | 5930 data.RunFor(2); |
5929 EXPECT_EQ(OK, callback.WaitForResult()); | 5931 EXPECT_EQ(OK, callback.WaitForResult()); |
5930 | 5932 |
5931 // And now we can allow everything else to run to completion. | 5933 // And now we can allow everything else to run to completion. |
5932 data.SetStop(10); | 5934 data.SetStop(10); |
5933 data.Run(); | 5935 data.Run(); |
5934 EXPECT_EQ(OK, callback2.WaitForResult()); | 5936 EXPECT_EQ(OK, callback2.WaitForResult()); |
5935 EXPECT_EQ(OK, callback3.WaitForResult()); | 5937 EXPECT_EQ(OK, callback3.WaitForResult()); |
5936 | 5938 |
5937 helper.VerifyDataConsumed(); | 5939 helper.VerifyDataConsumed(); |
5938 } | 5940 } |
5939 | 5941 |
5940 } // namespace net | 5942 } // namespace net |
OLD | NEW |