| 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 break; | 168 break; |
| 169 case SPDYSSL: | 169 case SPDYSSL: |
| 170 HttpStreamFactory::set_force_spdy_over_ssl(true); | 170 HttpStreamFactory::set_force_spdy_over_ssl(true); |
| 171 HttpStreamFactory::set_force_spdy_always(true); | 171 HttpStreamFactory::set_force_spdy_always(true); |
| 172 break; | 172 break; |
| 173 default: | 173 default: |
| 174 NOTREACHED(); | 174 NOTREACHED(); |
| 175 } | 175 } |
| 176 | 176 |
| 177 // We're now ready to use SSL-npn SPDY. | 177 // We're now ready to use SSL-npn SPDY. |
| 178 trans_.reset(new HttpNetworkTransaction(priority_, session_)); | 178 trans_.reset(new HttpNetworkTransaction(priority_, session_.get())); |
| 179 } | 179 } |
| 180 | 180 |
| 181 // Start the transaction, read some data, finish. | 181 // Start the transaction, read some data, finish. |
| 182 void RunDefaultTest() { | 182 void RunDefaultTest() { |
| 183 if (!StartDefaultTest()) | 183 if (!StartDefaultTest()) |
| 184 return; | 184 return; |
| 185 FinishDefaultTest(); | 185 FinishDefaultTest(); |
| 186 } | 186 } |
| 187 | 187 |
| 188 bool StartDefaultTest() { | 188 bool StartDefaultTest() { |
| 189 output_.rv = trans_->Start(&request_, callback.callback(), log_); | 189 output_.rv = trans_->Start(&request_, callback.callback(), log_); |
| 190 | 190 |
| 191 // We expect an IO Pending or some sort of error. | 191 // We expect an IO Pending or some sort of error. |
| 192 EXPECT_LT(output_.rv, 0); | 192 EXPECT_LT(output_.rv, 0); |
| 193 return output_.rv == ERR_IO_PENDING; | 193 return output_.rv == ERR_IO_PENDING; |
| 194 } | 194 } |
| 195 | 195 |
| 196 void FinishDefaultTest() { | 196 void FinishDefaultTest() { |
| 197 output_.rv = callback.WaitForResult(); | 197 output_.rv = callback.WaitForResult(); |
| 198 if (output_.rv != OK) { | 198 if (output_.rv != OK) { |
| 199 session_->spdy_session_pool()->CloseCurrentSessions(net::ERR_ABORTED); | 199 session_->spdy_session_pool()->CloseCurrentSessions(net::ERR_ABORTED); |
| 200 return; | 200 return; |
| 201 } | 201 } |
| 202 | 202 |
| 203 // Verify responses. | 203 // Verify responses. |
| 204 const HttpResponseInfo* response = trans_->GetResponseInfo(); | 204 const HttpResponseInfo* response = trans_->GetResponseInfo(); |
| 205 ASSERT_TRUE(response != NULL); | 205 ASSERT_TRUE(response != NULL); |
| 206 ASSERT_TRUE(response->headers != NULL); | 206 ASSERT_TRUE(response->headers.get() != NULL); |
| 207 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 207 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 208 EXPECT_EQ(spdy_enabled_, response->was_fetched_via_spdy); | 208 EXPECT_EQ(spdy_enabled_, response->was_fetched_via_spdy); |
| 209 if (HttpStreamFactory::spdy_enabled()) { | 209 if (HttpStreamFactory::spdy_enabled()) { |
| 210 EXPECT_EQ(HttpResponseInfo::CONNECTION_INFO_SPDY3, | 210 EXPECT_EQ(HttpResponseInfo::CONNECTION_INFO_SPDY3, |
| 211 response->connection_info); | 211 response->connection_info); |
| 212 } else { | 212 } else { |
| 213 EXPECT_EQ(HttpResponseInfo::CONNECTION_INFO_HTTP1, | 213 EXPECT_EQ(HttpResponseInfo::CONNECTION_INFO_HTTP1, |
| 214 response->connection_info); | 214 response->connection_info); |
| 215 } | 215 } |
| 216 if (test_type_ == SPDYNPN && spdy_enabled_) { | 216 if (test_type_ == SPDYNPN && spdy_enabled_) { |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 // the data for |trans|. | 485 // the data for |trans|. |
| 486 int ReadResult(HttpNetworkTransaction* trans, | 486 int ReadResult(HttpNetworkTransaction* trans, |
| 487 StaticSocketDataProvider* data, | 487 StaticSocketDataProvider* data, |
| 488 std::string* result) { | 488 std::string* result) { |
| 489 const int kSize = 3000; | 489 const int kSize = 3000; |
| 490 | 490 |
| 491 int bytes_read = 0; | 491 int bytes_read = 0; |
| 492 scoped_refptr<net::IOBufferWithSize> buf(new net::IOBufferWithSize(kSize)); | 492 scoped_refptr<net::IOBufferWithSize> buf(new net::IOBufferWithSize(kSize)); |
| 493 TestCompletionCallback callback; | 493 TestCompletionCallback callback; |
| 494 while (true) { | 494 while (true) { |
| 495 int rv = trans->Read(buf, kSize, callback.callback()); | 495 int rv = trans->Read(buf.get(), kSize, callback.callback()); |
| 496 if (rv == ERR_IO_PENDING) { | 496 if (rv == ERR_IO_PENDING) { |
| 497 // Multiple transactions may be in the data set. Keep pulling off | 497 // Multiple transactions may be in the data set. Keep pulling off |
| 498 // reads until we complete our callback. | 498 // reads until we complete our callback. |
| 499 while (!callback.have_result()) { | 499 while (!callback.have_result()) { |
| 500 data->CompleteRead(); | 500 data->CompleteRead(); |
| 501 base::MessageLoop::current()->RunUntilIdle(); | 501 base::MessageLoop::current()->RunUntilIdle(); |
| 502 } | 502 } |
| 503 rv = callback.WaitForResult(); | 503 rv = callback.WaitForResult(); |
| 504 } else if (rv <= 0) { | 504 } else if (rv <= 0) { |
| 505 break; | 505 break; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 | 542 |
| 543 // Start the transaction with basic parameters. | 543 // Start the transaction with basic parameters. |
| 544 TestCompletionCallback callback; | 544 TestCompletionCallback callback; |
| 545 int rv = trans->Start( | 545 int rv = trans->Start( |
| 546 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 546 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
| 547 EXPECT_EQ(ERR_IO_PENDING, rv); | 547 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 548 rv = callback.WaitForResult(); | 548 rv = callback.WaitForResult(); |
| 549 | 549 |
| 550 // Request the pushed path. | 550 // Request the pushed path. |
| 551 scoped_ptr<HttpNetworkTransaction> trans2( | 551 scoped_ptr<HttpNetworkTransaction> trans2( |
| 552 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 552 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
| 553 rv = trans2->Start( | 553 rv = trans2->Start( |
| 554 &CreateGetPushRequest(), callback.callback(), BoundNetLog()); | 554 &CreateGetPushRequest(), callback.callback(), BoundNetLog()); |
| 555 EXPECT_EQ(ERR_IO_PENDING, rv); | 555 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 556 base::MessageLoop::current()->RunUntilIdle(); | 556 base::MessageLoop::current()->RunUntilIdle(); |
| 557 | 557 |
| 558 // The data for the pushed path may be coming in more than 1 packet. Compile | 558 // The data for the pushed path may be coming in more than 1 packet. Compile |
| 559 // the results into a single string. | 559 // the results into a single string. |
| 560 | 560 |
| 561 // Read the server push body. | 561 // Read the server push body. |
| 562 std::string result2; | 562 std::string result2; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 585 | 585 |
| 586 static void DeleteSessionCallback(NormalSpdyTransactionHelper* helper, | 586 static void DeleteSessionCallback(NormalSpdyTransactionHelper* helper, |
| 587 int result) { | 587 int result) { |
| 588 helper->ResetTrans(); | 588 helper->ResetTrans(); |
| 589 } | 589 } |
| 590 | 590 |
| 591 static void StartTransactionCallback( | 591 static void StartTransactionCallback( |
| 592 const scoped_refptr<HttpNetworkSession>& session, | 592 const scoped_refptr<HttpNetworkSession>& session, |
| 593 int result) { | 593 int result) { |
| 594 scoped_ptr<HttpNetworkTransaction> trans( | 594 scoped_ptr<HttpNetworkTransaction> trans( |
| 595 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 595 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 596 TestCompletionCallback callback; | 596 TestCompletionCallback callback; |
| 597 HttpRequestInfo request; | 597 HttpRequestInfo request; |
| 598 request.method = "GET"; | 598 request.method = "GET"; |
| 599 request.url = GURL("http://www.google.com/"); | 599 request.url = GURL("http://www.google.com/"); |
| 600 request.load_flags = 0; | 600 request.load_flags = 0; |
| 601 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 601 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 602 EXPECT_EQ(ERR_IO_PENDING, rv); | 602 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 603 callback.WaitForResult(); | 603 callback.WaitForResult(); |
| 604 } | 604 } |
| 605 | 605 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 625 ::testing::Values(SPDYNOSSL, SPDYSSL, SPDYNPN)); | 625 ::testing::Values(SPDYNOSSL, SPDYSSL, SPDYNPN)); |
| 626 | 626 |
| 627 | 627 |
| 628 // Verify HttpNetworkTransaction constructor. | 628 // Verify HttpNetworkTransaction constructor. |
| 629 TEST_P(SpdyNetworkTransactionSpdy3Test, Constructor) { | 629 TEST_P(SpdyNetworkTransactionSpdy3Test, Constructor) { |
| 630 scoped_ptr<SpdySessionDependencies> session_deps( | 630 scoped_ptr<SpdySessionDependencies> session_deps( |
| 631 CreateSpdySessionDependencies()); | 631 CreateSpdySessionDependencies()); |
| 632 scoped_refptr<HttpNetworkSession> session( | 632 scoped_refptr<HttpNetworkSession> session( |
| 633 SpdySessionDependencies::SpdyCreateSession(session_deps.get())); | 633 SpdySessionDependencies::SpdyCreateSession(session_deps.get())); |
| 634 scoped_ptr<HttpTransaction> trans( | 634 scoped_ptr<HttpTransaction> trans( |
| 635 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 635 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 636 } | 636 } |
| 637 | 637 |
| 638 TEST_P(SpdyNetworkTransactionSpdy3Test, Get) { | 638 TEST_P(SpdyNetworkTransactionSpdy3Test, Get) { |
| 639 // Construct the request. | 639 // Construct the request. |
| 640 scoped_ptr<SpdyFrame> req( | 640 scoped_ptr<SpdyFrame> req( |
| 641 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 641 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 642 MockWrite writes[] = { CreateMockWrite(*req) }; | 642 MockWrite writes[] = { CreateMockWrite(*req) }; |
| 643 | 643 |
| 644 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 644 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 645 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); | 645 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 TransactionHelperResult out; | 771 TransactionHelperResult out; |
| 772 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 772 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 773 BoundNetLog(), GetParam(), NULL); | 773 BoundNetLog(), GetParam(), NULL); |
| 774 helper.RunPreTestSetup(); | 774 helper.RunPreTestSetup(); |
| 775 helper.AddData(&data); | 775 helper.AddData(&data); |
| 776 // We require placeholder data because three get requests are sent out, so | 776 // We require placeholder data because three get requests are sent out, so |
| 777 // there needs to be three sets of SSL connection data. | 777 // there needs to be three sets of SSL connection data. |
| 778 helper.AddData(&data_placeholder); | 778 helper.AddData(&data_placeholder); |
| 779 helper.AddData(&data_placeholder); | 779 helper.AddData(&data_placeholder); |
| 780 scoped_ptr<HttpNetworkTransaction> trans1( | 780 scoped_ptr<HttpNetworkTransaction> trans1( |
| 781 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 781 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
| 782 scoped_ptr<HttpNetworkTransaction> trans2( | 782 scoped_ptr<HttpNetworkTransaction> trans2( |
| 783 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 783 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
| 784 scoped_ptr<HttpNetworkTransaction> trans3( | 784 scoped_ptr<HttpNetworkTransaction> trans3( |
| 785 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 785 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
| 786 | 786 |
| 787 TestCompletionCallback callback1; | 787 TestCompletionCallback callback1; |
| 788 TestCompletionCallback callback2; | 788 TestCompletionCallback callback2; |
| 789 TestCompletionCallback callback3; | 789 TestCompletionCallback callback3; |
| 790 | 790 |
| 791 HttpRequestInfo httpreq1 = CreateGetRequest(); | 791 HttpRequestInfo httpreq1 = CreateGetRequest(); |
| 792 HttpRequestInfo httpreq2 = CreateGetRequest(); | 792 HttpRequestInfo httpreq2 = CreateGetRequest(); |
| 793 HttpRequestInfo httpreq3 = CreateGetRequest(); | 793 HttpRequestInfo httpreq3 = CreateGetRequest(); |
| 794 | 794 |
| 795 out.rv = trans1->Start(&httpreq1, callback1.callback(), log); | 795 out.rv = trans1->Start(&httpreq1, callback1.callback(), log); |
| 796 ASSERT_EQ(ERR_IO_PENDING, out.rv); | 796 ASSERT_EQ(ERR_IO_PENDING, out.rv); |
| 797 out.rv = trans2->Start(&httpreq2, callback2.callback(), log); | 797 out.rv = trans2->Start(&httpreq2, callback2.callback(), log); |
| 798 ASSERT_EQ(ERR_IO_PENDING, out.rv); | 798 ASSERT_EQ(ERR_IO_PENDING, out.rv); |
| 799 out.rv = trans3->Start(&httpreq3, callback3.callback(), log); | 799 out.rv = trans3->Start(&httpreq3, callback3.callback(), log); |
| 800 ASSERT_EQ(ERR_IO_PENDING, out.rv); | 800 ASSERT_EQ(ERR_IO_PENDING, out.rv); |
| 801 | 801 |
| 802 out.rv = callback1.WaitForResult(); | 802 out.rv = callback1.WaitForResult(); |
| 803 ASSERT_EQ(OK, out.rv); | 803 ASSERT_EQ(OK, out.rv); |
| 804 out.rv = callback3.WaitForResult(); | 804 out.rv = callback3.WaitForResult(); |
| 805 ASSERT_EQ(OK, out.rv); | 805 ASSERT_EQ(OK, out.rv); |
| 806 | 806 |
| 807 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); | 807 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); |
| 808 EXPECT_TRUE(response1->headers != NULL); | 808 EXPECT_TRUE(response1->headers.get() != NULL); |
| 809 EXPECT_TRUE(response1->was_fetched_via_spdy); | 809 EXPECT_TRUE(response1->was_fetched_via_spdy); |
| 810 out.status_line = response1->headers->GetStatusLine(); | 810 out.status_line = response1->headers->GetStatusLine(); |
| 811 out.response_info = *response1; | 811 out.response_info = *response1; |
| 812 | 812 |
| 813 trans2->GetResponseInfo(); | 813 trans2->GetResponseInfo(); |
| 814 | 814 |
| 815 out.rv = ReadTransaction(trans1.get(), &out.response_data); | 815 out.rv = ReadTransaction(trans1.get(), &out.response_data); |
| 816 helper.VerifyDataConsumed(); | 816 helper.VerifyDataConsumed(); |
| 817 EXPECT_EQ(OK, out.rv); | 817 EXPECT_EQ(OK, out.rv); |
| 818 | 818 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 858 BoundNetLog log; | 858 BoundNetLog log; |
| 859 TransactionHelperResult out; | 859 TransactionHelperResult out; |
| 860 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 860 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 861 BoundNetLog(), GetParam(), NULL); | 861 BoundNetLog(), GetParam(), NULL); |
| 862 helper.RunPreTestSetup(); | 862 helper.RunPreTestSetup(); |
| 863 helper.AddData(&data); | 863 helper.AddData(&data); |
| 864 // We require placeholder data because two get requests are sent out, so | 864 // We require placeholder data because two get requests are sent out, so |
| 865 // there needs to be two sets of SSL connection data. | 865 // there needs to be two sets of SSL connection data. |
| 866 helper.AddData(&data_placeholder); | 866 helper.AddData(&data_placeholder); |
| 867 scoped_ptr<HttpNetworkTransaction> trans1( | 867 scoped_ptr<HttpNetworkTransaction> trans1( |
| 868 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 868 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
| 869 scoped_ptr<HttpNetworkTransaction> trans2( | 869 scoped_ptr<HttpNetworkTransaction> trans2( |
| 870 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 870 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
| 871 | 871 |
| 872 TestCompletionCallback callback1; | 872 TestCompletionCallback callback1; |
| 873 TestCompletionCallback callback2; | 873 TestCompletionCallback callback2; |
| 874 | 874 |
| 875 HttpRequestInfo httpreq1 = CreateGetRequest(); | 875 HttpRequestInfo httpreq1 = CreateGetRequest(); |
| 876 HttpRequestInfo httpreq2 = CreateGetRequest(); | 876 HttpRequestInfo httpreq2 = CreateGetRequest(); |
| 877 | 877 |
| 878 out.rv = trans1->Start(&httpreq1, callback1.callback(), log); | 878 out.rv = trans1->Start(&httpreq1, callback1.callback(), log); |
| 879 ASSERT_EQ(ERR_IO_PENDING, out.rv); | 879 ASSERT_EQ(ERR_IO_PENDING, out.rv); |
| 880 out.rv = trans2->Start(&httpreq2, callback2.callback(), log); | 880 out.rv = trans2->Start(&httpreq2, callback2.callback(), log); |
| 881 ASSERT_EQ(ERR_IO_PENDING, out.rv); | 881 ASSERT_EQ(ERR_IO_PENDING, out.rv); |
| 882 | 882 |
| 883 out.rv = callback1.WaitForResult(); | 883 out.rv = callback1.WaitForResult(); |
| 884 ASSERT_EQ(OK, out.rv); | 884 ASSERT_EQ(OK, out.rv); |
| 885 out.rv = callback2.WaitForResult(); | 885 out.rv = callback2.WaitForResult(); |
| 886 ASSERT_EQ(OK, out.rv); | 886 ASSERT_EQ(OK, out.rv); |
| 887 | 887 |
| 888 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); | 888 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); |
| 889 EXPECT_TRUE(response1->headers != NULL); | 889 EXPECT_TRUE(response1->headers.get() != NULL); |
| 890 EXPECT_TRUE(response1->was_fetched_via_spdy); | 890 EXPECT_TRUE(response1->was_fetched_via_spdy); |
| 891 out.status_line = response1->headers->GetStatusLine(); | 891 out.status_line = response1->headers->GetStatusLine(); |
| 892 out.response_info = *response1; | 892 out.response_info = *response1; |
| 893 out.rv = ReadTransaction(trans1.get(), &out.response_data); | 893 out.rv = ReadTransaction(trans1.get(), &out.response_data); |
| 894 EXPECT_EQ(OK, out.rv); | 894 EXPECT_EQ(OK, out.rv); |
| 895 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 895 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 896 EXPECT_EQ("hello!hello!", out.response_data); | 896 EXPECT_EQ("hello!hello!", out.response_data); |
| 897 | 897 |
| 898 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); | 898 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); |
| 899 EXPECT_TRUE(response2->headers != NULL); | 899 EXPECT_TRUE(response2->headers.get() != NULL); |
| 900 EXPECT_TRUE(response2->was_fetched_via_spdy); | 900 EXPECT_TRUE(response2->was_fetched_via_spdy); |
| 901 out.status_line = response2->headers->GetStatusLine(); | 901 out.status_line = response2->headers->GetStatusLine(); |
| 902 out.response_info = *response2; | 902 out.response_info = *response2; |
| 903 out.rv = ReadTransaction(trans2.get(), &out.response_data); | 903 out.rv = ReadTransaction(trans2.get(), &out.response_data); |
| 904 EXPECT_EQ(OK, out.rv); | 904 EXPECT_EQ(OK, out.rv); |
| 905 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 905 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 906 EXPECT_EQ("hello!hello!", out.response_data); | 906 EXPECT_EQ("hello!hello!", out.response_data); |
| 907 | 907 |
| 908 helper.VerifyDataConsumed(); | 908 helper.VerifyDataConsumed(); |
| 909 } | 909 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 947 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 947 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 948 BoundNetLog(), GetParam(), NULL); | 948 BoundNetLog(), GetParam(), NULL); |
| 949 helper.RunPreTestSetup(); | 949 helper.RunPreTestSetup(); |
| 950 helper.AddData(&preconnect_data); | 950 helper.AddData(&preconnect_data); |
| 951 // We require placeholder data because 3 connections are attempted (first is | 951 // We require placeholder data because 3 connections are attempted (first is |
| 952 // the preconnect, 2nd and 3rd are the never finished connections. | 952 // the preconnect, 2nd and 3rd are the never finished connections. |
| 953 helper.AddData(&data_placeholder); | 953 helper.AddData(&data_placeholder); |
| 954 helper.AddData(&data_placeholder); | 954 helper.AddData(&data_placeholder); |
| 955 | 955 |
| 956 scoped_ptr<HttpNetworkTransaction> trans1( | 956 scoped_ptr<HttpNetworkTransaction> trans1( |
| 957 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 957 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
| 958 scoped_ptr<HttpNetworkTransaction> trans2( | 958 scoped_ptr<HttpNetworkTransaction> trans2( |
| 959 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 959 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
| 960 | 960 |
| 961 TestCompletionCallback callback1; | 961 TestCompletionCallback callback1; |
| 962 TestCompletionCallback callback2; | 962 TestCompletionCallback callback2; |
| 963 | 963 |
| 964 HttpRequestInfo httpreq = CreateGetRequest(); | 964 HttpRequestInfo httpreq = CreateGetRequest(); |
| 965 | 965 |
| 966 // Preconnect the first. | 966 // Preconnect the first. |
| 967 SSLConfig preconnect_ssl_config; | 967 SSLConfig preconnect_ssl_config; |
| 968 helper.session()->ssl_config_service()->GetSSLConfig(&preconnect_ssl_config); | 968 helper.session()->ssl_config_service()->GetSSLConfig(&preconnect_ssl_config); |
| 969 HttpStreamFactory* http_stream_factory = | 969 HttpStreamFactory* http_stream_factory = |
| (...skipping 10 matching lines...) Expand all Loading... |
| 980 ASSERT_EQ(ERR_IO_PENDING, out.rv); | 980 ASSERT_EQ(ERR_IO_PENDING, out.rv); |
| 981 out.rv = trans2->Start(&httpreq, callback2.callback(), log); | 981 out.rv = trans2->Start(&httpreq, callback2.callback(), log); |
| 982 ASSERT_EQ(ERR_IO_PENDING, out.rv); | 982 ASSERT_EQ(ERR_IO_PENDING, out.rv); |
| 983 | 983 |
| 984 out.rv = callback1.WaitForResult(); | 984 out.rv = callback1.WaitForResult(); |
| 985 ASSERT_EQ(OK, out.rv); | 985 ASSERT_EQ(OK, out.rv); |
| 986 out.rv = callback2.WaitForResult(); | 986 out.rv = callback2.WaitForResult(); |
| 987 ASSERT_EQ(OK, out.rv); | 987 ASSERT_EQ(OK, out.rv); |
| 988 | 988 |
| 989 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); | 989 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); |
| 990 EXPECT_TRUE(response1->headers != NULL); | 990 EXPECT_TRUE(response1->headers.get() != NULL); |
| 991 EXPECT_TRUE(response1->was_fetched_via_spdy); | 991 EXPECT_TRUE(response1->was_fetched_via_spdy); |
| 992 out.status_line = response1->headers->GetStatusLine(); | 992 out.status_line = response1->headers->GetStatusLine(); |
| 993 out.response_info = *response1; | 993 out.response_info = *response1; |
| 994 out.rv = ReadTransaction(trans1.get(), &out.response_data); | 994 out.rv = ReadTransaction(trans1.get(), &out.response_data); |
| 995 EXPECT_EQ(OK, out.rv); | 995 EXPECT_EQ(OK, out.rv); |
| 996 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 996 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 997 EXPECT_EQ("hello!hello!", out.response_data); | 997 EXPECT_EQ("hello!hello!", out.response_data); |
| 998 | 998 |
| 999 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); | 999 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); |
| 1000 EXPECT_TRUE(response2->headers != NULL); | 1000 EXPECT_TRUE(response2->headers.get() != NULL); |
| 1001 EXPECT_TRUE(response2->was_fetched_via_spdy); | 1001 EXPECT_TRUE(response2->was_fetched_via_spdy); |
| 1002 out.status_line = response2->headers->GetStatusLine(); | 1002 out.status_line = response2->headers->GetStatusLine(); |
| 1003 out.response_info = *response2; | 1003 out.response_info = *response2; |
| 1004 out.rv = ReadTransaction(trans2.get(), &out.response_data); | 1004 out.rv = ReadTransaction(trans2.get(), &out.response_data); |
| 1005 EXPECT_EQ(OK, out.rv); | 1005 EXPECT_EQ(OK, out.rv); |
| 1006 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 1006 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 1007 EXPECT_EQ("hello!hello!", out.response_data); | 1007 EXPECT_EQ("hello!hello!", out.response_data); |
| 1008 | 1008 |
| 1009 helper.VerifyDataConsumed(); | 1009 helper.VerifyDataConsumed(); |
| 1010 } | 1010 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1071 { | 1071 { |
| 1072 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 1072 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 1073 BoundNetLog(), GetParam(), NULL); | 1073 BoundNetLog(), GetParam(), NULL); |
| 1074 helper.RunPreTestSetup(); | 1074 helper.RunPreTestSetup(); |
| 1075 helper.AddData(&data); | 1075 helper.AddData(&data); |
| 1076 // We require placeholder data because three get requests are sent out, so | 1076 // We require placeholder data because three get requests are sent out, so |
| 1077 // there needs to be three sets of SSL connection data. | 1077 // there needs to be three sets of SSL connection data. |
| 1078 helper.AddData(&data_placeholder); | 1078 helper.AddData(&data_placeholder); |
| 1079 helper.AddData(&data_placeholder); | 1079 helper.AddData(&data_placeholder); |
| 1080 scoped_ptr<HttpNetworkTransaction> trans1( | 1080 scoped_ptr<HttpNetworkTransaction> trans1( |
| 1081 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 1081 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
| 1082 scoped_ptr<HttpNetworkTransaction> trans2( | 1082 scoped_ptr<HttpNetworkTransaction> trans2( |
| 1083 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 1083 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
| 1084 scoped_ptr<HttpNetworkTransaction> trans3( | 1084 scoped_ptr<HttpNetworkTransaction> trans3( |
| 1085 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 1085 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
| 1086 | 1086 |
| 1087 TestCompletionCallback callback1; | 1087 TestCompletionCallback callback1; |
| 1088 TestCompletionCallback callback2; | 1088 TestCompletionCallback callback2; |
| 1089 TestCompletionCallback callback3; | 1089 TestCompletionCallback callback3; |
| 1090 | 1090 |
| 1091 HttpRequestInfo httpreq1 = CreateGetRequest(); | 1091 HttpRequestInfo httpreq1 = CreateGetRequest(); |
| 1092 HttpRequestInfo httpreq2 = CreateGetRequest(); | 1092 HttpRequestInfo httpreq2 = CreateGetRequest(); |
| 1093 HttpRequestInfo httpreq3 = CreateGetRequest(); | 1093 HttpRequestInfo httpreq3 = CreateGetRequest(); |
| 1094 | 1094 |
| 1095 out.rv = trans1->Start(&httpreq1, callback1.callback(), log); | 1095 out.rv = trans1->Start(&httpreq1, callback1.callback(), log); |
| 1096 ASSERT_EQ(out.rv, ERR_IO_PENDING); | 1096 ASSERT_EQ(out.rv, ERR_IO_PENDING); |
| 1097 // run transaction 1 through quickly to force a read of our SETTINGS | 1097 // run transaction 1 through quickly to force a read of our SETTINGS |
| 1098 // frame | 1098 // frame |
| 1099 out.rv = callback1.WaitForResult(); | 1099 out.rv = callback1.WaitForResult(); |
| 1100 ASSERT_EQ(OK, out.rv); | 1100 ASSERT_EQ(OK, out.rv); |
| 1101 | 1101 |
| 1102 out.rv = trans2->Start(&httpreq2, callback2.callback(), log); | 1102 out.rv = trans2->Start(&httpreq2, callback2.callback(), log); |
| 1103 ASSERT_EQ(out.rv, ERR_IO_PENDING); | 1103 ASSERT_EQ(out.rv, ERR_IO_PENDING); |
| 1104 out.rv = trans3->Start(&httpreq3, callback3.callback(), log); | 1104 out.rv = trans3->Start(&httpreq3, callback3.callback(), log); |
| 1105 ASSERT_EQ(out.rv, ERR_IO_PENDING); | 1105 ASSERT_EQ(out.rv, ERR_IO_PENDING); |
| 1106 out.rv = callback2.WaitForResult(); | 1106 out.rv = callback2.WaitForResult(); |
| 1107 ASSERT_EQ(OK, out.rv); | 1107 ASSERT_EQ(OK, out.rv); |
| 1108 EXPECT_EQ(7U, data.read_index()); // i.e. the third trans was queued | 1108 EXPECT_EQ(7U, data.read_index()); // i.e. the third trans was queued |
| 1109 | 1109 |
| 1110 out.rv = callback3.WaitForResult(); | 1110 out.rv = callback3.WaitForResult(); |
| 1111 ASSERT_EQ(OK, out.rv); | 1111 ASSERT_EQ(OK, out.rv); |
| 1112 | 1112 |
| 1113 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); | 1113 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); |
| 1114 ASSERT_TRUE(response1 != NULL); | 1114 ASSERT_TRUE(response1 != NULL); |
| 1115 EXPECT_TRUE(response1->headers != NULL); | 1115 EXPECT_TRUE(response1->headers.get() != NULL); |
| 1116 EXPECT_TRUE(response1->was_fetched_via_spdy); | 1116 EXPECT_TRUE(response1->was_fetched_via_spdy); |
| 1117 out.status_line = response1->headers->GetStatusLine(); | 1117 out.status_line = response1->headers->GetStatusLine(); |
| 1118 out.response_info = *response1; | 1118 out.response_info = *response1; |
| 1119 out.rv = ReadTransaction(trans1.get(), &out.response_data); | 1119 out.rv = ReadTransaction(trans1.get(), &out.response_data); |
| 1120 EXPECT_EQ(OK, out.rv); | 1120 EXPECT_EQ(OK, out.rv); |
| 1121 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 1121 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 1122 EXPECT_EQ("hello!hello!", out.response_data); | 1122 EXPECT_EQ("hello!hello!", out.response_data); |
| 1123 | 1123 |
| 1124 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); | 1124 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); |
| 1125 out.status_line = response2->headers->GetStatusLine(); | 1125 out.status_line = response2->headers->GetStatusLine(); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1210 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 1210 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 1211 BoundNetLog(), GetParam(), NULL); | 1211 BoundNetLog(), GetParam(), NULL); |
| 1212 helper.RunPreTestSetup(); | 1212 helper.RunPreTestSetup(); |
| 1213 helper.AddData(&data); | 1213 helper.AddData(&data); |
| 1214 // We require placeholder data because four get requests are sent out, so | 1214 // We require placeholder data because four get requests are sent out, so |
| 1215 // there needs to be four sets of SSL connection data. | 1215 // there needs to be four sets of SSL connection data. |
| 1216 helper.AddData(&data_placeholder); | 1216 helper.AddData(&data_placeholder); |
| 1217 helper.AddData(&data_placeholder); | 1217 helper.AddData(&data_placeholder); |
| 1218 helper.AddData(&data_placeholder); | 1218 helper.AddData(&data_placeholder); |
| 1219 scoped_ptr<HttpNetworkTransaction> trans1( | 1219 scoped_ptr<HttpNetworkTransaction> trans1( |
| 1220 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 1220 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
| 1221 scoped_ptr<HttpNetworkTransaction> trans2( | 1221 scoped_ptr<HttpNetworkTransaction> trans2( |
| 1222 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 1222 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
| 1223 scoped_ptr<HttpNetworkTransaction> trans3( | 1223 scoped_ptr<HttpNetworkTransaction> trans3( |
| 1224 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 1224 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
| 1225 scoped_ptr<HttpNetworkTransaction> trans4( | 1225 scoped_ptr<HttpNetworkTransaction> trans4( |
| 1226 new HttpNetworkTransaction(HIGHEST, helper.session())); | 1226 new HttpNetworkTransaction(HIGHEST, helper.session().get())); |
| 1227 | 1227 |
| 1228 TestCompletionCallback callback1; | 1228 TestCompletionCallback callback1; |
| 1229 TestCompletionCallback callback2; | 1229 TestCompletionCallback callback2; |
| 1230 TestCompletionCallback callback3; | 1230 TestCompletionCallback callback3; |
| 1231 TestCompletionCallback callback4; | 1231 TestCompletionCallback callback4; |
| 1232 | 1232 |
| 1233 HttpRequestInfo httpreq1 = CreateGetRequest(); | 1233 HttpRequestInfo httpreq1 = CreateGetRequest(); |
| 1234 HttpRequestInfo httpreq2 = CreateGetRequest(); | 1234 HttpRequestInfo httpreq2 = CreateGetRequest(); |
| 1235 HttpRequestInfo httpreq3 = CreateGetRequest(); | 1235 HttpRequestInfo httpreq3 = CreateGetRequest(); |
| 1236 HttpRequestInfo httpreq4 = CreateGetRequest(); | 1236 HttpRequestInfo httpreq4 = CreateGetRequest(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1249 ASSERT_EQ(ERR_IO_PENDING, out.rv); | 1249 ASSERT_EQ(ERR_IO_PENDING, out.rv); |
| 1250 | 1250 |
| 1251 out.rv = callback2.WaitForResult(); | 1251 out.rv = callback2.WaitForResult(); |
| 1252 ASSERT_EQ(OK, out.rv); | 1252 ASSERT_EQ(OK, out.rv); |
| 1253 EXPECT_EQ(data.read_index(), 7U); // i.e. the third & fourth trans queued | 1253 EXPECT_EQ(data.read_index(), 7U); // i.e. the third & fourth trans queued |
| 1254 | 1254 |
| 1255 out.rv = callback3.WaitForResult(); | 1255 out.rv = callback3.WaitForResult(); |
| 1256 ASSERT_EQ(OK, out.rv); | 1256 ASSERT_EQ(OK, out.rv); |
| 1257 | 1257 |
| 1258 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); | 1258 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); |
| 1259 EXPECT_TRUE(response1->headers != NULL); | 1259 EXPECT_TRUE(response1->headers.get() != NULL); |
| 1260 EXPECT_TRUE(response1->was_fetched_via_spdy); | 1260 EXPECT_TRUE(response1->was_fetched_via_spdy); |
| 1261 out.status_line = response1->headers->GetStatusLine(); | 1261 out.status_line = response1->headers->GetStatusLine(); |
| 1262 out.response_info = *response1; | 1262 out.response_info = *response1; |
| 1263 out.rv = ReadTransaction(trans1.get(), &out.response_data); | 1263 out.rv = ReadTransaction(trans1.get(), &out.response_data); |
| 1264 EXPECT_EQ(OK, out.rv); | 1264 EXPECT_EQ(OK, out.rv); |
| 1265 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 1265 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 1266 EXPECT_EQ("hello!hello!", out.response_data); | 1266 EXPECT_EQ("hello!hello!", out.response_data); |
| 1267 | 1267 |
| 1268 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); | 1268 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); |
| 1269 out.status_line = response2->headers->GetStatusLine(); | 1269 out.status_line = response2->headers->GetStatusLine(); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1343 TransactionHelperResult out; | 1343 TransactionHelperResult out; |
| 1344 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 1344 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 1345 BoundNetLog(), GetParam(), NULL); | 1345 BoundNetLog(), GetParam(), NULL); |
| 1346 helper.RunPreTestSetup(); | 1346 helper.RunPreTestSetup(); |
| 1347 helper.AddData(&data); | 1347 helper.AddData(&data); |
| 1348 // We require placeholder data because three get requests are sent out, so | 1348 // We require placeholder data because three get requests are sent out, so |
| 1349 // there needs to be three sets of SSL connection data. | 1349 // there needs to be three sets of SSL connection data. |
| 1350 helper.AddData(&data_placeholder); | 1350 helper.AddData(&data_placeholder); |
| 1351 helper.AddData(&data_placeholder); | 1351 helper.AddData(&data_placeholder); |
| 1352 scoped_ptr<HttpNetworkTransaction> trans1( | 1352 scoped_ptr<HttpNetworkTransaction> trans1( |
| 1353 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 1353 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
| 1354 scoped_ptr<HttpNetworkTransaction> trans2( | 1354 scoped_ptr<HttpNetworkTransaction> trans2( |
| 1355 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 1355 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
| 1356 scoped_ptr<HttpNetworkTransaction> trans3( | 1356 scoped_ptr<HttpNetworkTransaction> trans3( |
| 1357 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 1357 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
| 1358 | 1358 |
| 1359 TestCompletionCallback callback1; | 1359 TestCompletionCallback callback1; |
| 1360 TestCompletionCallback callback2; | 1360 TestCompletionCallback callback2; |
| 1361 TestCompletionCallback callback3; | 1361 TestCompletionCallback callback3; |
| 1362 | 1362 |
| 1363 HttpRequestInfo httpreq1 = CreateGetRequest(); | 1363 HttpRequestInfo httpreq1 = CreateGetRequest(); |
| 1364 HttpRequestInfo httpreq2 = CreateGetRequest(); | 1364 HttpRequestInfo httpreq2 = CreateGetRequest(); |
| 1365 HttpRequestInfo httpreq3 = CreateGetRequest(); | 1365 HttpRequestInfo httpreq3 = CreateGetRequest(); |
| 1366 | 1366 |
| 1367 out.rv = trans1->Start(&httpreq1, callback1.callback(), log); | 1367 out.rv = trans1->Start(&httpreq1, callback1.callback(), log); |
| 1368 ASSERT_EQ(out.rv, ERR_IO_PENDING); | 1368 ASSERT_EQ(out.rv, ERR_IO_PENDING); |
| 1369 // Run transaction 1 through quickly to force a read of our SETTINGS frame. | 1369 // Run transaction 1 through quickly to force a read of our SETTINGS frame. |
| 1370 out.rv = callback1.WaitForResult(); | 1370 out.rv = callback1.WaitForResult(); |
| 1371 ASSERT_EQ(OK, out.rv); | 1371 ASSERT_EQ(OK, out.rv); |
| 1372 | 1372 |
| 1373 out.rv = trans2->Start(&httpreq2, callback2.callback(), log); | 1373 out.rv = trans2->Start(&httpreq2, callback2.callback(), log); |
| 1374 ASSERT_EQ(out.rv, ERR_IO_PENDING); | 1374 ASSERT_EQ(out.rv, ERR_IO_PENDING); |
| 1375 out.rv = trans3->Start(&httpreq3, callback3.callback(), log); | 1375 out.rv = trans3->Start(&httpreq3, callback3.callback(), log); |
| 1376 delete trans3.release(); | 1376 delete trans3.release(); |
| 1377 ASSERT_EQ(out.rv, ERR_IO_PENDING); | 1377 ASSERT_EQ(out.rv, ERR_IO_PENDING); |
| 1378 out.rv = callback2.WaitForResult(); | 1378 out.rv = callback2.WaitForResult(); |
| 1379 ASSERT_EQ(OK, out.rv); | 1379 ASSERT_EQ(OK, out.rv); |
| 1380 | 1380 |
| 1381 EXPECT_EQ(8U, data.read_index()); | 1381 EXPECT_EQ(8U, data.read_index()); |
| 1382 | 1382 |
| 1383 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); | 1383 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); |
| 1384 ASSERT_TRUE(response1 != NULL); | 1384 ASSERT_TRUE(response1 != NULL); |
| 1385 EXPECT_TRUE(response1->headers != NULL); | 1385 EXPECT_TRUE(response1->headers.get() != NULL); |
| 1386 EXPECT_TRUE(response1->was_fetched_via_spdy); | 1386 EXPECT_TRUE(response1->was_fetched_via_spdy); |
| 1387 out.status_line = response1->headers->GetStatusLine(); | 1387 out.status_line = response1->headers->GetStatusLine(); |
| 1388 out.response_info = *response1; | 1388 out.response_info = *response1; |
| 1389 out.rv = ReadTransaction(trans1.get(), &out.response_data); | 1389 out.rv = ReadTransaction(trans1.get(), &out.response_data); |
| 1390 EXPECT_EQ(OK, out.rv); | 1390 EXPECT_EQ(OK, out.rv); |
| 1391 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 1391 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 1392 EXPECT_EQ("hello!hello!", out.response_data); | 1392 EXPECT_EQ("hello!hello!", out.response_data); |
| 1393 | 1393 |
| 1394 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); | 1394 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); |
| 1395 ASSERT_TRUE(response2 != NULL); | 1395 ASSERT_TRUE(response2 != NULL); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1474 BoundNetLog log; | 1474 BoundNetLog log; |
| 1475 TransactionHelperResult out; | 1475 TransactionHelperResult out; |
| 1476 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 1476 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 1477 BoundNetLog(), GetParam(), NULL); | 1477 BoundNetLog(), GetParam(), NULL); |
| 1478 helper.RunPreTestSetup(); | 1478 helper.RunPreTestSetup(); |
| 1479 helper.AddData(&data); | 1479 helper.AddData(&data); |
| 1480 // We require placeholder data because three get requests are sent out, so | 1480 // We require placeholder data because three get requests are sent out, so |
| 1481 // there needs to be three sets of SSL connection data. | 1481 // there needs to be three sets of SSL connection data. |
| 1482 helper.AddData(&data_placeholder); | 1482 helper.AddData(&data_placeholder); |
| 1483 helper.AddData(&data_placeholder); | 1483 helper.AddData(&data_placeholder); |
| 1484 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, helper.session()); | 1484 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, helper.session().get()); |
| 1485 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, helper.session()); | 1485 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, helper.session().get()); |
| 1486 HttpNetworkTransaction* trans3( | 1486 HttpNetworkTransaction* trans3( |
| 1487 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 1487 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
| 1488 | 1488 |
| 1489 TestCompletionCallback callback1; | 1489 TestCompletionCallback callback1; |
| 1490 TestCompletionCallback callback2; | 1490 TestCompletionCallback callback2; |
| 1491 KillerCallback callback3(trans3); | 1491 KillerCallback callback3(trans3); |
| 1492 | 1492 |
| 1493 HttpRequestInfo httpreq1 = CreateGetRequest(); | 1493 HttpRequestInfo httpreq1 = CreateGetRequest(); |
| 1494 HttpRequestInfo httpreq2 = CreateGetRequest(); | 1494 HttpRequestInfo httpreq2 = CreateGetRequest(); |
| 1495 HttpRequestInfo httpreq3 = CreateGetRequest(); | 1495 HttpRequestInfo httpreq3 = CreateGetRequest(); |
| 1496 | 1496 |
| 1497 out.rv = trans1.Start(&httpreq1, callback1.callback(), log); | 1497 out.rv = trans1.Start(&httpreq1, callback1.callback(), log); |
| 1498 ASSERT_EQ(out.rv, ERR_IO_PENDING); | 1498 ASSERT_EQ(out.rv, ERR_IO_PENDING); |
| 1499 // Run transaction 1 through quickly to force a read of our SETTINGS frame. | 1499 // Run transaction 1 through quickly to force a read of our SETTINGS frame. |
| 1500 out.rv = callback1.WaitForResult(); | 1500 out.rv = callback1.WaitForResult(); |
| 1501 ASSERT_EQ(OK, out.rv); | 1501 ASSERT_EQ(OK, out.rv); |
| 1502 | 1502 |
| 1503 out.rv = trans2.Start(&httpreq2, callback2.callback(), log); | 1503 out.rv = trans2.Start(&httpreq2, callback2.callback(), log); |
| 1504 ASSERT_EQ(out.rv, ERR_IO_PENDING); | 1504 ASSERT_EQ(out.rv, ERR_IO_PENDING); |
| 1505 out.rv = trans3->Start(&httpreq3, callback3.callback(), log); | 1505 out.rv = trans3->Start(&httpreq3, callback3.callback(), log); |
| 1506 ASSERT_EQ(out.rv, ERR_IO_PENDING); | 1506 ASSERT_EQ(out.rv, ERR_IO_PENDING); |
| 1507 out.rv = callback3.WaitForResult(); | 1507 out.rv = callback3.WaitForResult(); |
| 1508 ASSERT_EQ(ERR_ABORTED, out.rv); | 1508 ASSERT_EQ(ERR_ABORTED, out.rv); |
| 1509 | 1509 |
| 1510 EXPECT_EQ(6U, data.read_index()); | 1510 EXPECT_EQ(6U, data.read_index()); |
| 1511 | 1511 |
| 1512 const HttpResponseInfo* response1 = trans1.GetResponseInfo(); | 1512 const HttpResponseInfo* response1 = trans1.GetResponseInfo(); |
| 1513 ASSERT_TRUE(response1 != NULL); | 1513 ASSERT_TRUE(response1 != NULL); |
| 1514 EXPECT_TRUE(response1->headers != NULL); | 1514 EXPECT_TRUE(response1->headers.get() != NULL); |
| 1515 EXPECT_TRUE(response1->was_fetched_via_spdy); | 1515 EXPECT_TRUE(response1->was_fetched_via_spdy); |
| 1516 out.status_line = response1->headers->GetStatusLine(); | 1516 out.status_line = response1->headers->GetStatusLine(); |
| 1517 out.response_info = *response1; | 1517 out.response_info = *response1; |
| 1518 out.rv = ReadTransaction(&trans1, &out.response_data); | 1518 out.rv = ReadTransaction(&trans1, &out.response_data); |
| 1519 EXPECT_EQ(OK, out.rv); | 1519 EXPECT_EQ(OK, out.rv); |
| 1520 | 1520 |
| 1521 const HttpResponseInfo* response2 = trans2.GetResponseInfo(); | 1521 const HttpResponseInfo* response2 = trans2.GetResponseInfo(); |
| 1522 ASSERT_TRUE(response2 != NULL); | 1522 ASSERT_TRUE(response2 != NULL); |
| 1523 out.status_line = response2->headers->GetStatusLine(); | 1523 out.status_line = response2->headers->GetStatusLine(); |
| 1524 out.response_info = *response2; | 1524 out.response_info = *response2; |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2073 HttpNetworkTransaction* trans = helper.trans(); | 2073 HttpNetworkTransaction* trans = helper.trans(); |
| 2074 | 2074 |
| 2075 TestCompletionCallback callback; | 2075 TestCompletionCallback callback; |
| 2076 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); | 2076 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); |
| 2077 EXPECT_EQ(ERR_IO_PENDING, rv); | 2077 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2078 rv = callback.WaitForResult(); | 2078 rv = callback.WaitForResult(); |
| 2079 EXPECT_EQ(OK, rv); | 2079 EXPECT_EQ(OK, rv); |
| 2080 | 2080 |
| 2081 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2081 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 2082 ASSERT_TRUE(response != NULL); | 2082 ASSERT_TRUE(response != NULL); |
| 2083 EXPECT_TRUE(response->headers != NULL); | 2083 EXPECT_TRUE(response->headers.get() != NULL); |
| 2084 EXPECT_TRUE(response->was_fetched_via_spdy); | 2084 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 2085 std::string response_data; | 2085 std::string response_data; |
| 2086 rv = ReadTransaction(trans, &response_data); | 2086 rv = ReadTransaction(trans, &response_data); |
| 2087 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, rv); | 2087 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, rv); |
| 2088 | 2088 |
| 2089 helper.VerifyDataConsumed(); | 2089 helper.VerifyDataConsumed(); |
| 2090 } | 2090 } |
| 2091 | 2091 |
| 2092 // Test that sent data frames and received WINDOW_UPDATE frames change | 2092 // Test that sent data frames and received WINDOW_UPDATE frames change |
| 2093 // the send_window_size_ correctly. | 2093 // the send_window_size_ correctly. |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2246 static_cast<SpdyHttpStream*>(trans->stream_.get()); | 2246 static_cast<SpdyHttpStream*>(trans->stream_.get()); |
| 2247 ASSERT_TRUE(stream != NULL); | 2247 ASSERT_TRUE(stream != NULL); |
| 2248 ASSERT_TRUE(stream->stream() != NULL); | 2248 ASSERT_TRUE(stream->stream() != NULL); |
| 2249 | 2249 |
| 2250 EXPECT_EQ( | 2250 EXPECT_EQ( |
| 2251 static_cast<int>(kSpdyStreamInitialWindowSize - body_data.size()), | 2251 static_cast<int>(kSpdyStreamInitialWindowSize - body_data.size()), |
| 2252 stream->stream()->recv_window_size()); | 2252 stream->stream()->recv_window_size()); |
| 2253 | 2253 |
| 2254 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2254 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 2255 ASSERT_TRUE(response != NULL); | 2255 ASSERT_TRUE(response != NULL); |
| 2256 ASSERT_TRUE(response->headers != NULL); | 2256 ASSERT_TRUE(response->headers.get() != NULL); |
| 2257 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 2257 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 2258 EXPECT_TRUE(response->was_fetched_via_spdy); | 2258 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 2259 | 2259 |
| 2260 // Issue a read which will cause a WINDOW_UPDATE to be sent and window | 2260 // Issue a read which will cause a WINDOW_UPDATE to be sent and window |
| 2261 // size increased to default. | 2261 // size increased to default. |
| 2262 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(body_data.size())); | 2262 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(body_data.size())); |
| 2263 rv = trans->Read(buf, body_data.size(), CompletionCallback()); | 2263 rv = trans->Read(buf.get(), body_data.size(), CompletionCallback()); |
| 2264 EXPECT_EQ(static_cast<int>(body_data.size()), rv); | 2264 EXPECT_EQ(static_cast<int>(body_data.size()), rv); |
| 2265 std::string content(buf->data(), buf->data() + body_data.size()); | 2265 std::string content(buf->data(), buf->data() + body_data.size()); |
| 2266 EXPECT_EQ(body_data, content); | 2266 EXPECT_EQ(body_data, content); |
| 2267 | 2267 |
| 2268 // Schedule the reading of empty data frame with FIN | 2268 // Schedule the reading of empty data frame with FIN |
| 2269 data.CompleteRead(); | 2269 data.CompleteRead(); |
| 2270 | 2270 |
| 2271 // Force write of WINDOW_UPDATE which was scheduled during the above | 2271 // Force write of WINDOW_UPDATE which was scheduled during the above |
| 2272 // read. | 2272 // read. |
| 2273 base::MessageLoop::current()->RunUntilIdle(); | 2273 base::MessageLoop::current()->RunUntilIdle(); |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2870 | 2870 |
| 2871 // Start the transaction with basic parameters. | 2871 // Start the transaction with basic parameters. |
| 2872 TestCompletionCallback callback; | 2872 TestCompletionCallback callback; |
| 2873 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); | 2873 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); |
| 2874 EXPECT_EQ(ERR_IO_PENDING, rv); | 2874 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2875 rv = callback.WaitForResult(); | 2875 rv = callback.WaitForResult(); |
| 2876 | 2876 |
| 2877 const int kSize = 3000; | 2877 const int kSize = 3000; |
| 2878 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSize)); | 2878 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSize)); |
| 2879 rv = trans->Read( | 2879 rv = trans->Read( |
| 2880 buf, kSize, | 2880 buf.get(), |
| 2881 kSize, |
| 2881 base::Bind(&SpdyNetworkTransactionSpdy3Test::StartTransactionCallback, | 2882 base::Bind(&SpdyNetworkTransactionSpdy3Test::StartTransactionCallback, |
| 2882 helper.session())); | 2883 helper.session())); |
| 2883 // This forces an err_IO_pending, which sets the callback. | 2884 // This forces an err_IO_pending, which sets the callback. |
| 2884 data.CompleteRead(); | 2885 data.CompleteRead(); |
| 2885 // This finishes the read. | 2886 // This finishes the read. |
| 2886 data.CompleteRead(); | 2887 data.CompleteRead(); |
| 2887 helper.VerifyDataConsumed(); | 2888 helper.VerifyDataConsumed(); |
| 2888 } | 2889 } |
| 2889 | 2890 |
| 2890 // Verify that the client can correctly deal with the user callback deleting the | 2891 // Verify that the client can correctly deal with the user callback deleting the |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2917 TestCompletionCallback callback; | 2918 TestCompletionCallback callback; |
| 2918 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); | 2919 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); |
| 2919 EXPECT_EQ(ERR_IO_PENDING, rv); | 2920 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2920 rv = callback.WaitForResult(); | 2921 rv = callback.WaitForResult(); |
| 2921 | 2922 |
| 2922 // Setup a user callback which will delete the session, and clear out the | 2923 // Setup a user callback which will delete the session, and clear out the |
| 2923 // memory holding the stream object. Note that the callback deletes trans. | 2924 // memory holding the stream object. Note that the callback deletes trans. |
| 2924 const int kSize = 3000; | 2925 const int kSize = 3000; |
| 2925 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSize)); | 2926 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSize)); |
| 2926 rv = trans->Read( | 2927 rv = trans->Read( |
| 2927 buf, kSize, | 2928 buf.get(), |
| 2929 kSize, |
| 2928 base::Bind(&SpdyNetworkTransactionSpdy3Test::DeleteSessionCallback, | 2930 base::Bind(&SpdyNetworkTransactionSpdy3Test::DeleteSessionCallback, |
| 2929 base::Unretained(&helper))); | 2931 base::Unretained(&helper))); |
| 2930 ASSERT_EQ(ERR_IO_PENDING, rv); | 2932 ASSERT_EQ(ERR_IO_PENDING, rv); |
| 2931 data.CompleteRead(); | 2933 data.CompleteRead(); |
| 2932 | 2934 |
| 2933 // Finish running rest of tasks. | 2935 // Finish running rest of tasks. |
| 2934 base::MessageLoop::current()->RunUntilIdle(); | 2936 base::MessageLoop::current()->RunUntilIdle(); |
| 2935 helper.VerifyDataConsumed(); | 2937 helper.VerifyDataConsumed(); |
| 2936 } | 2938 } |
| 2937 | 2939 |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3332 HttpResponseInfo response2; | 3334 HttpResponseInfo response2; |
| 3333 std::string expected_push_result("pushed"); | 3335 std::string expected_push_result("pushed"); |
| 3334 OrderedSocketData data(reads, arraysize(reads), | 3336 OrderedSocketData data(reads, arraysize(reads), |
| 3335 writes, arraysize(writes)); | 3337 writes, arraysize(writes)); |
| 3336 RunServerPushTest(&data, | 3338 RunServerPushTest(&data, |
| 3337 &response, | 3339 &response, |
| 3338 &response2, | 3340 &response2, |
| 3339 expected_push_result); | 3341 expected_push_result); |
| 3340 | 3342 |
| 3341 // Verify the SYN_REPLY. | 3343 // Verify the SYN_REPLY. |
| 3342 EXPECT_TRUE(response.headers != NULL); | 3344 EXPECT_TRUE(response.headers.get() != NULL); |
| 3343 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3345 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 3344 | 3346 |
| 3345 // Verify the pushed stream. | 3347 // Verify the pushed stream. |
| 3346 EXPECT_TRUE(response2.headers != NULL); | 3348 EXPECT_TRUE(response2.headers.get() != NULL); |
| 3347 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 3349 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
| 3348 } | 3350 } |
| 3349 | 3351 |
| 3350 TEST_P(SpdyNetworkTransactionSpdy3Test, ServerPushBeforeSynReply) { | 3352 TEST_P(SpdyNetworkTransactionSpdy3Test, ServerPushBeforeSynReply) { |
| 3351 static const unsigned char kPushBodyFrame[] = { | 3353 static const unsigned char kPushBodyFrame[] = { |
| 3352 0x00, 0x00, 0x00, 0x02, // header, ID | 3354 0x00, 0x00, 0x00, 0x02, // header, ID |
| 3353 0x01, 0x00, 0x00, 0x06, // FIN, length | 3355 0x01, 0x00, 0x00, 0x06, // FIN, length |
| 3354 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | 3356 'p', 'u', 's', 'h', 'e', 'd' // "pushed" |
| 3355 }; | 3357 }; |
| 3356 scoped_ptr<SpdyFrame> stream1_syn( | 3358 scoped_ptr<SpdyFrame> stream1_syn( |
| (...skipping 24 matching lines...) Expand all Loading... |
| 3381 HttpResponseInfo response2; | 3383 HttpResponseInfo response2; |
| 3382 std::string expected_push_result("pushed"); | 3384 std::string expected_push_result("pushed"); |
| 3383 OrderedSocketData data(reads, arraysize(reads), | 3385 OrderedSocketData data(reads, arraysize(reads), |
| 3384 writes, arraysize(writes)); | 3386 writes, arraysize(writes)); |
| 3385 RunServerPushTest(&data, | 3387 RunServerPushTest(&data, |
| 3386 &response, | 3388 &response, |
| 3387 &response2, | 3389 &response2, |
| 3388 expected_push_result); | 3390 expected_push_result); |
| 3389 | 3391 |
| 3390 // Verify the SYN_REPLY. | 3392 // Verify the SYN_REPLY. |
| 3391 EXPECT_TRUE(response.headers != NULL); | 3393 EXPECT_TRUE(response.headers.get() != NULL); |
| 3392 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3394 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 3393 | 3395 |
| 3394 // Verify the pushed stream. | 3396 // Verify the pushed stream. |
| 3395 EXPECT_TRUE(response2.headers != NULL); | 3397 EXPECT_TRUE(response2.headers.get() != NULL); |
| 3396 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 3398 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
| 3397 } | 3399 } |
| 3398 | 3400 |
| 3399 TEST_P(SpdyNetworkTransactionSpdy3Test, ServerPushSingleDataFrame2) { | 3401 TEST_P(SpdyNetworkTransactionSpdy3Test, ServerPushSingleDataFrame2) { |
| 3400 static const unsigned char kPushBodyFrame[] = { | 3402 static const unsigned char kPushBodyFrame[] = { |
| 3401 0x00, 0x00, 0x00, 0x02, // header, ID | 3403 0x00, 0x00, 0x00, 0x02, // header, ID |
| 3402 0x01, 0x00, 0x00, 0x06, // FIN, length | 3404 0x01, 0x00, 0x00, 0x06, // FIN, length |
| 3403 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | 3405 'p', 'u', 's', 'h', 'e', 'd' // "pushed" |
| 3404 }; | 3406 }; |
| 3405 scoped_ptr<SpdyFrame> stream1_syn( | 3407 scoped_ptr<SpdyFrame> stream1_syn( |
| (...skipping 23 matching lines...) Expand all Loading... |
| 3429 HttpResponseInfo response2; | 3431 HttpResponseInfo response2; |
| 3430 std::string expected_push_result("pushed"); | 3432 std::string expected_push_result("pushed"); |
| 3431 OrderedSocketData data(reads, arraysize(reads), | 3433 OrderedSocketData data(reads, arraysize(reads), |
| 3432 writes, arraysize(writes)); | 3434 writes, arraysize(writes)); |
| 3433 RunServerPushTest(&data, | 3435 RunServerPushTest(&data, |
| 3434 &response, | 3436 &response, |
| 3435 &response2, | 3437 &response2, |
| 3436 expected_push_result); | 3438 expected_push_result); |
| 3437 | 3439 |
| 3438 // Verify the SYN_REPLY. | 3440 // Verify the SYN_REPLY. |
| 3439 EXPECT_TRUE(response.headers != NULL); | 3441 EXPECT_TRUE(response.headers.get() != NULL); |
| 3440 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3442 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 3441 | 3443 |
| 3442 // Verify the pushed stream. | 3444 // Verify the pushed stream. |
| 3443 EXPECT_TRUE(response2.headers != NULL); | 3445 EXPECT_TRUE(response2.headers.get() != NULL); |
| 3444 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 3446 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
| 3445 } | 3447 } |
| 3446 | 3448 |
| 3447 TEST_P(SpdyNetworkTransactionSpdy3Test, ServerPushServerAborted) { | 3449 TEST_P(SpdyNetworkTransactionSpdy3Test, ServerPushServerAborted) { |
| 3448 scoped_ptr<SpdyFrame> stream1_syn( | 3450 scoped_ptr<SpdyFrame> stream1_syn( |
| 3449 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 3451 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 3450 scoped_ptr<SpdyFrame> stream1_body(ConstructSpdyBodyFrame(1, true)); | 3452 scoped_ptr<SpdyFrame> stream1_body(ConstructSpdyBodyFrame(1, true)); |
| 3451 MockWrite writes[] = { | 3453 MockWrite writes[] = { |
| 3452 CreateMockWrite(*stream1_syn, 1), | 3454 CreateMockWrite(*stream1_syn, 1), |
| 3453 }; | 3455 }; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3493 << data.read_count() | 3495 << data.read_count() |
| 3494 << " Read index: " | 3496 << " Read index: " |
| 3495 << data.read_index(); | 3497 << data.read_index(); |
| 3496 EXPECT_TRUE(data.at_write_eof()) << "Write count: " | 3498 EXPECT_TRUE(data.at_write_eof()) << "Write count: " |
| 3497 << data.write_count() | 3499 << data.write_count() |
| 3498 << " Write index: " | 3500 << " Write index: " |
| 3499 << data.write_index(); | 3501 << data.write_index(); |
| 3500 | 3502 |
| 3501 // Verify the SYN_REPLY. | 3503 // Verify the SYN_REPLY. |
| 3502 HttpResponseInfo response = *trans->GetResponseInfo(); | 3504 HttpResponseInfo response = *trans->GetResponseInfo(); |
| 3503 EXPECT_TRUE(response.headers != NULL); | 3505 EXPECT_TRUE(response.headers.get() != NULL); |
| 3504 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3506 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 3505 } | 3507 } |
| 3506 | 3508 |
| 3507 TEST_P(SpdyNetworkTransactionSpdy3Test, ServerPushDuplicate) { | 3509 TEST_P(SpdyNetworkTransactionSpdy3Test, ServerPushDuplicate) { |
| 3508 // Verify that we don't leak streams and that we properly send a reset | 3510 // Verify that we don't leak streams and that we properly send a reset |
| 3509 // if the server pushes the same stream twice. | 3511 // if the server pushes the same stream twice. |
| 3510 static const unsigned char kPushBodyFrame[] = { | 3512 static const unsigned char kPushBodyFrame[] = { |
| 3511 0x00, 0x00, 0x00, 0x02, // header, ID | 3513 0x00, 0x00, 0x00, 0x02, // header, ID |
| 3512 0x01, 0x00, 0x00, 0x06, // FIN, length | 3514 0x01, 0x00, 0x00, 0x06, // FIN, length |
| 3513 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | 3515 'p', 'u', 's', 'h', 'e', 'd' // "pushed" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3551 HttpResponseInfo response2; | 3553 HttpResponseInfo response2; |
| 3552 std::string expected_push_result("pushed"); | 3554 std::string expected_push_result("pushed"); |
| 3553 OrderedSocketData data(reads, arraysize(reads), | 3555 OrderedSocketData data(reads, arraysize(reads), |
| 3554 writes, arraysize(writes)); | 3556 writes, arraysize(writes)); |
| 3555 RunServerPushTest(&data, | 3557 RunServerPushTest(&data, |
| 3556 &response, | 3558 &response, |
| 3557 &response2, | 3559 &response2, |
| 3558 expected_push_result); | 3560 expected_push_result); |
| 3559 | 3561 |
| 3560 // Verify the SYN_REPLY. | 3562 // Verify the SYN_REPLY. |
| 3561 EXPECT_TRUE(response.headers != NULL); | 3563 EXPECT_TRUE(response.headers.get() != NULL); |
| 3562 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3564 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 3563 | 3565 |
| 3564 // Verify the pushed stream. | 3566 // Verify the pushed stream. |
| 3565 EXPECT_TRUE(response2.headers != NULL); | 3567 EXPECT_TRUE(response2.headers.get() != NULL); |
| 3566 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 3568 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
| 3567 } | 3569 } |
| 3568 | 3570 |
| 3569 TEST_P(SpdyNetworkTransactionSpdy3Test, ServerPushMultipleDataFrame) { | 3571 TEST_P(SpdyNetworkTransactionSpdy3Test, ServerPushMultipleDataFrame) { |
| 3570 static const unsigned char kPushBodyFrame1[] = { | 3572 static const unsigned char kPushBodyFrame1[] = { |
| 3571 0x00, 0x00, 0x00, 0x02, // header, ID | 3573 0x00, 0x00, 0x00, 0x02, // header, ID |
| 3572 0x01, 0x00, 0x00, 0x1F, // FIN, length | 3574 0x01, 0x00, 0x00, 0x1F, // FIN, length |
| 3573 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | 3575 'p', 'u', 's', 'h', 'e', 'd' // "pushed" |
| 3574 }; | 3576 }; |
| 3575 static const char kPushBodyFrame2[] = " my darling"; | 3577 static const char kPushBodyFrame2[] = " my darling"; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3610 HttpResponseInfo response2; | 3612 HttpResponseInfo response2; |
| 3611 std::string expected_push_result("pushed my darling hello my baby"); | 3613 std::string expected_push_result("pushed my darling hello my baby"); |
| 3612 OrderedSocketData data(reads, arraysize(reads), | 3614 OrderedSocketData data(reads, arraysize(reads), |
| 3613 writes, arraysize(writes)); | 3615 writes, arraysize(writes)); |
| 3614 RunServerPushTest(&data, | 3616 RunServerPushTest(&data, |
| 3615 &response, | 3617 &response, |
| 3616 &response2, | 3618 &response2, |
| 3617 expected_push_result); | 3619 expected_push_result); |
| 3618 | 3620 |
| 3619 // Verify the SYN_REPLY. | 3621 // Verify the SYN_REPLY. |
| 3620 EXPECT_TRUE(response.headers != NULL); | 3622 EXPECT_TRUE(response.headers.get() != NULL); |
| 3621 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3623 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 3622 | 3624 |
| 3623 // Verify the pushed stream. | 3625 // Verify the pushed stream. |
| 3624 EXPECT_TRUE(response2.headers != NULL); | 3626 EXPECT_TRUE(response2.headers.get() != NULL); |
| 3625 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 3627 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
| 3626 } | 3628 } |
| 3627 | 3629 |
| 3628 TEST_P(SpdyNetworkTransactionSpdy3Test, | 3630 TEST_P(SpdyNetworkTransactionSpdy3Test, |
| 3629 ServerPushMultipleDataFrameInterrupted) { | 3631 ServerPushMultipleDataFrameInterrupted) { |
| 3630 static const unsigned char kPushBodyFrame1[] = { | 3632 static const unsigned char kPushBodyFrame1[] = { |
| 3631 0x00, 0x00, 0x00, 0x02, // header, ID | 3633 0x00, 0x00, 0x00, 0x02, // header, ID |
| 3632 0x01, 0x00, 0x00, 0x1F, // FIN, length | 3634 0x01, 0x00, 0x00, 0x1F, // FIN, length |
| 3633 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | 3635 'p', 'u', 's', 'h', 'e', 'd' // "pushed" |
| 3634 }; | 3636 }; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3671 HttpResponseInfo response2; | 3673 HttpResponseInfo response2; |
| 3672 std::string expected_push_result("pushed my darling hello my baby"); | 3674 std::string expected_push_result("pushed my darling hello my baby"); |
| 3673 OrderedSocketData data(reads, arraysize(reads), | 3675 OrderedSocketData data(reads, arraysize(reads), |
| 3674 writes, arraysize(writes)); | 3676 writes, arraysize(writes)); |
| 3675 RunServerPushTest(&data, | 3677 RunServerPushTest(&data, |
| 3676 &response, | 3678 &response, |
| 3677 &response2, | 3679 &response2, |
| 3678 expected_push_result); | 3680 expected_push_result); |
| 3679 | 3681 |
| 3680 // Verify the SYN_REPLY. | 3682 // Verify the SYN_REPLY. |
| 3681 EXPECT_TRUE(response.headers != NULL); | 3683 EXPECT_TRUE(response.headers.get() != NULL); |
| 3682 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3684 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 3683 | 3685 |
| 3684 // Verify the pushed stream. | 3686 // Verify the pushed stream. |
| 3685 EXPECT_TRUE(response2.headers != NULL); | 3687 EXPECT_TRUE(response2.headers.get() != NULL); |
| 3686 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 3688 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
| 3687 } | 3689 } |
| 3688 | 3690 |
| 3689 TEST_P(SpdyNetworkTransactionSpdy3Test, ServerPushInvalidAssociatedStreamID0) { | 3691 TEST_P(SpdyNetworkTransactionSpdy3Test, ServerPushInvalidAssociatedStreamID0) { |
| 3690 scoped_ptr<SpdyFrame> stream1_syn( | 3692 scoped_ptr<SpdyFrame> stream1_syn( |
| 3691 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 3693 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 3692 scoped_ptr<SpdyFrame> stream1_body(ConstructSpdyBodyFrame(1, true)); | 3694 scoped_ptr<SpdyFrame> stream1_body(ConstructSpdyBodyFrame(1, true)); |
| 3693 scoped_ptr<SpdyFrame> stream2_rst( | 3695 scoped_ptr<SpdyFrame> stream2_rst( |
| 3694 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_REFUSED_STREAM)); | 3696 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_REFUSED_STREAM)); |
| 3695 MockWrite writes[] = { | 3697 MockWrite writes[] = { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3735 << data.read_count() | 3737 << data.read_count() |
| 3736 << " Read index: " | 3738 << " Read index: " |
| 3737 << data.read_index(); | 3739 << data.read_index(); |
| 3738 EXPECT_TRUE(data.at_write_eof()) << "Write count: " | 3740 EXPECT_TRUE(data.at_write_eof()) << "Write count: " |
| 3739 << data.write_count() | 3741 << data.write_count() |
| 3740 << " Write index: " | 3742 << " Write index: " |
| 3741 << data.write_index(); | 3743 << data.write_index(); |
| 3742 | 3744 |
| 3743 // Verify the SYN_REPLY. | 3745 // Verify the SYN_REPLY. |
| 3744 HttpResponseInfo response = *trans->GetResponseInfo(); | 3746 HttpResponseInfo response = *trans->GetResponseInfo(); |
| 3745 EXPECT_TRUE(response.headers != NULL); | 3747 EXPECT_TRUE(response.headers.get() != NULL); |
| 3746 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3748 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 3747 } | 3749 } |
| 3748 | 3750 |
| 3749 TEST_P(SpdyNetworkTransactionSpdy3Test, ServerPushInvalidAssociatedStreamID9) { | 3751 TEST_P(SpdyNetworkTransactionSpdy3Test, ServerPushInvalidAssociatedStreamID9) { |
| 3750 scoped_ptr<SpdyFrame> stream1_syn( | 3752 scoped_ptr<SpdyFrame> stream1_syn( |
| 3751 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 3753 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 3752 scoped_ptr<SpdyFrame> stream1_body(ConstructSpdyBodyFrame(1, true)); | 3754 scoped_ptr<SpdyFrame> stream1_body(ConstructSpdyBodyFrame(1, true)); |
| 3753 scoped_ptr<SpdyFrame> stream2_rst( | 3755 scoped_ptr<SpdyFrame> stream2_rst( |
| 3754 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_INVALID_STREAM)); | 3756 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_INVALID_STREAM)); |
| 3755 MockWrite writes[] = { | 3757 MockWrite writes[] = { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3795 << data.read_count() | 3797 << data.read_count() |
| 3796 << " Read index: " | 3798 << " Read index: " |
| 3797 << data.read_index(); | 3799 << data.read_index(); |
| 3798 EXPECT_TRUE(data.at_write_eof()) << "Write count: " | 3800 EXPECT_TRUE(data.at_write_eof()) << "Write count: " |
| 3799 << data.write_count() | 3801 << data.write_count() |
| 3800 << " Write index: " | 3802 << " Write index: " |
| 3801 << data.write_index(); | 3803 << data.write_index(); |
| 3802 | 3804 |
| 3803 // Verify the SYN_REPLY. | 3805 // Verify the SYN_REPLY. |
| 3804 HttpResponseInfo response = *trans->GetResponseInfo(); | 3806 HttpResponseInfo response = *trans->GetResponseInfo(); |
| 3805 EXPECT_TRUE(response.headers != NULL); | 3807 EXPECT_TRUE(response.headers.get() != NULL); |
| 3806 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3808 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 3807 } | 3809 } |
| 3808 | 3810 |
| 3809 TEST_P(SpdyNetworkTransactionSpdy3Test, ServerPushNoURL) { | 3811 TEST_P(SpdyNetworkTransactionSpdy3Test, ServerPushNoURL) { |
| 3810 scoped_ptr<SpdyFrame> stream1_syn( | 3812 scoped_ptr<SpdyFrame> stream1_syn( |
| 3811 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 3813 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 3812 scoped_ptr<SpdyFrame> stream1_body(ConstructSpdyBodyFrame(1, true)); | 3814 scoped_ptr<SpdyFrame> stream1_body(ConstructSpdyBodyFrame(1, true)); |
| 3813 scoped_ptr<SpdyFrame> stream2_rst( | 3815 scoped_ptr<SpdyFrame> stream2_rst( |
| 3814 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_PROTOCOL_ERROR)); | 3816 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_PROTOCOL_ERROR)); |
| 3815 MockWrite writes[] = { | 3817 MockWrite writes[] = { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3850 << data.read_count() | 3852 << data.read_count() |
| 3851 << " Read index: " | 3853 << " Read index: " |
| 3852 << data.read_index(); | 3854 << data.read_index(); |
| 3853 EXPECT_TRUE(data.at_write_eof()) << "Write count: " | 3855 EXPECT_TRUE(data.at_write_eof()) << "Write count: " |
| 3854 << data.write_count() | 3856 << data.write_count() |
| 3855 << " Write index: " | 3857 << " Write index: " |
| 3856 << data.write_index(); | 3858 << data.write_index(); |
| 3857 | 3859 |
| 3858 // Verify the SYN_REPLY. | 3860 // Verify the SYN_REPLY. |
| 3859 HttpResponseInfo response = *trans->GetResponseInfo(); | 3861 HttpResponseInfo response = *trans->GetResponseInfo(); |
| 3860 EXPECT_TRUE(response.headers != NULL); | 3862 EXPECT_TRUE(response.headers.get() != NULL); |
| 3861 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3863 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 3862 } | 3864 } |
| 3863 | 3865 |
| 3864 // Verify that various SynReply headers parse correctly through the | 3866 // Verify that various SynReply headers parse correctly through the |
| 3865 // HTTP layer. | 3867 // HTTP layer. |
| 3866 TEST_P(SpdyNetworkTransactionSpdy3Test, SynReplyHeaders) { | 3868 TEST_P(SpdyNetworkTransactionSpdy3Test, SynReplyHeaders) { |
| 3867 struct SynReplyHeadersTests { | 3869 struct SynReplyHeadersTests { |
| 3868 int num_headers; | 3870 int num_headers; |
| 3869 const char* extra_headers[5]; | 3871 const char* extra_headers[5]; |
| 3870 const char* expected_headers; | 3872 const char* expected_headers; |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4432 HttpNetworkTransaction* trans = helper.trans(); | 4434 HttpNetworkTransaction* trans = helper.trans(); |
| 4433 int rv = trans->Start( | 4435 int rv = trans->Start( |
| 4434 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 4436 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
| 4435 EXPECT_EQ(ERR_IO_PENDING, rv); | 4437 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4436 | 4438 |
| 4437 TransactionHelperResult out = helper.output(); | 4439 TransactionHelperResult out = helper.output(); |
| 4438 out.rv = callback.WaitForResult(); | 4440 out.rv = callback.WaitForResult(); |
| 4439 EXPECT_EQ(out.rv, OK); | 4441 EXPECT_EQ(out.rv, OK); |
| 4440 | 4442 |
| 4441 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4443 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 4442 EXPECT_TRUE(response->headers != NULL); | 4444 EXPECT_TRUE(response->headers.get() != NULL); |
| 4443 EXPECT_TRUE(response->was_fetched_via_spdy); | 4445 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 4444 out.status_line = response->headers->GetStatusLine(); | 4446 out.status_line = response->headers->GetStatusLine(); |
| 4445 out.response_info = *response; // Make a copy so we can verify. | 4447 out.response_info = *response; // Make a copy so we can verify. |
| 4446 | 4448 |
| 4447 // Read Data | 4449 // Read Data |
| 4448 TestCompletionCallback read_callback; | 4450 TestCompletionCallback read_callback; |
| 4449 | 4451 |
| 4450 std::string content; | 4452 std::string content; |
| 4451 do { | 4453 do { |
| 4452 // Read small chunks at a time. | 4454 // Read small chunks at a time. |
| 4453 const int kSmallReadSize = 3; | 4455 const int kSmallReadSize = 3; |
| 4454 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSmallReadSize)); | 4456 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSmallReadSize)); |
| 4455 rv = trans->Read(buf, kSmallReadSize, read_callback.callback()); | 4457 rv = trans->Read(buf.get(), kSmallReadSize, read_callback.callback()); |
| 4456 if (rv == net::ERR_IO_PENDING) { | 4458 if (rv == net::ERR_IO_PENDING) { |
| 4457 data.CompleteRead(); | 4459 data.CompleteRead(); |
| 4458 rv = read_callback.WaitForResult(); | 4460 rv = read_callback.WaitForResult(); |
| 4459 } | 4461 } |
| 4460 if (rv > 0) { | 4462 if (rv > 0) { |
| 4461 content.append(buf->data(), rv); | 4463 content.append(buf->data(), rv); |
| 4462 } else if (rv < 0) { | 4464 } else if (rv < 0) { |
| 4463 NOTREACHED(); | 4465 NOTREACHED(); |
| 4464 } | 4466 } |
| 4465 } while (rv > 0); | 4467 } while (rv > 0); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4524 TestCompletionCallback callback; | 4526 TestCompletionCallback callback; |
| 4525 int rv = trans->Start( | 4527 int rv = trans->Start( |
| 4526 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 4528 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
| 4527 EXPECT_EQ(ERR_IO_PENDING, rv); | 4529 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4528 | 4530 |
| 4529 TransactionHelperResult out = helper.output(); | 4531 TransactionHelperResult out = helper.output(); |
| 4530 out.rv = callback.WaitForResult(); | 4532 out.rv = callback.WaitForResult(); |
| 4531 EXPECT_EQ(out.rv, OK); | 4533 EXPECT_EQ(out.rv, OK); |
| 4532 | 4534 |
| 4533 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4535 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 4534 EXPECT_TRUE(response->headers != NULL); | 4536 EXPECT_TRUE(response->headers.get() != NULL); |
| 4535 EXPECT_TRUE(response->was_fetched_via_spdy); | 4537 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 4536 out.status_line = response->headers->GetStatusLine(); | 4538 out.status_line = response->headers->GetStatusLine(); |
| 4537 out.response_info = *response; // Make a copy so we can verify. | 4539 out.response_info = *response; // Make a copy so we can verify. |
| 4538 | 4540 |
| 4539 // Read Data | 4541 // Read Data |
| 4540 TestCompletionCallback read_callback; | 4542 TestCompletionCallback read_callback; |
| 4541 | 4543 |
| 4542 std::string content; | 4544 std::string content; |
| 4543 int reads_completed = 0; | 4545 int reads_completed = 0; |
| 4544 do { | 4546 do { |
| 4545 // Read small chunks at a time. | 4547 // Read small chunks at a time. |
| 4546 const int kSmallReadSize = 14; | 4548 const int kSmallReadSize = 14; |
| 4547 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSmallReadSize)); | 4549 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSmallReadSize)); |
| 4548 rv = trans->Read(buf, kSmallReadSize, read_callback.callback()); | 4550 rv = trans->Read(buf.get(), kSmallReadSize, read_callback.callback()); |
| 4549 if (rv == net::ERR_IO_PENDING) { | 4551 if (rv == net::ERR_IO_PENDING) { |
| 4550 data.CompleteRead(); | 4552 data.CompleteRead(); |
| 4551 rv = read_callback.WaitForResult(); | 4553 rv = read_callback.WaitForResult(); |
| 4552 } | 4554 } |
| 4553 if (rv > 0) { | 4555 if (rv > 0) { |
| 4554 EXPECT_EQ(kSmallReadSize, rv); | 4556 EXPECT_EQ(kSmallReadSize, rv); |
| 4555 content.append(buf->data(), rv); | 4557 content.append(buf->data(), rv); |
| 4556 } else if (rv < 0) { | 4558 } else if (rv < 0) { |
| 4557 FAIL() << "Unexpected read error: " << rv; | 4559 FAIL() << "Unexpected read error: " << rv; |
| 4558 } | 4560 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4621 TestCompletionCallback callback; | 4623 TestCompletionCallback callback; |
| 4622 int rv = trans->Start( | 4624 int rv = trans->Start( |
| 4623 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 4625 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
| 4624 EXPECT_EQ(ERR_IO_PENDING, rv); | 4626 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4625 | 4627 |
| 4626 TransactionHelperResult out = helper.output(); | 4628 TransactionHelperResult out = helper.output(); |
| 4627 out.rv = callback.WaitForResult(); | 4629 out.rv = callback.WaitForResult(); |
| 4628 EXPECT_EQ(out.rv, OK); | 4630 EXPECT_EQ(out.rv, OK); |
| 4629 | 4631 |
| 4630 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4632 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 4631 EXPECT_TRUE(response->headers != NULL); | 4633 EXPECT_TRUE(response->headers.get() != NULL); |
| 4632 EXPECT_TRUE(response->was_fetched_via_spdy); | 4634 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 4633 out.status_line = response->headers->GetStatusLine(); | 4635 out.status_line = response->headers->GetStatusLine(); |
| 4634 out.response_info = *response; // Make a copy so we can verify. | 4636 out.response_info = *response; // Make a copy so we can verify. |
| 4635 | 4637 |
| 4636 // Read Data | 4638 // Read Data |
| 4637 TestCompletionCallback read_callback; | 4639 TestCompletionCallback read_callback; |
| 4638 | 4640 |
| 4639 std::string content; | 4641 std::string content; |
| 4640 int reads_completed = 0; | 4642 int reads_completed = 0; |
| 4641 do { | 4643 do { |
| 4642 // Read small chunks at a time. | 4644 // Read small chunks at a time. |
| 4643 const int kSmallReadSize = 14; | 4645 const int kSmallReadSize = 14; |
| 4644 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSmallReadSize)); | 4646 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSmallReadSize)); |
| 4645 rv = trans->Read(buf, kSmallReadSize, read_callback.callback()); | 4647 rv = trans->Read(buf.get(), kSmallReadSize, read_callback.callback()); |
| 4646 if (rv > 0) { | 4648 if (rv > 0) { |
| 4647 EXPECT_EQ(kSmallReadSize, rv); | 4649 EXPECT_EQ(kSmallReadSize, rv); |
| 4648 content.append(buf->data(), rv); | 4650 content.append(buf->data(), rv); |
| 4649 } else if (rv < 0) { | 4651 } else if (rv < 0) { |
| 4650 FAIL() << "Unexpected read error: " << rv; | 4652 FAIL() << "Unexpected read error: " << rv; |
| 4651 } | 4653 } |
| 4652 reads_completed++; | 4654 reads_completed++; |
| 4653 } while (rv > 0); | 4655 } while (rv > 0); |
| 4654 | 4656 |
| 4655 EXPECT_EQ(3, reads_completed); | 4657 EXPECT_EQ(3, reads_completed); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4711 | 4713 |
| 4712 int rv = trans->Start( | 4714 int rv = trans->Start( |
| 4713 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 4715 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
| 4714 EXPECT_EQ(ERR_IO_PENDING, rv); | 4716 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4715 | 4717 |
| 4716 TransactionHelperResult out = helper.output(); | 4718 TransactionHelperResult out = helper.output(); |
| 4717 out.rv = callback.WaitForResult(); | 4719 out.rv = callback.WaitForResult(); |
| 4718 EXPECT_EQ(out.rv, OK); | 4720 EXPECT_EQ(out.rv, OK); |
| 4719 | 4721 |
| 4720 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4722 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 4721 EXPECT_TRUE(response->headers != NULL); | 4723 EXPECT_TRUE(response->headers.get() != NULL); |
| 4722 EXPECT_TRUE(response->was_fetched_via_spdy); | 4724 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 4723 out.status_line = response->headers->GetStatusLine(); | 4725 out.status_line = response->headers->GetStatusLine(); |
| 4724 out.response_info = *response; // Make a copy so we can verify. | 4726 out.response_info = *response; // Make a copy so we can verify. |
| 4725 | 4727 |
| 4726 // Read Data | 4728 // Read Data |
| 4727 TestCompletionCallback read_callback; | 4729 TestCompletionCallback read_callback; |
| 4728 | 4730 |
| 4729 std::string content; | 4731 std::string content; |
| 4730 int reads_completed = 0; | 4732 int reads_completed = 0; |
| 4731 do { | 4733 do { |
| 4732 // Read small chunks at a time. | 4734 // Read small chunks at a time. |
| 4733 const int kSmallReadSize = 14; | 4735 const int kSmallReadSize = 14; |
| 4734 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSmallReadSize)); | 4736 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSmallReadSize)); |
| 4735 rv = trans->Read(buf, kSmallReadSize, read_callback.callback()); | 4737 rv = trans->Read(buf.get(), kSmallReadSize, read_callback.callback()); |
| 4736 if (rv == net::ERR_IO_PENDING) { | 4738 if (rv == net::ERR_IO_PENDING) { |
| 4737 data.CompleteRead(); | 4739 data.CompleteRead(); |
| 4738 rv = read_callback.WaitForResult(); | 4740 rv = read_callback.WaitForResult(); |
| 4739 } | 4741 } |
| 4740 if (rv > 0) { | 4742 if (rv > 0) { |
| 4741 content.append(buf->data(), rv); | 4743 content.append(buf->data(), rv); |
| 4742 } else if (rv < 0) { | 4744 } else if (rv < 0) { |
| 4743 // This test intentionally closes the connection, and will get an error. | 4745 // This test intentionally closes the connection, and will get an error. |
| 4744 EXPECT_EQ(ERR_CONNECTION_CLOSED, rv); | 4746 EXPECT_EQ(ERR_CONNECTION_CLOSED, rv); |
| 4745 break; | 4747 break; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4791 | 4793 |
| 4792 int rv = trans->Start( | 4794 int rv = trans->Start( |
| 4793 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 4795 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
| 4794 EXPECT_EQ(ERR_IO_PENDING, rv); | 4796 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4795 | 4797 |
| 4796 TransactionHelperResult out = helper.output(); | 4798 TransactionHelperResult out = helper.output(); |
| 4797 out.rv = callback.WaitForResult(); | 4799 out.rv = callback.WaitForResult(); |
| 4798 EXPECT_EQ(out.rv, OK); | 4800 EXPECT_EQ(out.rv, OK); |
| 4799 | 4801 |
| 4800 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4802 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 4801 EXPECT_TRUE(response->headers != NULL); | 4803 EXPECT_TRUE(response->headers.get() != NULL); |
| 4802 EXPECT_TRUE(response->was_fetched_via_spdy); | 4804 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 4803 out.status_line = response->headers->GetStatusLine(); | 4805 out.status_line = response->headers->GetStatusLine(); |
| 4804 out.response_info = *response; // Make a copy so we can verify. | 4806 out.response_info = *response; // Make a copy so we can verify. |
| 4805 | 4807 |
| 4806 // Read Data | 4808 // Read Data |
| 4807 TestCompletionCallback read_callback; | 4809 TestCompletionCallback read_callback; |
| 4808 | 4810 |
| 4809 do { | 4811 do { |
| 4810 const int kReadSize = 256; | 4812 const int kReadSize = 256; |
| 4811 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kReadSize)); | 4813 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kReadSize)); |
| 4812 rv = trans->Read(buf, kReadSize, read_callback.callback()); | 4814 rv = trans->Read(buf.get(), kReadSize, read_callback.callback()); |
| 4813 if (rv == net::ERR_IO_PENDING) { | 4815 if (rv == net::ERR_IO_PENDING) { |
| 4814 // Complete the read now, which causes buffering to start. | 4816 // Complete the read now, which causes buffering to start. |
| 4815 data.CompleteRead(); | 4817 data.CompleteRead(); |
| 4816 // Destroy the transaction, causing the stream to get cancelled | 4818 // Destroy the transaction, causing the stream to get cancelled |
| 4817 // and orphaning the buffered IO task. | 4819 // and orphaning the buffered IO task. |
| 4818 helper.ResetTrans(); | 4820 helper.ResetTrans(); |
| 4819 break; | 4821 break; |
| 4820 } | 4822 } |
| 4821 // We shouldn't get here in this test. | 4823 // We shouldn't get here in this test. |
| 4822 FAIL() << "Unexpected read: " << rv; | 4824 FAIL() << "Unexpected read: " << rv; |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5099 | 5101 |
| 5100 TestCompletionCallback callback; | 5102 TestCompletionCallback callback; |
| 5101 TransactionHelperResult out; | 5103 TransactionHelperResult out; |
| 5102 out.rv = trans->Start(&CreateGetRequest(), callback.callback(), log); | 5104 out.rv = trans->Start(&CreateGetRequest(), callback.callback(), log); |
| 5103 | 5105 |
| 5104 EXPECT_EQ(out.rv, ERR_IO_PENDING); | 5106 EXPECT_EQ(out.rv, ERR_IO_PENDING); |
| 5105 out.rv = callback.WaitForResult(); | 5107 out.rv = callback.WaitForResult(); |
| 5106 EXPECT_EQ(out.rv, OK); | 5108 EXPECT_EQ(out.rv, OK); |
| 5107 | 5109 |
| 5108 const HttpResponseInfo* response = trans->GetResponseInfo(); | 5110 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 5109 EXPECT_TRUE(response->headers != NULL); | 5111 EXPECT_TRUE(response->headers.get() != NULL); |
| 5110 EXPECT_TRUE(response->was_fetched_via_spdy); | 5112 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 5111 out.rv = ReadTransaction(trans, &out.response_data); | 5113 out.rv = ReadTransaction(trans, &out.response_data); |
| 5112 EXPECT_EQ(ERR_CONNECTION_CLOSED, out.rv); | 5114 EXPECT_EQ(ERR_CONNECTION_CLOSED, out.rv); |
| 5113 | 5115 |
| 5114 // Verify that we consumed all test data. | 5116 // Verify that we consumed all test data. |
| 5115 helper.VerifyDataConsumed(); | 5117 helper.VerifyDataConsumed(); |
| 5116 } | 5118 } |
| 5117 | 5119 |
| 5118 // Test to make sure we can correctly connect through a proxy. | 5120 // Test to make sure we can correctly connect through a proxy. |
| 5119 TEST_P(SpdyNetworkTransactionSpdy3Test, ProxyConnect) { | 5121 TEST_P(SpdyNetworkTransactionSpdy3Test, ProxyConnect) { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5199 | 5201 |
| 5200 int rv = trans->Start( | 5202 int rv = trans->Start( |
| 5201 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 5203 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
| 5202 EXPECT_EQ(ERR_IO_PENDING, rv); | 5204 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5203 | 5205 |
| 5204 rv = callback.WaitForResult(); | 5206 rv = callback.WaitForResult(); |
| 5205 EXPECT_EQ(0, rv); | 5207 EXPECT_EQ(0, rv); |
| 5206 | 5208 |
| 5207 // Verify the SYN_REPLY. | 5209 // Verify the SYN_REPLY. |
| 5208 HttpResponseInfo response = *trans->GetResponseInfo(); | 5210 HttpResponseInfo response = *trans->GetResponseInfo(); |
| 5209 EXPECT_TRUE(response.headers != NULL); | 5211 EXPECT_TRUE(response.headers.get() != NULL); |
| 5210 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5212 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 5211 | 5213 |
| 5212 std::string response_data; | 5214 std::string response_data; |
| 5213 ASSERT_EQ(OK, ReadTransaction(trans, &response_data)); | 5215 ASSERT_EQ(OK, ReadTransaction(trans, &response_data)); |
| 5214 EXPECT_EQ("hello!", response_data); | 5216 EXPECT_EQ("hello!", response_data); |
| 5215 helper.VerifyDataConsumed(); | 5217 helper.VerifyDataConsumed(); |
| 5216 } | 5218 } |
| 5217 | 5219 |
| 5218 // Test to make sure we can correctly connect through a proxy to www.google.com, | 5220 // Test to make sure we can correctly connect through a proxy to www.google.com, |
| 5219 // if there already exists a direct spdy connection to www.google.com. See | 5221 // if there already exists a direct spdy connection to www.google.com. See |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5259 TestCompletionCallback callback; | 5261 TestCompletionCallback callback; |
| 5260 TransactionHelperResult out; | 5262 TransactionHelperResult out; |
| 5261 out.rv = trans->Start( | 5263 out.rv = trans->Start( |
| 5262 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 5264 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
| 5263 | 5265 |
| 5264 EXPECT_EQ(out.rv, ERR_IO_PENDING); | 5266 EXPECT_EQ(out.rv, ERR_IO_PENDING); |
| 5265 out.rv = callback.WaitForResult(); | 5267 out.rv = callback.WaitForResult(); |
| 5266 EXPECT_EQ(out.rv, OK); | 5268 EXPECT_EQ(out.rv, OK); |
| 5267 | 5269 |
| 5268 const HttpResponseInfo* response = trans->GetResponseInfo(); | 5270 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 5269 EXPECT_TRUE(response->headers != NULL); | 5271 EXPECT_TRUE(response->headers.get() != NULL); |
| 5270 EXPECT_TRUE(response->was_fetched_via_spdy); | 5272 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 5271 out.rv = ReadTransaction(trans, &out.response_data); | 5273 out.rv = ReadTransaction(trans, &out.response_data); |
| 5272 EXPECT_EQ(OK, out.rv); | 5274 EXPECT_EQ(OK, out.rv); |
| 5273 out.status_line = response->headers->GetStatusLine(); | 5275 out.status_line = response->headers->GetStatusLine(); |
| 5274 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 5276 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
| 5275 EXPECT_EQ("hello!", out.response_data); | 5277 EXPECT_EQ("hello!", out.response_data); |
| 5276 | 5278 |
| 5277 // Check that the SpdySession is still in the SpdySessionPool. | 5279 // Check that the SpdySession is still in the SpdySessionPool. |
| 5278 HostPortPair host_port_pair("www.google.com", helper.port()); | 5280 HostPortPair host_port_pair("www.google.com", helper.port()); |
| 5279 SpdySessionKey session_pool_key_direct( | 5281 SpdySessionKey session_pool_key_direct( |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5376 | 5378 |
| 5377 HttpNetworkTransaction* trans_proxy = helper_proxy.trans(); | 5379 HttpNetworkTransaction* trans_proxy = helper_proxy.trans(); |
| 5378 TestCompletionCallback callback_proxy; | 5380 TestCompletionCallback callback_proxy; |
| 5379 int rv = trans_proxy->Start( | 5381 int rv = trans_proxy->Start( |
| 5380 &request_proxy, callback_proxy.callback(), BoundNetLog()); | 5382 &request_proxy, callback_proxy.callback(), BoundNetLog()); |
| 5381 EXPECT_EQ(ERR_IO_PENDING, rv); | 5383 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5382 rv = callback_proxy.WaitForResult(); | 5384 rv = callback_proxy.WaitForResult(); |
| 5383 EXPECT_EQ(0, rv); | 5385 EXPECT_EQ(0, rv); |
| 5384 | 5386 |
| 5385 HttpResponseInfo response_proxy = *trans_proxy->GetResponseInfo(); | 5387 HttpResponseInfo response_proxy = *trans_proxy->GetResponseInfo(); |
| 5386 EXPECT_TRUE(response_proxy.headers != NULL); | 5388 EXPECT_TRUE(response_proxy.headers.get() != NULL); |
| 5387 EXPECT_EQ("HTTP/1.1 200 OK", response_proxy.headers->GetStatusLine()); | 5389 EXPECT_EQ("HTTP/1.1 200 OK", response_proxy.headers->GetStatusLine()); |
| 5388 | 5390 |
| 5389 std::string response_data; | 5391 std::string response_data; |
| 5390 ASSERT_EQ(OK, ReadTransaction(trans_proxy, &response_data)); | 5392 ASSERT_EQ(OK, ReadTransaction(trans_proxy, &response_data)); |
| 5391 EXPECT_EQ("hello!", response_data); | 5393 EXPECT_EQ("hello!", response_data); |
| 5392 | 5394 |
| 5393 data.CompleteRead(); | 5395 data.CompleteRead(); |
| 5394 helper_proxy.VerifyDataConsumed(); | 5396 helper_proxy.VerifyDataConsumed(); |
| 5395 } | 5397 } |
| 5396 | 5398 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5431 DelayedSocketData data2(1, reads2, arraysize(reads2), NULL, 0); | 5433 DelayedSocketData data2(1, reads2, arraysize(reads2), NULL, 0); |
| 5432 | 5434 |
| 5433 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 5435 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 5434 BoundNetLog(), GetParam(), NULL); | 5436 BoundNetLog(), GetParam(), NULL); |
| 5435 helper.AddData(&data1); | 5437 helper.AddData(&data1); |
| 5436 helper.AddData(&data2); | 5438 helper.AddData(&data2); |
| 5437 helper.RunPreTestSetup(); | 5439 helper.RunPreTestSetup(); |
| 5438 | 5440 |
| 5439 for (int i = 0; i < 2; ++i) { | 5441 for (int i = 0; i < 2; ++i) { |
| 5440 scoped_ptr<HttpNetworkTransaction> trans( | 5442 scoped_ptr<HttpNetworkTransaction> trans( |
| 5441 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 5443 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
| 5442 | 5444 |
| 5443 TestCompletionCallback callback; | 5445 TestCompletionCallback callback; |
| 5444 int rv = trans->Start( | 5446 int rv = trans->Start( |
| 5445 &helper.request(), callback.callback(), BoundNetLog()); | 5447 &helper.request(), callback.callback(), BoundNetLog()); |
| 5446 EXPECT_EQ(ERR_IO_PENDING, rv); | 5448 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5447 // On the second transaction, we trigger the RST. | 5449 // On the second transaction, we trigger the RST. |
| 5448 if (i == 1) { | 5450 if (i == 1) { |
| 5449 if (variant == VARIANT_RST_DURING_READ_COMPLETION) { | 5451 if (variant == VARIANT_RST_DURING_READ_COMPLETION) { |
| 5450 // Writes to the socket complete asynchronously on SPDY by running | 5452 // Writes to the socket complete asynchronously on SPDY by running |
| 5451 // through the message loop. Complete the write here. | 5453 // through the message loop. Complete the write here. |
| 5452 base::MessageLoop::current()->RunUntilIdle(); | 5454 base::MessageLoop::current()->RunUntilIdle(); |
| 5453 } | 5455 } |
| 5454 | 5456 |
| 5455 // Now schedule the ERR_CONNECTION_RESET. | 5457 // Now schedule the ERR_CONNECTION_RESET. |
| 5456 EXPECT_EQ(3u, data1.read_index()); | 5458 EXPECT_EQ(3u, data1.read_index()); |
| 5457 data1.CompleteRead(); | 5459 data1.CompleteRead(); |
| 5458 EXPECT_EQ(4u, data1.read_index()); | 5460 EXPECT_EQ(4u, data1.read_index()); |
| 5459 } | 5461 } |
| 5460 rv = callback.WaitForResult(); | 5462 rv = callback.WaitForResult(); |
| 5461 EXPECT_EQ(OK, rv); | 5463 EXPECT_EQ(OK, rv); |
| 5462 | 5464 |
| 5463 const HttpResponseInfo* response = trans->GetResponseInfo(); | 5465 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 5464 ASSERT_TRUE(response != NULL); | 5466 ASSERT_TRUE(response != NULL); |
| 5465 EXPECT_TRUE(response->headers != NULL); | 5467 EXPECT_TRUE(response->headers.get() != NULL); |
| 5466 EXPECT_TRUE(response->was_fetched_via_spdy); | 5468 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 5467 std::string response_data; | 5469 std::string response_data; |
| 5468 rv = ReadTransaction(trans.get(), &response_data); | 5470 rv = ReadTransaction(trans.get(), &response_data); |
| 5469 EXPECT_EQ(OK, rv); | 5471 EXPECT_EQ(OK, rv); |
| 5470 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 5472 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 5471 EXPECT_EQ("hello!", response_data); | 5473 EXPECT_EQ("hello!", response_data); |
| 5472 } | 5474 } |
| 5473 | 5475 |
| 5474 helper.VerifyDataConsumed(); | 5476 helper.VerifyDataConsumed(); |
| 5475 } | 5477 } |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5576 HttpNetworkTransaction* trans = helper.trans(); | 5578 HttpNetworkTransaction* trans = helper.trans(); |
| 5577 TestCompletionCallback callback; | 5579 TestCompletionCallback callback; |
| 5578 const int rv_start = trans->Start(&request, callback.callback(), net_log); | 5580 const int rv_start = trans->Start(&request, callback.callback(), net_log); |
| 5579 EXPECT_EQ(ERR_IO_PENDING, rv_start); | 5581 EXPECT_EQ(ERR_IO_PENDING, rv_start); |
| 5580 const int rv_start_complete = callback.WaitForResult(); | 5582 const int rv_start_complete = callback.WaitForResult(); |
| 5581 EXPECT_EQ(OK, rv_start_complete); | 5583 EXPECT_EQ(OK, rv_start_complete); |
| 5582 | 5584 |
| 5583 // Make sure the response has an auth challenge. | 5585 // Make sure the response has an auth challenge. |
| 5584 const HttpResponseInfo* const response_start = trans->GetResponseInfo(); | 5586 const HttpResponseInfo* const response_start = trans->GetResponseInfo(); |
| 5585 ASSERT_TRUE(response_start != NULL); | 5587 ASSERT_TRUE(response_start != NULL); |
| 5586 ASSERT_TRUE(response_start->headers != NULL); | 5588 ASSERT_TRUE(response_start->headers.get() != NULL); |
| 5587 EXPECT_EQ(401, response_start->headers->response_code()); | 5589 EXPECT_EQ(401, response_start->headers->response_code()); |
| 5588 EXPECT_TRUE(response_start->was_fetched_via_spdy); | 5590 EXPECT_TRUE(response_start->was_fetched_via_spdy); |
| 5589 AuthChallengeInfo* auth_challenge = response_start->auth_challenge.get(); | 5591 AuthChallengeInfo* auth_challenge = response_start->auth_challenge.get(); |
| 5590 ASSERT_TRUE(auth_challenge != NULL); | 5592 ASSERT_TRUE(auth_challenge != NULL); |
| 5591 EXPECT_FALSE(auth_challenge->is_proxy); | 5593 EXPECT_FALSE(auth_challenge->is_proxy); |
| 5592 EXPECT_EQ("basic", auth_challenge->scheme); | 5594 EXPECT_EQ("basic", auth_challenge->scheme); |
| 5593 EXPECT_EQ("MyRealm", auth_challenge->realm); | 5595 EXPECT_EQ("MyRealm", auth_challenge->realm); |
| 5594 | 5596 |
| 5595 // Restart with a username/password. | 5597 // Restart with a username/password. |
| 5596 AuthCredentials credentials(ASCIIToUTF16("foo"), ASCIIToUTF16("bar")); | 5598 AuthCredentials credentials(ASCIIToUTF16("foo"), ASCIIToUTF16("bar")); |
| 5597 TestCompletionCallback callback_restart; | 5599 TestCompletionCallback callback_restart; |
| 5598 const int rv_restart = trans->RestartWithAuth( | 5600 const int rv_restart = trans->RestartWithAuth( |
| 5599 credentials, callback_restart.callback()); | 5601 credentials, callback_restart.callback()); |
| 5600 EXPECT_EQ(ERR_IO_PENDING, rv_restart); | 5602 EXPECT_EQ(ERR_IO_PENDING, rv_restart); |
| 5601 const int rv_restart_complete = callback_restart.WaitForResult(); | 5603 const int rv_restart_complete = callback_restart.WaitForResult(); |
| 5602 EXPECT_EQ(OK, rv_restart_complete); | 5604 EXPECT_EQ(OK, rv_restart_complete); |
| 5603 // TODO(cbentzel): This is actually the same response object as before, but | 5605 // TODO(cbentzel): This is actually the same response object as before, but |
| 5604 // data has changed. | 5606 // data has changed. |
| 5605 const HttpResponseInfo* const response_restart = trans->GetResponseInfo(); | 5607 const HttpResponseInfo* const response_restart = trans->GetResponseInfo(); |
| 5606 ASSERT_TRUE(response_restart != NULL); | 5608 ASSERT_TRUE(response_restart != NULL); |
| 5607 ASSERT_TRUE(response_restart->headers != NULL); | 5609 ASSERT_TRUE(response_restart->headers.get() != NULL); |
| 5608 EXPECT_EQ(200, response_restart->headers->response_code()); | 5610 EXPECT_EQ(200, response_restart->headers->response_code()); |
| 5609 EXPECT_TRUE(response_restart->auth_challenge.get() == NULL); | 5611 EXPECT_TRUE(response_restart->auth_challenge.get() == NULL); |
| 5610 } | 5612 } |
| 5611 | 5613 |
| 5612 TEST_P(SpdyNetworkTransactionSpdy3Test, ServerPushWithHeaders) { | 5614 TEST_P(SpdyNetworkTransactionSpdy3Test, ServerPushWithHeaders) { |
| 5613 static const unsigned char kPushBodyFrame[] = { | 5615 static const unsigned char kPushBodyFrame[] = { |
| 5614 0x00, 0x00, 0x00, 0x02, // header, ID | 5616 0x00, 0x00, 0x00, 0x02, // header, ID |
| 5615 0x01, 0x00, 0x00, 0x06, // FIN, length | 5617 0x01, 0x00, 0x00, 0x06, // FIN, length |
| 5616 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | 5618 'p', 'u', 's', 'h', 'e', 'd' // "pushed" |
| 5617 }; | 5619 }; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5674 HttpResponseInfo response2; | 5676 HttpResponseInfo response2; |
| 5675 std::string expected_push_result("pushed"); | 5677 std::string expected_push_result("pushed"); |
| 5676 OrderedSocketData data(reads, arraysize(reads), | 5678 OrderedSocketData data(reads, arraysize(reads), |
| 5677 writes, arraysize(writes)); | 5679 writes, arraysize(writes)); |
| 5678 RunServerPushTest(&data, | 5680 RunServerPushTest(&data, |
| 5679 &response, | 5681 &response, |
| 5680 &response2, | 5682 &response2, |
| 5681 expected_push_result); | 5683 expected_push_result); |
| 5682 | 5684 |
| 5683 // Verify the SYN_REPLY. | 5685 // Verify the SYN_REPLY. |
| 5684 EXPECT_TRUE(response.headers != NULL); | 5686 EXPECT_TRUE(response.headers.get() != NULL); |
| 5685 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5687 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 5686 | 5688 |
| 5687 // Verify the pushed stream. | 5689 // Verify the pushed stream. |
| 5688 EXPECT_TRUE(response2.headers != NULL); | 5690 EXPECT_TRUE(response2.headers.get() != NULL); |
| 5689 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 5691 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
| 5690 } | 5692 } |
| 5691 | 5693 |
| 5692 TEST_P(SpdyNetworkTransactionSpdy3Test, ServerPushClaimBeforeHeaders) { | 5694 TEST_P(SpdyNetworkTransactionSpdy3Test, ServerPushClaimBeforeHeaders) { |
| 5693 // We push a stream and attempt to claim it before the headers come down. | 5695 // We push a stream and attempt to claim it before the headers come down. |
| 5694 static const unsigned char kPushBodyFrame[] = { | 5696 static const unsigned char kPushBodyFrame[] = { |
| 5695 0x00, 0x00, 0x00, 0x02, // header, ID | 5697 0x00, 0x00, 0x00, 0x02, // header, ID |
| 5696 0x01, 0x00, 0x00, 0x06, // FIN, length | 5698 0x01, 0x00, 0x00, 0x06, // FIN, length |
| 5697 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | 5699 'p', 'u', 's', 'h', 'e', 'd' // "pushed" |
| 5698 }; | 5700 }; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5775 int rv = trans->Start( | 5777 int rv = trans->Start( |
| 5776 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 5778 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
| 5777 EXPECT_EQ(ERR_IO_PENDING, rv); | 5779 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5778 data.Run(); | 5780 data.Run(); |
| 5779 rv = callback.WaitForResult(); | 5781 rv = callback.WaitForResult(); |
| 5780 EXPECT_EQ(0, rv); | 5782 EXPECT_EQ(0, rv); |
| 5781 | 5783 |
| 5782 // Request the pushed path. At this point, we've received the push, but the | 5784 // Request the pushed path. At this point, we've received the push, but the |
| 5783 // headers are not yet complete. | 5785 // headers are not yet complete. |
| 5784 scoped_ptr<HttpNetworkTransaction> trans2( | 5786 scoped_ptr<HttpNetworkTransaction> trans2( |
| 5785 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 5787 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
| 5786 rv = trans2->Start( | 5788 rv = trans2->Start( |
| 5787 &CreateGetPushRequest(), callback.callback(), BoundNetLog()); | 5789 &CreateGetPushRequest(), callback.callback(), BoundNetLog()); |
| 5788 EXPECT_EQ(ERR_IO_PENDING, rv); | 5790 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5789 data.RunFor(3); | 5791 data.RunFor(3); |
| 5790 base::MessageLoop::current()->RunUntilIdle(); | 5792 base::MessageLoop::current()->RunUntilIdle(); |
| 5791 | 5793 |
| 5792 // Read the server push body. | 5794 // Read the server push body. |
| 5793 std::string result2; | 5795 std::string result2; |
| 5794 ReadResult(trans2.get(), &data, &result2); | 5796 ReadResult(trans2.get(), &data, &result2); |
| 5795 // Read the response body. | 5797 // Read the response body. |
| 5796 std::string result; | 5798 std::string result; |
| 5797 ReadResult(trans, &data, &result); | 5799 ReadResult(trans, &data, &result); |
| 5798 | 5800 |
| 5799 // Verify that the received push data is same as the expected push data. | 5801 // Verify that the received push data is same as the expected push data. |
| 5800 EXPECT_EQ(result2.compare(expected_push_result), 0) | 5802 EXPECT_EQ(result2.compare(expected_push_result), 0) |
| 5801 << "Received data: " | 5803 << "Received data: " |
| 5802 << result2 | 5804 << result2 |
| 5803 << "||||| Expected data: " | 5805 << "||||| Expected data: " |
| 5804 << expected_push_result; | 5806 << expected_push_result; |
| 5805 | 5807 |
| 5806 // Verify the SYN_REPLY. | 5808 // Verify the SYN_REPLY. |
| 5807 // Copy the response info, because trans goes away. | 5809 // Copy the response info, because trans goes away. |
| 5808 response = *trans->GetResponseInfo(); | 5810 response = *trans->GetResponseInfo(); |
| 5809 response2 = *trans2->GetResponseInfo(); | 5811 response2 = *trans2->GetResponseInfo(); |
| 5810 | 5812 |
| 5811 VerifyStreamsClosed(helper); | 5813 VerifyStreamsClosed(helper); |
| 5812 | 5814 |
| 5813 // Verify the SYN_REPLY. | 5815 // Verify the SYN_REPLY. |
| 5814 EXPECT_TRUE(response.headers != NULL); | 5816 EXPECT_TRUE(response.headers.get() != NULL); |
| 5815 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5817 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 5816 | 5818 |
| 5817 // Verify the pushed stream. | 5819 // Verify the pushed stream. |
| 5818 EXPECT_TRUE(response2.headers != NULL); | 5820 EXPECT_TRUE(response2.headers.get() != NULL); |
| 5819 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 5821 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
| 5820 | 5822 |
| 5821 // Read the final EOF (which will close the session) | 5823 // Read the final EOF (which will close the session) |
| 5822 data.RunFor(1); | 5824 data.RunFor(1); |
| 5823 | 5825 |
| 5824 // Verify that we consumed all test data. | 5826 // Verify that we consumed all test data. |
| 5825 EXPECT_TRUE(data.at_read_eof()); | 5827 EXPECT_TRUE(data.at_read_eof()); |
| 5826 EXPECT_TRUE(data.at_write_eof()); | 5828 EXPECT_TRUE(data.at_write_eof()); |
| 5827 } | 5829 } |
| 5828 | 5830 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5926 int rv = trans->Start( | 5928 int rv = trans->Start( |
| 5927 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 5929 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
| 5928 EXPECT_EQ(ERR_IO_PENDING, rv); | 5930 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5929 data.Run(); | 5931 data.Run(); |
| 5930 rv = callback.WaitForResult(); | 5932 rv = callback.WaitForResult(); |
| 5931 EXPECT_EQ(0, rv); | 5933 EXPECT_EQ(0, rv); |
| 5932 | 5934 |
| 5933 // Request the pushed path. At this point, we've received the push, but the | 5935 // Request the pushed path. At this point, we've received the push, but the |
| 5934 // headers are not yet complete. | 5936 // headers are not yet complete. |
| 5935 scoped_ptr<HttpNetworkTransaction> trans2( | 5937 scoped_ptr<HttpNetworkTransaction> trans2( |
| 5936 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 5938 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
| 5937 rv = trans2->Start( | 5939 rv = trans2->Start( |
| 5938 &CreateGetPushRequest(), callback.callback(), BoundNetLog()); | 5940 &CreateGetPushRequest(), callback.callback(), BoundNetLog()); |
| 5939 EXPECT_EQ(ERR_IO_PENDING, rv); | 5941 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5940 data.RunFor(3); | 5942 data.RunFor(3); |
| 5941 base::MessageLoop::current()->RunUntilIdle(); | 5943 base::MessageLoop::current()->RunUntilIdle(); |
| 5942 | 5944 |
| 5943 // Read the server push body. | 5945 // Read the server push body. |
| 5944 std::string result2; | 5946 std::string result2; |
| 5945 ReadResult(trans2.get(), &data, &result2); | 5947 ReadResult(trans2.get(), &data, &result2); |
| 5946 // Read the response body. | 5948 // Read the response body. |
| 5947 std::string result; | 5949 std::string result; |
| 5948 ReadResult(trans, &data, &result); | 5950 ReadResult(trans, &data, &result); |
| 5949 | 5951 |
| 5950 // Verify that the received push data is same as the expected push data. | 5952 // Verify that the received push data is same as the expected push data. |
| 5951 EXPECT_EQ(result2.compare(expected_push_result), 0) | 5953 EXPECT_EQ(result2.compare(expected_push_result), 0) |
| 5952 << "Received data: " | 5954 << "Received data: " |
| 5953 << result2 | 5955 << result2 |
| 5954 << "||||| Expected data: " | 5956 << "||||| Expected data: " |
| 5955 << expected_push_result; | 5957 << expected_push_result; |
| 5956 | 5958 |
| 5957 // Verify the SYN_REPLY. | 5959 // Verify the SYN_REPLY. |
| 5958 // Copy the response info, because trans goes away. | 5960 // Copy the response info, because trans goes away. |
| 5959 response = *trans->GetResponseInfo(); | 5961 response = *trans->GetResponseInfo(); |
| 5960 response2 = *trans2->GetResponseInfo(); | 5962 response2 = *trans2->GetResponseInfo(); |
| 5961 | 5963 |
| 5962 VerifyStreamsClosed(helper); | 5964 VerifyStreamsClosed(helper); |
| 5963 | 5965 |
| 5964 // Verify the SYN_REPLY. | 5966 // Verify the SYN_REPLY. |
| 5965 EXPECT_TRUE(response.headers != NULL); | 5967 EXPECT_TRUE(response.headers.get() != NULL); |
| 5966 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5968 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 5967 | 5969 |
| 5968 // Verify the pushed stream. | 5970 // Verify the pushed stream. |
| 5969 EXPECT_TRUE(response2.headers != NULL); | 5971 EXPECT_TRUE(response2.headers.get() != NULL); |
| 5970 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 5972 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
| 5971 | 5973 |
| 5972 // Verify we got all the headers | 5974 // Verify we got all the headers |
| 5973 EXPECT_TRUE(response2.headers->HasHeaderValue( | 5975 EXPECT_TRUE(response2.headers->HasHeaderValue( |
| 5974 "scheme", "http")); | 5976 "scheme", "http")); |
| 5975 EXPECT_TRUE(response2.headers->HasHeaderValue( | 5977 EXPECT_TRUE(response2.headers->HasHeaderValue( |
| 5976 "host", "www.google.com")); | 5978 "host", "www.google.com")); |
| 5977 EXPECT_TRUE(response2.headers->HasHeaderValue( | 5979 EXPECT_TRUE(response2.headers->HasHeaderValue( |
| 5978 "path", "/foo.dat")); | 5980 "path", "/foo.dat")); |
| 5979 EXPECT_TRUE(response2.headers->HasHeaderValue("hello", "bye")); | 5981 EXPECT_TRUE(response2.headers->HasHeaderValue("hello", "bye")); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6067 int rv = trans->Start( | 6069 int rv = trans->Start( |
| 6068 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 6070 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
| 6069 EXPECT_EQ(ERR_IO_PENDING, rv); | 6071 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6070 data.Run(); | 6072 data.Run(); |
| 6071 rv = callback.WaitForResult(); | 6073 rv = callback.WaitForResult(); |
| 6072 EXPECT_EQ(0, rv); | 6074 EXPECT_EQ(0, rv); |
| 6073 | 6075 |
| 6074 // Request the pushed path. At this point, we've received the push, but the | 6076 // Request the pushed path. At this point, we've received the push, but the |
| 6075 // headers are not yet complete. | 6077 // headers are not yet complete. |
| 6076 scoped_ptr<HttpNetworkTransaction> trans2( | 6078 scoped_ptr<HttpNetworkTransaction> trans2( |
| 6077 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 6079 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session().get())); |
| 6078 rv = trans2->Start( | 6080 rv = trans2->Start( |
| 6079 &CreateGetPushRequest(), callback.callback(), BoundNetLog()); | 6081 &CreateGetPushRequest(), callback.callback(), BoundNetLog()); |
| 6080 EXPECT_EQ(ERR_IO_PENDING, rv); | 6082 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6081 data.RunFor(2); | 6083 data.RunFor(2); |
| 6082 base::MessageLoop::current()->RunUntilIdle(); | 6084 base::MessageLoop::current()->RunUntilIdle(); |
| 6083 | 6085 |
| 6084 // Read the server push body. | 6086 // Read the server push body. |
| 6085 std::string result2; | 6087 std::string result2; |
| 6086 ReadResult(trans2.get(), &data, &result2); | 6088 ReadResult(trans2.get(), &data, &result2); |
| 6087 // Read the response body. | 6089 // Read the response body. |
| 6088 std::string result; | 6090 std::string result; |
| 6089 ReadResult(trans, &data, &result); | 6091 ReadResult(trans, &data, &result); |
| 6090 EXPECT_EQ("hello!", result); | 6092 EXPECT_EQ("hello!", result); |
| 6091 | 6093 |
| 6092 // Verify that we haven't received any push data. | 6094 // Verify that we haven't received any push data. |
| 6093 EXPECT_EQ("", result2); | 6095 EXPECT_EQ("", result2); |
| 6094 | 6096 |
| 6095 // Verify the SYN_REPLY. | 6097 // Verify the SYN_REPLY. |
| 6096 // Copy the response info, because trans goes away. | 6098 // Copy the response info, because trans goes away. |
| 6097 HttpResponseInfo response = *trans->GetResponseInfo(); | 6099 HttpResponseInfo response = *trans->GetResponseInfo(); |
| 6098 ASSERT_TRUE(trans2->GetResponseInfo() == NULL); | 6100 ASSERT_TRUE(trans2->GetResponseInfo() == NULL); |
| 6099 | 6101 |
| 6100 VerifyStreamsClosed(helper); | 6102 VerifyStreamsClosed(helper); |
| 6101 | 6103 |
| 6102 // Verify the SYN_REPLY. | 6104 // Verify the SYN_REPLY. |
| 6103 EXPECT_TRUE(response.headers != NULL); | 6105 EXPECT_TRUE(response.headers.get() != NULL); |
| 6104 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 6106 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 6105 | 6107 |
| 6106 // Read the final EOF (which will close the session). | 6108 // Read the final EOF (which will close the session). |
| 6107 data.RunFor(1); | 6109 data.RunFor(1); |
| 6108 | 6110 |
| 6109 // Verify that we consumed all test data. | 6111 // Verify that we consumed all test data. |
| 6110 EXPECT_TRUE(data.at_read_eof()); | 6112 EXPECT_TRUE(data.at_read_eof()); |
| 6111 EXPECT_TRUE(data.at_write_eof()); | 6113 EXPECT_TRUE(data.at_write_eof()); |
| 6112 } | 6114 } |
| 6113 | 6115 |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6384 EXPECT_TRUE(data.at_read_eof()); | 6386 EXPECT_TRUE(data.at_read_eof()); |
| 6385 EXPECT_TRUE(data.at_write_eof()); | 6387 EXPECT_TRUE(data.at_write_eof()); |
| 6386 | 6388 |
| 6387 // Verify the SYN_REPLY. | 6389 // Verify the SYN_REPLY. |
| 6388 // Copy the response info, because trans goes away. | 6390 // Copy the response info, because trans goes away. |
| 6389 response = *trans->GetResponseInfo(); | 6391 response = *trans->GetResponseInfo(); |
| 6390 | 6392 |
| 6391 VerifyStreamsClosed(helper); | 6393 VerifyStreamsClosed(helper); |
| 6392 | 6394 |
| 6393 // Verify the SYN_REPLY. | 6395 // Verify the SYN_REPLY. |
| 6394 EXPECT_TRUE(response.headers != NULL); | 6396 EXPECT_TRUE(response.headers.get() != NULL); |
| 6395 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 6397 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 6396 } | 6398 } |
| 6397 } | 6399 } |
| 6398 | 6400 |
| 6399 TEST_P(SpdyNetworkTransactionSpdy3Test, RetryAfterRefused) { | 6401 TEST_P(SpdyNetworkTransactionSpdy3Test, RetryAfterRefused) { |
| 6400 // Construct the request. | 6402 // Construct the request. |
| 6401 scoped_ptr<SpdyFrame> req( | 6403 scoped_ptr<SpdyFrame> req( |
| 6402 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 6404 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
| 6403 scoped_ptr<SpdyFrame> req2( | 6405 scoped_ptr<SpdyFrame> req2( |
| 6404 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); | 6406 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6441 << data.read_count() | 6443 << data.read_count() |
| 6442 << " Read index: " | 6444 << " Read index: " |
| 6443 << data.read_index(); | 6445 << data.read_index(); |
| 6444 EXPECT_TRUE(data.at_write_eof()) << "Write count: " | 6446 EXPECT_TRUE(data.at_write_eof()) << "Write count: " |
| 6445 << data.write_count() | 6447 << data.write_count() |
| 6446 << " Write index: " | 6448 << " Write index: " |
| 6447 << data.write_index(); | 6449 << data.write_index(); |
| 6448 | 6450 |
| 6449 // Verify the SYN_REPLY. | 6451 // Verify the SYN_REPLY. |
| 6450 HttpResponseInfo response = *trans->GetResponseInfo(); | 6452 HttpResponseInfo response = *trans->GetResponseInfo(); |
| 6451 EXPECT_TRUE(response.headers != NULL); | 6453 EXPECT_TRUE(response.headers.get() != NULL); |
| 6452 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 6454 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
| 6453 } | 6455 } |
| 6454 | 6456 |
| 6455 TEST_P(SpdyNetworkTransactionSpdy3Test, OutOfOrderSynStream) { | 6457 TEST_P(SpdyNetworkTransactionSpdy3Test, OutOfOrderSynStream) { |
| 6456 // This first request will start to establish the SpdySession. | 6458 // This first request will start to establish the SpdySession. |
| 6457 // Then we will start the second (MEDIUM priority) and then third | 6459 // Then we will start the second (MEDIUM priority) and then third |
| 6458 // (HIGHEST priority) request in such a way that the third will actually | 6460 // (HIGHEST priority) request in such a way that the third will actually |
| 6459 // start before the second, causing the second to be numbered differently | 6461 // start before the second, causing the second to be numbered differently |
| 6460 // than they order they were created. | 6462 // than they order they were created. |
| 6461 scoped_ptr<SpdyFrame> req1( | 6463 scoped_ptr<SpdyFrame> req1( |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6502 EXPECT_EQ(ERR_IO_PENDING, rv); | 6504 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6503 | 6505 |
| 6504 // Run the message loop, but do not allow the write to complete. | 6506 // Run the message loop, but do not allow the write to complete. |
| 6505 // This leaves the SpdySession with a write pending, which prevents | 6507 // This leaves the SpdySession with a write pending, which prevents |
| 6506 // SpdySession from attempting subsequent writes until this write completes. | 6508 // SpdySession from attempting subsequent writes until this write completes. |
| 6507 base::MessageLoop::current()->RunUntilIdle(); | 6509 base::MessageLoop::current()->RunUntilIdle(); |
| 6508 | 6510 |
| 6509 // Now, start both new transactions | 6511 // Now, start both new transactions |
| 6510 HttpRequestInfo info2 = CreateGetRequest(); | 6512 HttpRequestInfo info2 = CreateGetRequest(); |
| 6511 TestCompletionCallback callback2; | 6513 TestCompletionCallback callback2; |
| 6512 scoped_ptr<HttpNetworkTransaction> trans2( | 6514 scoped_ptr<HttpNetworkTransaction> trans2( |
| 6513 new HttpNetworkTransaction(MEDIUM, helper.session())); | 6515 new HttpNetworkTransaction(MEDIUM, helper.session().get())); |
| 6514 rv = trans2->Start(&info2, callback2.callback(), BoundNetLog()); | 6516 rv = trans2->Start(&info2, callback2.callback(), BoundNetLog()); |
| 6515 EXPECT_EQ(ERR_IO_PENDING, rv); | 6517 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6516 base::MessageLoop::current()->RunUntilIdle(); | 6518 base::MessageLoop::current()->RunUntilIdle(); |
| 6517 | 6519 |
| 6518 HttpRequestInfo info3 = CreateGetRequest(); | 6520 HttpRequestInfo info3 = CreateGetRequest(); |
| 6519 TestCompletionCallback callback3; | 6521 TestCompletionCallback callback3; |
| 6520 scoped_ptr<HttpNetworkTransaction> trans3( | 6522 scoped_ptr<HttpNetworkTransaction> trans3( |
| 6521 new HttpNetworkTransaction(HIGHEST, helper.session())); | 6523 new HttpNetworkTransaction(HIGHEST, helper.session().get())); |
| 6522 rv = trans3->Start(&info3, callback3.callback(), BoundNetLog()); | 6524 rv = trans3->Start(&info3, callback3.callback(), BoundNetLog()); |
| 6523 EXPECT_EQ(ERR_IO_PENDING, rv); | 6525 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6524 base::MessageLoop::current()->RunUntilIdle(); | 6526 base::MessageLoop::current()->RunUntilIdle(); |
| 6525 | 6527 |
| 6526 // We now have two SYN_STREAM frames queued up which will be | 6528 // We now have two SYN_STREAM frames queued up which will be |
| 6527 // dequeued only once the first write completes, which we | 6529 // dequeued only once the first write completes, which we |
| 6528 // now allow to happen. | 6530 // now allow to happen. |
| 6529 data.RunFor(2); | 6531 data.RunFor(2); |
| 6530 EXPECT_EQ(OK, callback.WaitForResult()); | 6532 EXPECT_EQ(OK, callback.WaitForResult()); |
| 6531 | 6533 |
| 6532 // And now we can allow everything else to run to completion. | 6534 // And now we can allow everything else to run to completion. |
| 6533 data.SetStop(10); | 6535 data.SetStop(10); |
| 6534 data.Run(); | 6536 data.Run(); |
| 6535 EXPECT_EQ(OK, callback2.WaitForResult()); | 6537 EXPECT_EQ(OK, callback2.WaitForResult()); |
| 6536 EXPECT_EQ(OK, callback3.WaitForResult()); | 6538 EXPECT_EQ(OK, callback3.WaitForResult()); |
| 6537 | 6539 |
| 6538 helper.VerifyDataConsumed(); | 6540 helper.VerifyDataConsumed(); |
| 6539 } | 6541 } |
| 6540 | 6542 |
| 6541 } // namespace net | 6543 } // namespace net |
| OLD | NEW |