| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <cmath> | 5 #include <cmath> |
| 6 #include <memory> | 6 #include <memory> |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 std::string response_data; | 94 std::string response_data; |
| 95 HttpResponseInfo response_info; | 95 HttpResponseInfo response_info; |
| 96 }; | 96 }; |
| 97 | 97 |
| 98 // A helper class that handles all the initial npn/ssl setup. | 98 // A helper class that handles all the initial npn/ssl setup. |
| 99 class NormalSpdyTransactionHelper { | 99 class NormalSpdyTransactionHelper { |
| 100 public: | 100 public: |
| 101 NormalSpdyTransactionHelper( | 101 NormalSpdyTransactionHelper( |
| 102 const HttpRequestInfo& request, | 102 const HttpRequestInfo& request, |
| 103 RequestPriority priority, | 103 RequestPriority priority, |
| 104 const BoundNetLog& log, | 104 const NetLogWithSource& log, |
| 105 std::unique_ptr<SpdySessionDependencies> session_deps) | 105 std::unique_ptr<SpdySessionDependencies> session_deps) |
| 106 : request_(request), | 106 : request_(request), |
| 107 priority_(priority), | 107 priority_(priority), |
| 108 session_deps_(session_deps.get() == NULL | 108 session_deps_(session_deps.get() == NULL |
| 109 ? base::MakeUnique<SpdySessionDependencies>() | 109 ? base::MakeUnique<SpdySessionDependencies>() |
| 110 : std::move(session_deps)), | 110 : std::move(session_deps)), |
| 111 session_( | 111 session_( |
| 112 SpdySessionDependencies::SpdyCreateSession(session_deps_.get())), | 112 SpdySessionDependencies::SpdyCreateSession(session_deps_.get())), |
| 113 log_(log) {} | 113 log_(log) {} |
| 114 | 114 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 typedef std::vector<std::unique_ptr<SocketDataProvider>> AlternateVector; | 246 typedef std::vector<std::unique_ptr<SocketDataProvider>> AlternateVector; |
| 247 HttpRequestInfo request_; | 247 HttpRequestInfo request_; |
| 248 RequestPriority priority_; | 248 RequestPriority priority_; |
| 249 std::unique_ptr<SpdySessionDependencies> session_deps_; | 249 std::unique_ptr<SpdySessionDependencies> session_deps_; |
| 250 std::unique_ptr<HttpNetworkSession> session_; | 250 std::unique_ptr<HttpNetworkSession> session_; |
| 251 TransactionHelperResult output_; | 251 TransactionHelperResult output_; |
| 252 SSLVector ssl_vector_; | 252 SSLVector ssl_vector_; |
| 253 TestCompletionCallback callback_; | 253 TestCompletionCallback callback_; |
| 254 std::unique_ptr<HttpNetworkTransaction> trans_; | 254 std::unique_ptr<HttpNetworkTransaction> trans_; |
| 255 DataVector data_vector_; | 255 DataVector data_vector_; |
| 256 const BoundNetLog log_; | 256 const NetLogWithSource log_; |
| 257 }; | 257 }; |
| 258 | 258 |
| 259 void ConnectStatusHelperWithExpectedStatus(const MockRead& status, | 259 void ConnectStatusHelperWithExpectedStatus(const MockRead& status, |
| 260 int expected_status); | 260 int expected_status); |
| 261 | 261 |
| 262 void ConnectStatusHelper(const MockRead& status); | 262 void ConnectStatusHelper(const MockRead& status); |
| 263 | 263 |
| 264 const HttpRequestInfo& CreateGetPushRequest() { | 264 const HttpRequestInfo& CreateGetPushRequest() { |
| 265 get_push_request_.method = "GET"; | 265 get_push_request_.method = "GET"; |
| 266 get_push_request_.url = GURL(GetDefaultUrlWithPath("/foo.dat")); | 266 get_push_request_.url = GURL(GetDefaultUrlWithPath("/foo.dat")); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 return bytes_read; | 418 return bytes_read; |
| 419 } | 419 } |
| 420 | 420 |
| 421 void VerifyStreamsClosed(const NormalSpdyTransactionHelper& helper) { | 421 void VerifyStreamsClosed(const NormalSpdyTransactionHelper& helper) { |
| 422 // This lengthy block is reaching into the pool to dig out the active | 422 // This lengthy block is reaching into the pool to dig out the active |
| 423 // session. Once we have the session, we verify that the streams are | 423 // session. Once we have the session, we verify that the streams are |
| 424 // all closed and not leaked at this point. | 424 // all closed and not leaked at this point. |
| 425 const GURL& url = helper.request().url; | 425 const GURL& url = helper.request().url; |
| 426 SpdySessionKey key(HostPortPair::FromURL(url), ProxyServer::Direct(), | 426 SpdySessionKey key(HostPortPair::FromURL(url), ProxyServer::Direct(), |
| 427 PRIVACY_MODE_DISABLED); | 427 PRIVACY_MODE_DISABLED); |
| 428 BoundNetLog log; | 428 NetLogWithSource log; |
| 429 HttpNetworkSession* session = helper.session(); | 429 HttpNetworkSession* session = helper.session(); |
| 430 base::WeakPtr<SpdySession> spdy_session = | 430 base::WeakPtr<SpdySession> spdy_session = |
| 431 session->spdy_session_pool()->FindAvailableSession(key, url, log); | 431 session->spdy_session_pool()->FindAvailableSession(key, url, log); |
| 432 ASSERT_TRUE(spdy_session); | 432 ASSERT_TRUE(spdy_session); |
| 433 EXPECT_EQ(0u, spdy_session->num_active_streams()); | 433 EXPECT_EQ(0u, spdy_session->num_active_streams()); |
| 434 EXPECT_EQ(0u, spdy_session->num_unclaimed_pushed_streams()); | 434 EXPECT_EQ(0u, spdy_session->num_unclaimed_pushed_streams()); |
| 435 } | 435 } |
| 436 | 436 |
| 437 void RunServerPushTest(SequencedSocketData* data, | 437 void RunServerPushTest(SequencedSocketData* data, |
| 438 HttpResponseInfo* response, | 438 HttpResponseInfo* response, |
| 439 HttpResponseInfo* push_response, | 439 HttpResponseInfo* push_response, |
| 440 const std::string& expected) { | 440 const std::string& expected) { |
| 441 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 441 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 442 BoundNetLog(), NULL); | 442 NetLogWithSource(), NULL); |
| 443 helper.RunPreTestSetup(); | 443 helper.RunPreTestSetup(); |
| 444 helper.AddData(data); | 444 helper.AddData(data); |
| 445 | 445 |
| 446 HttpNetworkTransaction* trans = helper.trans(); | 446 HttpNetworkTransaction* trans = helper.trans(); |
| 447 | 447 |
| 448 // Start the transaction with basic parameters. | 448 // Start the transaction with basic parameters. |
| 449 TestCompletionCallback callback; | 449 TestCompletionCallback callback; |
| 450 int rv = trans->Start( | 450 int rv = trans->Start(&CreateGetRequest(), callback.callback(), |
| 451 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 451 NetLogWithSource()); |
| 452 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 452 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 453 rv = callback.WaitForResult(); | 453 rv = callback.WaitForResult(); |
| 454 | 454 |
| 455 // Request the pushed path. | 455 // Request the pushed path. |
| 456 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, helper.session()); | 456 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, helper.session()); |
| 457 rv = trans2.Start(&CreateGetPushRequest(), callback.callback(), | 457 rv = trans2.Start(&CreateGetPushRequest(), callback.callback(), |
| 458 BoundNetLog()); | 458 NetLogWithSource()); |
| 459 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 459 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 460 base::RunLoop().RunUntilIdle(); | 460 base::RunLoop().RunUntilIdle(); |
| 461 | 461 |
| 462 // The data for the pushed path may be coming in more than 1 frame. Compile | 462 // The data for the pushed path may be coming in more than 1 frame. Compile |
| 463 // the results into a single string. | 463 // the results into a single string. |
| 464 | 464 |
| 465 // Read the server push body. | 465 // Read the server push body. |
| 466 std::string result2; | 466 std::string result2; |
| 467 ReadResult(&trans2, &result2); | 467 ReadResult(&trans2, &result2); |
| 468 // Read the response body. | 468 // Read the response body. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 | 504 |
| 505 static void StartTransactionCallback(HttpNetworkSession* session, | 505 static void StartTransactionCallback(HttpNetworkSession* session, |
| 506 GURL url, | 506 GURL url, |
| 507 int result) { | 507 int result) { |
| 508 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session); | 508 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session); |
| 509 TestCompletionCallback callback; | 509 TestCompletionCallback callback; |
| 510 HttpRequestInfo request; | 510 HttpRequestInfo request; |
| 511 request.method = "GET"; | 511 request.method = "GET"; |
| 512 request.url = url; | 512 request.url = url; |
| 513 request.load_flags = 0; | 513 request.load_flags = 0; |
| 514 int rv = trans.Start(&request, callback.callback(), BoundNetLog()); | 514 int rv = trans.Start(&request, callback.callback(), NetLogWithSource()); |
| 515 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 515 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 516 callback.WaitForResult(); | 516 callback.WaitForResult(); |
| 517 } | 517 } |
| 518 | 518 |
| 519 ChunkedUploadDataStream* upload_chunked_data_stream() const { | 519 ChunkedUploadDataStream* upload_chunked_data_stream() const { |
| 520 return upload_chunked_data_stream_.get(); | 520 return upload_chunked_data_stream_.get(); |
| 521 } | 521 } |
| 522 | 522 |
| 523 std::string GetDefaultUrlWithPath(const char* path) { | 523 std::string GetDefaultUrlWithPath(const char* path) { |
| 524 return std::string(kDefaultUrl) + path; | 524 return std::string(kDefaultUrl) + path; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 | 558 |
| 559 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); | 559 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); |
| 560 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); | 560 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); |
| 561 MockRead reads[] = { | 561 MockRead reads[] = { |
| 562 CreateMockRead(resp, 1), CreateMockRead(body, 2), | 562 CreateMockRead(resp, 1), CreateMockRead(body, 2), |
| 563 MockRead(ASYNC, 0, 3) // EOF | 563 MockRead(ASYNC, 0, 3) // EOF |
| 564 }; | 564 }; |
| 565 | 565 |
| 566 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 566 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 567 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 567 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 568 BoundNetLog(), NULL); | 568 NetLogWithSource(), NULL); |
| 569 helper.RunToCompletion(&data); | 569 helper.RunToCompletion(&data); |
| 570 TransactionHelperResult out = helper.output(); | 570 TransactionHelperResult out = helper.output(); |
| 571 EXPECT_THAT(out.rv, IsOk()); | 571 EXPECT_THAT(out.rv, IsOk()); |
| 572 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 572 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
| 573 EXPECT_EQ("hello!", out.response_data); | 573 EXPECT_EQ("hello!", out.response_data); |
| 574 } | 574 } |
| 575 | 575 |
| 576 TEST_F(SpdyNetworkTransactionTest, GetAtEachPriority) { | 576 TEST_F(SpdyNetworkTransactionTest, GetAtEachPriority) { |
| 577 for (RequestPriority p = MINIMUM_PRIORITY; p <= MAXIMUM_PRIORITY; | 577 for (RequestPriority p = MINIMUM_PRIORITY; p <= MAXIMUM_PRIORITY; |
| 578 p = RequestPriority(p + 1)) { | 578 p = RequestPriority(p + 1)) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 SpdySerializedFrame body(spdy_test_util.ConstructSpdyDataFrame(1, true)); | 613 SpdySerializedFrame body(spdy_test_util.ConstructSpdyDataFrame(1, true)); |
| 614 MockRead reads[] = { | 614 MockRead reads[] = { |
| 615 CreateMockRead(resp, 1), CreateMockRead(body, 2), | 615 CreateMockRead(resp, 1), CreateMockRead(body, 2), |
| 616 MockRead(ASYNC, 0, 3) // EOF | 616 MockRead(ASYNC, 0, 3) // EOF |
| 617 }; | 617 }; |
| 618 | 618 |
| 619 SequencedSocketData data(reads, arraysize(reads), writes, | 619 SequencedSocketData data(reads, arraysize(reads), writes, |
| 620 arraysize(writes)); | 620 arraysize(writes)); |
| 621 HttpRequestInfo http_req = CreateGetRequest(); | 621 HttpRequestInfo http_req = CreateGetRequest(); |
| 622 | 622 |
| 623 NormalSpdyTransactionHelper helper(http_req, p, BoundNetLog(), NULL); | 623 NormalSpdyTransactionHelper helper(http_req, p, NetLogWithSource(), NULL); |
| 624 helper.RunToCompletion(&data); | 624 helper.RunToCompletion(&data); |
| 625 TransactionHelperResult out = helper.output(); | 625 TransactionHelperResult out = helper.output(); |
| 626 EXPECT_THAT(out.rv, IsOk()); | 626 EXPECT_THAT(out.rv, IsOk()); |
| 627 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 627 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
| 628 EXPECT_EQ("hello!", out.response_data); | 628 EXPECT_EQ("hello!", out.response_data); |
| 629 } | 629 } |
| 630 } | 630 } |
| 631 | 631 |
| 632 // Start three gets simultaniously; making sure that multiplexed | 632 // Start three gets simultaniously; making sure that multiplexed |
| 633 // streams work properly. | 633 // streams work properly. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 | 669 |
| 670 CreateMockRead(fbody, 9), CreateMockRead(fbody2, 10), | 670 CreateMockRead(fbody, 9), CreateMockRead(fbody2, 10), |
| 671 CreateMockRead(fbody3, 11), | 671 CreateMockRead(fbody3, 11), |
| 672 | 672 |
| 673 MockRead(ASYNC, 0, 12), // EOF | 673 MockRead(ASYNC, 0, 12), // EOF |
| 674 }; | 674 }; |
| 675 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 675 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 676 SequencedSocketData data_placeholder1(NULL, 0, NULL, 0); | 676 SequencedSocketData data_placeholder1(NULL, 0, NULL, 0); |
| 677 SequencedSocketData data_placeholder2(NULL, 0, NULL, 0); | 677 SequencedSocketData data_placeholder2(NULL, 0, NULL, 0); |
| 678 | 678 |
| 679 BoundNetLog log; | 679 NetLogWithSource log; |
| 680 TransactionHelperResult out; | 680 TransactionHelperResult out; |
| 681 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 681 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 682 BoundNetLog(), NULL); | 682 NetLogWithSource(), NULL); |
| 683 helper.RunPreTestSetup(); | 683 helper.RunPreTestSetup(); |
| 684 helper.AddData(&data); | 684 helper.AddData(&data); |
| 685 // We require placeholder data because three get requests are sent out at | 685 // We require placeholder data because three get requests are sent out at |
| 686 // the same time which results in three sockets being connected. The first | 686 // the same time which results in three sockets being connected. The first |
| 687 // on will negotiate SPDY and will be used for all requests. | 687 // on will negotiate SPDY and will be used for all requests. |
| 688 helper.AddData(&data_placeholder1); | 688 helper.AddData(&data_placeholder1); |
| 689 helper.AddData(&data_placeholder2); | 689 helper.AddData(&data_placeholder2); |
| 690 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, helper.session()); | 690 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, helper.session()); |
| 691 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, helper.session()); | 691 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, helper.session()); |
| 692 HttpNetworkTransaction trans3(DEFAULT_PRIORITY, helper.session()); | 692 HttpNetworkTransaction trans3(DEFAULT_PRIORITY, helper.session()); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 CreateMockRead(resp2, 4), CreateMockRead(body2, 5), | 749 CreateMockRead(resp2, 4), CreateMockRead(body2, 5), |
| 750 CreateMockRead(fbody, 6), CreateMockRead(fbody2, 7), | 750 CreateMockRead(fbody, 6), CreateMockRead(fbody2, 7), |
| 751 MockRead(ASYNC, 0, 8), // EOF | 751 MockRead(ASYNC, 0, 8), // EOF |
| 752 }; | 752 }; |
| 753 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 753 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 754 | 754 |
| 755 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); | 755 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); |
| 756 SequencedSocketData data_placeholder(NULL, 0, NULL, 0); | 756 SequencedSocketData data_placeholder(NULL, 0, NULL, 0); |
| 757 data_placeholder.set_connect_data(never_finishing_connect); | 757 data_placeholder.set_connect_data(never_finishing_connect); |
| 758 | 758 |
| 759 BoundNetLog log; | 759 NetLogWithSource log; |
| 760 TransactionHelperResult out; | 760 TransactionHelperResult out; |
| 761 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 761 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 762 BoundNetLog(), NULL); | 762 NetLogWithSource(), NULL); |
| 763 helper.RunPreTestSetup(); | 763 helper.RunPreTestSetup(); |
| 764 helper.AddData(&data); | 764 helper.AddData(&data); |
| 765 // We require placeholder data because two requests are sent out at | 765 // We require placeholder data because two requests are sent out at |
| 766 // the same time which results in two sockets being connected. The first | 766 // the same time which results in two sockets being connected. The first |
| 767 // on will negotiate SPDY and will be used for all requests. | 767 // on will negotiate SPDY and will be used for all requests. |
| 768 helper.AddData(&data_placeholder); | 768 helper.AddData(&data_placeholder); |
| 769 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, helper.session()); | 769 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, helper.session()); |
| 770 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, helper.session()); | 770 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, helper.session()); |
| 771 | 771 |
| 772 TestCompletionCallback callback1; | 772 TestCompletionCallback callback1; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 MockRead(ASYNC, 0, 8), // EOF | 831 MockRead(ASYNC, 0, 8), // EOF |
| 832 }; | 832 }; |
| 833 SequencedSocketData preconnect_data(reads, arraysize(reads), writes, | 833 SequencedSocketData preconnect_data(reads, arraysize(reads), writes, |
| 834 arraysize(writes)); | 834 arraysize(writes)); |
| 835 | 835 |
| 836 MockConnect never_finishing_connect(ASYNC, ERR_IO_PENDING); | 836 MockConnect never_finishing_connect(ASYNC, ERR_IO_PENDING); |
| 837 | 837 |
| 838 SequencedSocketData data_placeholder(NULL, 0, NULL, 0); | 838 SequencedSocketData data_placeholder(NULL, 0, NULL, 0); |
| 839 data_placeholder.set_connect_data(never_finishing_connect); | 839 data_placeholder.set_connect_data(never_finishing_connect); |
| 840 | 840 |
| 841 BoundNetLog log; | 841 NetLogWithSource log; |
| 842 TransactionHelperResult out; | 842 TransactionHelperResult out; |
| 843 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 843 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 844 BoundNetLog(), NULL); | 844 NetLogWithSource(), NULL); |
| 845 helper.RunPreTestSetup(); | 845 helper.RunPreTestSetup(); |
| 846 helper.AddData(&preconnect_data); | 846 helper.AddData(&preconnect_data); |
| 847 // We require placeholder data because 3 connections are attempted (first is | 847 // We require placeholder data because 3 connections are attempted (first is |
| 848 // the preconnect, 2nd and 3rd are the never finished connections. | 848 // the preconnect, 2nd and 3rd are the never finished connections. |
| 849 helper.AddData(&data_placeholder); | 849 helper.AddData(&data_placeholder); |
| 850 helper.AddData(&data_placeholder); | 850 helper.AddData(&data_placeholder); |
| 851 | 851 |
| 852 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, helper.session()); | 852 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, helper.session()); |
| 853 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, helper.session()); | 853 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, helper.session()); |
| 854 | 854 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 947 CreateMockRead(fbody2, 9), | 947 CreateMockRead(fbody2, 9), |
| 948 CreateMockRead(resp3, 11), | 948 CreateMockRead(resp3, 11), |
| 949 CreateMockRead(body3, 12), | 949 CreateMockRead(body3, 12), |
| 950 CreateMockRead(fbody3, 13), | 950 CreateMockRead(fbody3, 13), |
| 951 | 951 |
| 952 MockRead(ASYNC, 0, 14), // EOF | 952 MockRead(ASYNC, 0, 14), // EOF |
| 953 }; | 953 }; |
| 954 | 954 |
| 955 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 955 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 956 | 956 |
| 957 BoundNetLog log; | 957 NetLogWithSource log; |
| 958 TransactionHelperResult out; | 958 TransactionHelperResult out; |
| 959 { | 959 { |
| 960 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 960 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 961 BoundNetLog(), NULL); | 961 NetLogWithSource(), NULL); |
| 962 helper.RunPreTestSetup(); | 962 helper.RunPreTestSetup(); |
| 963 helper.AddData(&data); | 963 helper.AddData(&data); |
| 964 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, helper.session()); | 964 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, helper.session()); |
| 965 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, helper.session()); | 965 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, helper.session()); |
| 966 HttpNetworkTransaction trans3(DEFAULT_PRIORITY, helper.session()); | 966 HttpNetworkTransaction trans3(DEFAULT_PRIORITY, helper.session()); |
| 967 | 967 |
| 968 TestCompletionCallback callback1; | 968 TestCompletionCallback callback1; |
| 969 TestCompletionCallback callback2; | 969 TestCompletionCallback callback2; |
| 970 TestCompletionCallback callback3; | 970 TestCompletionCallback callback3; |
| 971 | 971 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1081 CreateMockRead(fbody2, 9), | 1081 CreateMockRead(fbody2, 9), |
| 1082 CreateMockRead(resp4, 11), | 1082 CreateMockRead(resp4, 11), |
| 1083 CreateMockRead(fbody4, 12), | 1083 CreateMockRead(fbody4, 12), |
| 1084 CreateMockRead(resp3, 14), | 1084 CreateMockRead(resp3, 14), |
| 1085 CreateMockRead(body3, 15), | 1085 CreateMockRead(body3, 15), |
| 1086 CreateMockRead(fbody3, 16), | 1086 CreateMockRead(fbody3, 16), |
| 1087 | 1087 |
| 1088 MockRead(ASYNC, 0, 17), // EOF | 1088 MockRead(ASYNC, 0, 17), // EOF |
| 1089 }; | 1089 }; |
| 1090 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 1090 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 1091 BoundNetLog log; | 1091 NetLogWithSource log; |
| 1092 TransactionHelperResult out; | 1092 TransactionHelperResult out; |
| 1093 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 1093 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 1094 BoundNetLog(), NULL); | 1094 NetLogWithSource(), NULL); |
| 1095 helper.RunPreTestSetup(); | 1095 helper.RunPreTestSetup(); |
| 1096 helper.AddData(&data); | 1096 helper.AddData(&data); |
| 1097 | 1097 |
| 1098 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, helper.session()); | 1098 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, helper.session()); |
| 1099 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, helper.session()); | 1099 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, helper.session()); |
| 1100 HttpNetworkTransaction trans3(DEFAULT_PRIORITY, helper.session()); | 1100 HttpNetworkTransaction trans3(DEFAULT_PRIORITY, helper.session()); |
| 1101 HttpNetworkTransaction trans4(HIGHEST, helper.session()); | 1101 HttpNetworkTransaction trans4(HIGHEST, helper.session()); |
| 1102 | 1102 |
| 1103 TestCompletionCallback callback1; | 1103 TestCompletionCallback callback1; |
| 1104 TestCompletionCallback callback2; | 1104 TestCompletionCallback callback2; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1203 }; | 1203 }; |
| 1204 MockRead reads[] = { | 1204 MockRead reads[] = { |
| 1205 CreateMockRead(settings_frame, 1), CreateMockRead(resp, 2), | 1205 CreateMockRead(settings_frame, 1), CreateMockRead(resp, 2), |
| 1206 CreateMockRead(body, 3), CreateMockRead(fbody, 4), | 1206 CreateMockRead(body, 3), CreateMockRead(fbody, 4), |
| 1207 CreateMockRead(resp2, 7), CreateMockRead(body2, 8), | 1207 CreateMockRead(resp2, 7), CreateMockRead(body2, 8), |
| 1208 CreateMockRead(fbody2, 9), MockRead(ASYNC, 0, 10), // EOF | 1208 CreateMockRead(fbody2, 9), MockRead(ASYNC, 0, 10), // EOF |
| 1209 }; | 1209 }; |
| 1210 | 1210 |
| 1211 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 1211 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 1212 | 1212 |
| 1213 BoundNetLog log; | 1213 NetLogWithSource log; |
| 1214 TransactionHelperResult out; | 1214 TransactionHelperResult out; |
| 1215 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 1215 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 1216 BoundNetLog(), NULL); | 1216 NetLogWithSource(), NULL); |
| 1217 helper.RunPreTestSetup(); | 1217 helper.RunPreTestSetup(); |
| 1218 helper.AddData(&data); | 1218 helper.AddData(&data); |
| 1219 std::unique_ptr<HttpNetworkTransaction> trans1( | 1219 std::unique_ptr<HttpNetworkTransaction> trans1( |
| 1220 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 1220 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); |
| 1221 std::unique_ptr<HttpNetworkTransaction> trans2( | 1221 std::unique_ptr<HttpNetworkTransaction> trans2( |
| 1222 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 1222 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); |
| 1223 std::unique_ptr<HttpNetworkTransaction> trans3( | 1223 std::unique_ptr<HttpNetworkTransaction> trans3( |
| 1224 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 1224 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); |
| 1225 | 1225 |
| 1226 TestCompletionCallback callback1; | 1226 TestCompletionCallback callback1; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1331 CreateMockRead(resp, 2), | 1331 CreateMockRead(resp, 2), |
| 1332 CreateMockRead(body, 3), | 1332 CreateMockRead(body, 3), |
| 1333 CreateMockRead(fin_body, 4), | 1333 CreateMockRead(fin_body, 4), |
| 1334 CreateMockRead(resp2, 7), | 1334 CreateMockRead(resp2, 7), |
| 1335 MockRead(ASYNC, ERR_CONNECTION_RESET, 8), // Abort! | 1335 MockRead(ASYNC, ERR_CONNECTION_RESET, 8), // Abort! |
| 1336 }; | 1336 }; |
| 1337 | 1337 |
| 1338 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 1338 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 1339 SequencedSocketData data_placeholder(NULL, 0, NULL, 0); | 1339 SequencedSocketData data_placeholder(NULL, 0, NULL, 0); |
| 1340 | 1340 |
| 1341 BoundNetLog log; | 1341 NetLogWithSource log; |
| 1342 TransactionHelperResult out; | 1342 TransactionHelperResult out; |
| 1343 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 1343 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 1344 BoundNetLog(), NULL); | 1344 NetLogWithSource(), NULL); |
| 1345 helper.RunPreTestSetup(); | 1345 helper.RunPreTestSetup(); |
| 1346 helper.AddData(&data); | 1346 helper.AddData(&data); |
| 1347 // We require placeholder data because three get requests are sent out, so | 1347 // We require placeholder data because three get requests are sent out, so |
| 1348 // there needs to be three sets of SSL connection data. | 1348 // there needs to be three sets of SSL connection data. |
| 1349 helper.AddData(&data_placeholder); | 1349 helper.AddData(&data_placeholder); |
| 1350 helper.AddData(&data_placeholder); | 1350 helper.AddData(&data_placeholder); |
| 1351 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, helper.session()); | 1351 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, helper.session()); |
| 1352 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, helper.session()); | 1352 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, helper.session()); |
| 1353 HttpNetworkTransaction* trans3( | 1353 HttpNetworkTransaction* trans3( |
| 1354 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 1354 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1409 }; | 1409 }; |
| 1410 | 1410 |
| 1411 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); | 1411 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); |
| 1412 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); | 1412 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); |
| 1413 MockRead reads[] = { | 1413 MockRead reads[] = { |
| 1414 CreateMockRead(resp, 1), CreateMockRead(body, 2), | 1414 CreateMockRead(resp, 1), CreateMockRead(body, 2), |
| 1415 MockRead(ASYNC, 0, 3) // EOF | 1415 MockRead(ASYNC, 0, 3) // EOF |
| 1416 }; | 1416 }; |
| 1417 | 1417 |
| 1418 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 1418 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 1419 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, BoundNetLog(), | 1419 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, |
| 1420 NULL); | 1420 NetLogWithSource(), NULL); |
| 1421 helper.RunToCompletion(&data); | 1421 helper.RunToCompletion(&data); |
| 1422 TransactionHelperResult out = helper.output(); | 1422 TransactionHelperResult out = helper.output(); |
| 1423 | 1423 |
| 1424 EXPECT_THAT(out.rv, IsOk()); | 1424 EXPECT_THAT(out.rv, IsOk()); |
| 1425 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 1425 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
| 1426 } | 1426 } |
| 1427 | 1427 |
| 1428 // Test that a simple HEAD request works. | 1428 // Test that a simple HEAD request works. |
| 1429 TEST_F(SpdyNetworkTransactionTest, Head) { | 1429 TEST_F(SpdyNetworkTransactionTest, Head) { |
| 1430 // Setup the request | 1430 // Setup the request |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1441 }; | 1441 }; |
| 1442 | 1442 |
| 1443 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); | 1443 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); |
| 1444 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); | 1444 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); |
| 1445 MockRead reads[] = { | 1445 MockRead reads[] = { |
| 1446 CreateMockRead(resp, 1), CreateMockRead(body, 2), | 1446 CreateMockRead(resp, 1), CreateMockRead(body, 2), |
| 1447 MockRead(ASYNC, 0, 3) // EOF | 1447 MockRead(ASYNC, 0, 3) // EOF |
| 1448 }; | 1448 }; |
| 1449 | 1449 |
| 1450 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 1450 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 1451 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, BoundNetLog(), | 1451 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, |
| 1452 NULL); | 1452 NetLogWithSource(), NULL); |
| 1453 helper.RunToCompletion(&data); | 1453 helper.RunToCompletion(&data); |
| 1454 TransactionHelperResult out = helper.output(); | 1454 TransactionHelperResult out = helper.output(); |
| 1455 | 1455 |
| 1456 EXPECT_THAT(out.rv, IsOk()); | 1456 EXPECT_THAT(out.rv, IsOk()); |
| 1457 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 1457 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
| 1458 } | 1458 } |
| 1459 | 1459 |
| 1460 // Test that a simple POST works. | 1460 // Test that a simple POST works. |
| 1461 TEST_F(SpdyNetworkTransactionTest, Post) { | 1461 TEST_F(SpdyNetworkTransactionTest, Post) { |
| 1462 SpdySerializedFrame req(spdy_util_.ConstructSpdyPost( | 1462 SpdySerializedFrame req(spdy_util_.ConstructSpdyPost( |
| 1463 kDefaultUrl, 1, kUploadDataSize, LOWEST, NULL, 0)); | 1463 kDefaultUrl, 1, kUploadDataSize, LOWEST, NULL, 0)); |
| 1464 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); | 1464 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); |
| 1465 MockWrite writes[] = { | 1465 MockWrite writes[] = { |
| 1466 CreateMockWrite(req, 0), CreateMockWrite(body, 1), // POST upload frame | 1466 CreateMockWrite(req, 0), CreateMockWrite(body, 1), // POST upload frame |
| 1467 }; | 1467 }; |
| 1468 | 1468 |
| 1469 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostReply(NULL, 0)); | 1469 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostReply(NULL, 0)); |
| 1470 MockRead reads[] = { | 1470 MockRead reads[] = { |
| 1471 CreateMockRead(resp, 2), CreateMockRead(body, 3), | 1471 CreateMockRead(resp, 2), CreateMockRead(body, 3), |
| 1472 MockRead(ASYNC, 0, 4) // EOF | 1472 MockRead(ASYNC, 0, 4) // EOF |
| 1473 }; | 1473 }; |
| 1474 | 1474 |
| 1475 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 1475 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 1476 NormalSpdyTransactionHelper helper(CreatePostRequest(), DEFAULT_PRIORITY, | 1476 NormalSpdyTransactionHelper helper(CreatePostRequest(), DEFAULT_PRIORITY, |
| 1477 BoundNetLog(), NULL); | 1477 NetLogWithSource(), NULL); |
| 1478 helper.RunToCompletion(&data); | 1478 helper.RunToCompletion(&data); |
| 1479 TransactionHelperResult out = helper.output(); | 1479 TransactionHelperResult out = helper.output(); |
| 1480 EXPECT_THAT(out.rv, IsOk()); | 1480 EXPECT_THAT(out.rv, IsOk()); |
| 1481 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 1481 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
| 1482 EXPECT_EQ("hello!", out.response_data); | 1482 EXPECT_EQ("hello!", out.response_data); |
| 1483 } | 1483 } |
| 1484 | 1484 |
| 1485 // Test that a POST with a file works. | 1485 // Test that a POST with a file works. |
| 1486 TEST_F(SpdyNetworkTransactionTest, FilePost) { | 1486 TEST_F(SpdyNetworkTransactionTest, FilePost) { |
| 1487 SpdySerializedFrame req(spdy_util_.ConstructSpdyPost( | 1487 SpdySerializedFrame req(spdy_util_.ConstructSpdyPost( |
| 1488 kDefaultUrl, 1, kUploadDataSize, LOWEST, NULL, 0)); | 1488 kDefaultUrl, 1, kUploadDataSize, LOWEST, NULL, 0)); |
| 1489 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); | 1489 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); |
| 1490 MockWrite writes[] = { | 1490 MockWrite writes[] = { |
| 1491 CreateMockWrite(req, 0), CreateMockWrite(body, 1), // POST upload frame | 1491 CreateMockWrite(req, 0), CreateMockWrite(body, 1), // POST upload frame |
| 1492 }; | 1492 }; |
| 1493 | 1493 |
| 1494 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostReply(NULL, 0)); | 1494 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostReply(NULL, 0)); |
| 1495 MockRead reads[] = { | 1495 MockRead reads[] = { |
| 1496 CreateMockRead(resp, 2), CreateMockRead(body, 3), | 1496 CreateMockRead(resp, 2), CreateMockRead(body, 3), |
| 1497 MockRead(ASYNC, 0, 4) // EOF | 1497 MockRead(ASYNC, 0, 4) // EOF |
| 1498 }; | 1498 }; |
| 1499 | 1499 |
| 1500 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 1500 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 1501 NormalSpdyTransactionHelper helper(CreateFilePostRequest(), DEFAULT_PRIORITY, | 1501 NormalSpdyTransactionHelper helper(CreateFilePostRequest(), DEFAULT_PRIORITY, |
| 1502 BoundNetLog(), NULL); | 1502 NetLogWithSource(), NULL); |
| 1503 helper.RunToCompletion(&data); | 1503 helper.RunToCompletion(&data); |
| 1504 TransactionHelperResult out = helper.output(); | 1504 TransactionHelperResult out = helper.output(); |
| 1505 EXPECT_THAT(out.rv, IsOk()); | 1505 EXPECT_THAT(out.rv, IsOk()); |
| 1506 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 1506 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
| 1507 EXPECT_EQ("hello!", out.response_data); | 1507 EXPECT_EQ("hello!", out.response_data); |
| 1508 } | 1508 } |
| 1509 | 1509 |
| 1510 // Test that a POST with a unreadable file fails. | 1510 // Test that a POST with a unreadable file fails. |
| 1511 TEST_F(SpdyNetworkTransactionTest, UnreadableFilePost) { | 1511 TEST_F(SpdyNetworkTransactionTest, UnreadableFilePost) { |
| 1512 MockWrite writes[] = { | 1512 MockWrite writes[] = { |
| 1513 MockWrite(ASYNC, 0, 0) // EOF | 1513 MockWrite(ASYNC, 0, 0) // EOF |
| 1514 }; | 1514 }; |
| 1515 MockRead reads[] = { | 1515 MockRead reads[] = { |
| 1516 MockRead(ASYNC, 0, 1) // EOF | 1516 MockRead(ASYNC, 0, 1) // EOF |
| 1517 }; | 1517 }; |
| 1518 | 1518 |
| 1519 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 1519 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 1520 NormalSpdyTransactionHelper helper(CreateUnreadableFilePostRequest(), | 1520 NormalSpdyTransactionHelper helper(CreateUnreadableFilePostRequest(), |
| 1521 DEFAULT_PRIORITY, BoundNetLog(), NULL); | 1521 DEFAULT_PRIORITY, NetLogWithSource(), |
| 1522 NULL); |
| 1522 helper.RunPreTestSetup(); | 1523 helper.RunPreTestSetup(); |
| 1523 helper.AddData(&data); | 1524 helper.AddData(&data); |
| 1524 helper.RunDefaultTest(); | 1525 helper.RunDefaultTest(); |
| 1525 | 1526 |
| 1526 base::RunLoop().RunUntilIdle(); | 1527 base::RunLoop().RunUntilIdle(); |
| 1527 helper.VerifyDataNotConsumed(); | 1528 helper.VerifyDataNotConsumed(); |
| 1528 EXPECT_THAT(helper.output().rv, IsError(ERR_ACCESS_DENIED)); | 1529 EXPECT_THAT(helper.output().rv, IsError(ERR_ACCESS_DENIED)); |
| 1529 } | 1530 } |
| 1530 | 1531 |
| 1531 // Test that a complex POST works. | 1532 // Test that a complex POST works. |
| 1532 TEST_F(SpdyNetworkTransactionTest, ComplexPost) { | 1533 TEST_F(SpdyNetworkTransactionTest, ComplexPost) { |
| 1533 SpdySerializedFrame req(spdy_util_.ConstructSpdyPost( | 1534 SpdySerializedFrame req(spdy_util_.ConstructSpdyPost( |
| 1534 kDefaultUrl, 1, kUploadDataSize, LOWEST, NULL, 0)); | 1535 kDefaultUrl, 1, kUploadDataSize, LOWEST, NULL, 0)); |
| 1535 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); | 1536 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); |
| 1536 MockWrite writes[] = { | 1537 MockWrite writes[] = { |
| 1537 CreateMockWrite(req, 0), CreateMockWrite(body, 1), // POST upload frame | 1538 CreateMockWrite(req, 0), CreateMockWrite(body, 1), // POST upload frame |
| 1538 }; | 1539 }; |
| 1539 | 1540 |
| 1540 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostReply(NULL, 0)); | 1541 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostReply(NULL, 0)); |
| 1541 MockRead reads[] = { | 1542 MockRead reads[] = { |
| 1542 CreateMockRead(resp, 2), CreateMockRead(body, 3), | 1543 CreateMockRead(resp, 2), CreateMockRead(body, 3), |
| 1543 MockRead(ASYNC, 0, 4) // EOF | 1544 MockRead(ASYNC, 0, 4) // EOF |
| 1544 }; | 1545 }; |
| 1545 | 1546 |
| 1546 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 1547 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 1547 NormalSpdyTransactionHelper helper(CreateComplexPostRequest(), | 1548 NormalSpdyTransactionHelper helper( |
| 1548 DEFAULT_PRIORITY, BoundNetLog(), NULL); | 1549 CreateComplexPostRequest(), DEFAULT_PRIORITY, NetLogWithSource(), NULL); |
| 1549 helper.RunToCompletion(&data); | 1550 helper.RunToCompletion(&data); |
| 1550 TransactionHelperResult out = helper.output(); | 1551 TransactionHelperResult out = helper.output(); |
| 1551 EXPECT_THAT(out.rv, IsOk()); | 1552 EXPECT_THAT(out.rv, IsOk()); |
| 1552 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 1553 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
| 1553 EXPECT_EQ("hello!", out.response_data); | 1554 EXPECT_EQ("hello!", out.response_data); |
| 1554 } | 1555 } |
| 1555 | 1556 |
| 1556 // Test that a chunked POST works. | 1557 // Test that a chunked POST works. |
| 1557 TEST_F(SpdyNetworkTransactionTest, ChunkedPost) { | 1558 TEST_F(SpdyNetworkTransactionTest, ChunkedPost) { |
| 1558 SpdySerializedFrame req(spdy_util_.ConstructChunkedSpdyPost(NULL, 0)); | 1559 SpdySerializedFrame req(spdy_util_.ConstructChunkedSpdyPost(NULL, 0)); |
| 1559 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); | 1560 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); |
| 1560 MockWrite writes[] = { | 1561 MockWrite writes[] = { |
| 1561 CreateMockWrite(req, 0), CreateMockWrite(body, 1), | 1562 CreateMockWrite(req, 0), CreateMockWrite(body, 1), |
| 1562 }; | 1563 }; |
| 1563 | 1564 |
| 1564 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostReply(NULL, 0)); | 1565 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostReply(NULL, 0)); |
| 1565 MockRead reads[] = { | 1566 MockRead reads[] = { |
| 1566 CreateMockRead(resp, 2), CreateMockRead(body, 3), | 1567 CreateMockRead(resp, 2), CreateMockRead(body, 3), |
| 1567 MockRead(ASYNC, 0, 4) // EOF | 1568 MockRead(ASYNC, 0, 4) // EOF |
| 1568 }; | 1569 }; |
| 1569 | 1570 |
| 1570 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 1571 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 1571 NormalSpdyTransactionHelper helper(CreateChunkedPostRequest(), | 1572 NormalSpdyTransactionHelper helper( |
| 1572 DEFAULT_PRIORITY, BoundNetLog(), NULL); | 1573 CreateChunkedPostRequest(), DEFAULT_PRIORITY, NetLogWithSource(), NULL); |
| 1573 | 1574 |
| 1574 // These chunks get merged into a single frame when being sent. | 1575 // These chunks get merged into a single frame when being sent. |
| 1575 const int kFirstChunkSize = kUploadDataSize/2; | 1576 const int kFirstChunkSize = kUploadDataSize/2; |
| 1576 upload_chunked_data_stream()->AppendData(kUploadData, kFirstChunkSize, false); | 1577 upload_chunked_data_stream()->AppendData(kUploadData, kFirstChunkSize, false); |
| 1577 upload_chunked_data_stream()->AppendData( | 1578 upload_chunked_data_stream()->AppendData( |
| 1578 kUploadData + kFirstChunkSize, kUploadDataSize - kFirstChunkSize, true); | 1579 kUploadData + kFirstChunkSize, kUploadDataSize - kFirstChunkSize, true); |
| 1579 | 1580 |
| 1580 helper.RunToCompletion(&data); | 1581 helper.RunToCompletion(&data); |
| 1581 TransactionHelperResult out = helper.output(); | 1582 TransactionHelperResult out = helper.output(); |
| 1582 EXPECT_THAT(out.rv, IsOk()); | 1583 EXPECT_THAT(out.rv, IsOk()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1596 }; | 1597 }; |
| 1597 | 1598 |
| 1598 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostReply(NULL, 0)); | 1599 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostReply(NULL, 0)); |
| 1599 MockRead reads[] = { | 1600 MockRead reads[] = { |
| 1600 CreateMockRead(resp, 4), CreateMockRead(chunk1, 5), | 1601 CreateMockRead(resp, 4), CreateMockRead(chunk1, 5), |
| 1601 CreateMockRead(chunk2, 6), CreateMockRead(chunk3, 7), | 1602 CreateMockRead(chunk2, 6), CreateMockRead(chunk3, 7), |
| 1602 MockRead(ASYNC, 0, 8) // EOF | 1603 MockRead(ASYNC, 0, 8) // EOF |
| 1603 }; | 1604 }; |
| 1604 | 1605 |
| 1605 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 1606 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 1606 NormalSpdyTransactionHelper helper(CreateChunkedPostRequest(), | 1607 NormalSpdyTransactionHelper helper( |
| 1607 DEFAULT_PRIORITY, BoundNetLog(), NULL); | 1608 CreateChunkedPostRequest(), DEFAULT_PRIORITY, NetLogWithSource(), NULL); |
| 1608 | 1609 |
| 1609 upload_chunked_data_stream()->AppendData(kUploadData, kUploadDataSize, false); | 1610 upload_chunked_data_stream()->AppendData(kUploadData, kUploadDataSize, false); |
| 1610 | 1611 |
| 1611 helper.RunPreTestSetup(); | 1612 helper.RunPreTestSetup(); |
| 1612 helper.AddData(&data); | 1613 helper.AddData(&data); |
| 1613 ASSERT_TRUE(helper.StartDefaultTest()); | 1614 ASSERT_TRUE(helper.StartDefaultTest()); |
| 1614 | 1615 |
| 1615 base::RunLoop().RunUntilIdle(); | 1616 base::RunLoop().RunUntilIdle(); |
| 1616 upload_chunked_data_stream()->AppendData(kUploadData, kUploadDataSize, false); | 1617 upload_chunked_data_stream()->AppendData(kUploadData, kUploadDataSize, false); |
| 1617 base::RunLoop().RunUntilIdle(); | 1618 base::RunLoop().RunUntilIdle(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1653 | 1654 |
| 1654 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostReply(NULL, 0)); | 1655 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostReply(NULL, 0)); |
| 1655 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); | 1656 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); |
| 1656 MockRead reads[] = { | 1657 MockRead reads[] = { |
| 1657 CreateMockRead(resp, 1), CreateMockRead(body, 2), | 1658 CreateMockRead(resp, 1), CreateMockRead(body, 2), |
| 1658 MockRead(ASYNC, 0, 3) // EOF | 1659 MockRead(ASYNC, 0, 3) // EOF |
| 1659 }; | 1660 }; |
| 1660 | 1661 |
| 1661 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 1662 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 1662 | 1663 |
| 1663 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, BoundNetLog(), | 1664 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, |
| 1664 NULL); | 1665 NetLogWithSource(), NULL); |
| 1665 helper.RunToCompletion(&data); | 1666 helper.RunToCompletion(&data); |
| 1666 TransactionHelperResult out = helper.output(); | 1667 TransactionHelperResult out = helper.output(); |
| 1667 EXPECT_THAT(out.rv, IsOk()); | 1668 EXPECT_THAT(out.rv, IsOk()); |
| 1668 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 1669 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
| 1669 EXPECT_EQ("hello!", out.response_data); | 1670 EXPECT_EQ("hello!", out.response_data); |
| 1670 } | 1671 } |
| 1671 | 1672 |
| 1672 // Test that a simple POST works. | 1673 // Test that a simple POST works. |
| 1673 TEST_F(SpdyNetworkTransactionTest, EmptyPost) { | 1674 TEST_F(SpdyNetworkTransactionTest, EmptyPost) { |
| 1674 // Create an empty UploadDataStream. | 1675 // Create an empty UploadDataStream. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1694 | 1695 |
| 1695 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostReply(NULL, 0)); | 1696 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostReply(NULL, 0)); |
| 1696 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); | 1697 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); |
| 1697 MockRead reads[] = { | 1698 MockRead reads[] = { |
| 1698 CreateMockRead(resp, 1), CreateMockRead(body, 2), | 1699 CreateMockRead(resp, 1), CreateMockRead(body, 2), |
| 1699 MockRead(ASYNC, 0, 3) // EOF | 1700 MockRead(ASYNC, 0, 3) // EOF |
| 1700 }; | 1701 }; |
| 1701 | 1702 |
| 1702 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 1703 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 1703 | 1704 |
| 1704 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, BoundNetLog(), | 1705 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, |
| 1705 NULL); | 1706 NetLogWithSource(), NULL); |
| 1706 helper.RunToCompletion(&data); | 1707 helper.RunToCompletion(&data); |
| 1707 TransactionHelperResult out = helper.output(); | 1708 TransactionHelperResult out = helper.output(); |
| 1708 EXPECT_THAT(out.rv, IsOk()); | 1709 EXPECT_THAT(out.rv, IsOk()); |
| 1709 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 1710 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
| 1710 EXPECT_EQ("hello!", out.response_data); | 1711 EXPECT_EQ("hello!", out.response_data); |
| 1711 } | 1712 } |
| 1712 | 1713 |
| 1713 // While we're doing a post, the server sends the reply before upload completes. | 1714 // While we're doing a post, the server sends the reply before upload completes. |
| 1714 TEST_F(SpdyNetworkTransactionTest, ResponseBeforePostCompletes) { | 1715 TEST_F(SpdyNetworkTransactionTest, ResponseBeforePostCompletes) { |
| 1715 SpdySerializedFrame req(spdy_util_.ConstructChunkedSpdyPost(NULL, 0)); | 1716 SpdySerializedFrame req(spdy_util_.ConstructChunkedSpdyPost(NULL, 0)); |
| 1716 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); | 1717 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); |
| 1717 MockWrite writes[] = { | 1718 MockWrite writes[] = { |
| 1718 CreateMockWrite(req, 0), CreateMockWrite(body, 3), | 1719 CreateMockWrite(req, 0), CreateMockWrite(body, 3), |
| 1719 }; | 1720 }; |
| 1720 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostReply(NULL, 0)); | 1721 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostReply(NULL, 0)); |
| 1721 MockRead reads[] = { | 1722 MockRead reads[] = { |
| 1722 CreateMockRead(resp, 1), CreateMockRead(body, 2), | 1723 CreateMockRead(resp, 1), CreateMockRead(body, 2), |
| 1723 MockRead(ASYNC, 0, 4) // EOF | 1724 MockRead(ASYNC, 0, 4) // EOF |
| 1724 }; | 1725 }; |
| 1725 | 1726 |
| 1726 // Write the request headers, and read the complete response | 1727 // Write the request headers, and read the complete response |
| 1727 // while still waiting for chunked request data. | 1728 // while still waiting for chunked request data. |
| 1728 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 1729 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 1729 NormalSpdyTransactionHelper helper(CreateChunkedPostRequest(), | 1730 NormalSpdyTransactionHelper helper( |
| 1730 DEFAULT_PRIORITY, BoundNetLog(), NULL); | 1731 CreateChunkedPostRequest(), DEFAULT_PRIORITY, NetLogWithSource(), NULL); |
| 1731 helper.RunPreTestSetup(); | 1732 helper.RunPreTestSetup(); |
| 1732 helper.AddData(&data); | 1733 helper.AddData(&data); |
| 1733 | 1734 |
| 1734 ASSERT_TRUE(helper.StartDefaultTest()); | 1735 ASSERT_TRUE(helper.StartDefaultTest()); |
| 1735 | 1736 |
| 1736 base::RunLoop().RunUntilIdle(); | 1737 base::RunLoop().RunUntilIdle(); |
| 1737 | 1738 |
| 1738 // Process the request headers, response headers, and response body. | 1739 // Process the request headers, response headers, and response body. |
| 1739 // The request body is still in flight. | 1740 // The request body is still in flight. |
| 1740 const HttpResponseInfo* response = helper.trans()->GetResponseInfo(); | 1741 const HttpResponseInfo* response = helper.trans()->GetResponseInfo(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1764 CreateMockWrite(rst, 3, SYNCHRONOUS), | 1765 CreateMockWrite(rst, 3, SYNCHRONOUS), |
| 1765 }; | 1766 }; |
| 1766 | 1767 |
| 1767 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); | 1768 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); |
| 1768 MockRead reads[] = { | 1769 MockRead reads[] = { |
| 1769 CreateMockRead(resp, 1, ASYNC), MockRead(ASYNC, 0, 0, 4) // EOF | 1770 CreateMockRead(resp, 1, ASYNC), MockRead(ASYNC, 0, 0, 4) // EOF |
| 1770 }; | 1771 }; |
| 1771 | 1772 |
| 1772 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 1773 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 1773 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 1774 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 1774 BoundNetLog(), NULL); | 1775 NetLogWithSource(), NULL); |
| 1775 helper.RunPreTestSetup(); | 1776 helper.RunPreTestSetup(); |
| 1776 helper.AddData(&data); | 1777 helper.AddData(&data); |
| 1777 helper.StartDefaultTest(); | 1778 helper.StartDefaultTest(); |
| 1778 EXPECT_THAT(helper.output().rv, IsError(ERR_IO_PENDING)); | 1779 EXPECT_THAT(helper.output().rv, IsError(ERR_IO_PENDING)); |
| 1779 | 1780 |
| 1780 helper.WaitForCallbackToComplete(); | 1781 helper.WaitForCallbackToComplete(); |
| 1781 EXPECT_THAT(helper.output().rv, IsOk()); | 1782 EXPECT_THAT(helper.output().rv, IsOk()); |
| 1782 | 1783 |
| 1783 helper.ResetTrans(); | 1784 helper.ResetTrans(); |
| 1784 base::RunLoop().RunUntilIdle(); | 1785 base::RunLoop().RunUntilIdle(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1795 | 1796 |
| 1796 SpdySerializedFrame req( | 1797 SpdySerializedFrame req( |
| 1797 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 1798 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 1798 SpdySerializedFrame rst( | 1799 SpdySerializedFrame rst( |
| 1799 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); | 1800 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); |
| 1800 MockWrite writes[] = { | 1801 MockWrite writes[] = { |
| 1801 CreateMockWrite(req, 0), CreateMockWrite(rst, 2), | 1802 CreateMockWrite(req, 0), CreateMockWrite(rst, 2), |
| 1802 }; | 1803 }; |
| 1803 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 1804 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 1804 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 1805 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 1805 BoundNetLog(), NULL); | 1806 NetLogWithSource(), NULL); |
| 1806 helper.RunToCompletion(&data); | 1807 helper.RunToCompletion(&data); |
| 1807 TransactionHelperResult out = helper.output(); | 1808 TransactionHelperResult out = helper.output(); |
| 1808 EXPECT_THAT(out.rv, IsError(ERR_SPDY_PROTOCOL_ERROR)); | 1809 EXPECT_THAT(out.rv, IsError(ERR_SPDY_PROTOCOL_ERROR)); |
| 1809 } | 1810 } |
| 1810 | 1811 |
| 1811 // Test that the transaction doesn't crash when we get two replies on the same | 1812 // Test that the transaction doesn't crash when we get two replies on the same |
| 1812 // stream ID. See http://crbug.com/45639. | 1813 // stream ID. See http://crbug.com/45639. |
| 1813 TEST_F(SpdyNetworkTransactionTest, ResponseWithTwoSynReplies) { | 1814 TEST_F(SpdyNetworkTransactionTest, ResponseWithTwoSynReplies) { |
| 1814 SpdySerializedFrame req( | 1815 SpdySerializedFrame req( |
| 1815 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 1816 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 1816 SpdySerializedFrame rst( | 1817 SpdySerializedFrame rst( |
| 1817 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); | 1818 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); |
| 1818 MockWrite writes[] = { | 1819 MockWrite writes[] = { |
| 1819 CreateMockWrite(req, 0), CreateMockWrite(rst, 4), | 1820 CreateMockWrite(req, 0), CreateMockWrite(rst, 4), |
| 1820 }; | 1821 }; |
| 1821 | 1822 |
| 1822 SpdySerializedFrame resp0(spdy_util_.ConstructSpdyGetReply(nullptr, 0, 1)); | 1823 SpdySerializedFrame resp0(spdy_util_.ConstructSpdyGetReply(nullptr, 0, 1)); |
| 1823 SpdySerializedFrame resp1(spdy_util_.ConstructSpdyGetReply(nullptr, 0, 1)); | 1824 SpdySerializedFrame resp1(spdy_util_.ConstructSpdyGetReply(nullptr, 0, 1)); |
| 1824 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); | 1825 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); |
| 1825 MockRead reads[] = { | 1826 MockRead reads[] = { |
| 1826 CreateMockRead(resp0, 1), CreateMockRead(resp1, 2), | 1827 CreateMockRead(resp0, 1), CreateMockRead(resp1, 2), |
| 1827 CreateMockRead(body, 3), MockRead(ASYNC, 0, 5) // EOF | 1828 CreateMockRead(body, 3), MockRead(ASYNC, 0, 5) // EOF |
| 1828 }; | 1829 }; |
| 1829 | 1830 |
| 1830 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 1831 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 1831 | 1832 |
| 1832 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 1833 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 1833 BoundNetLog(), NULL); | 1834 NetLogWithSource(), NULL); |
| 1834 helper.RunPreTestSetup(); | 1835 helper.RunPreTestSetup(); |
| 1835 helper.AddData(&data); | 1836 helper.AddData(&data); |
| 1836 | 1837 |
| 1837 HttpNetworkTransaction* trans = helper.trans(); | 1838 HttpNetworkTransaction* trans = helper.trans(); |
| 1838 | 1839 |
| 1839 TestCompletionCallback callback; | 1840 TestCompletionCallback callback; |
| 1840 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); | 1841 int rv = |
| 1842 trans->Start(&helper.request(), callback.callback(), NetLogWithSource()); |
| 1841 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 1843 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 1842 rv = callback.WaitForResult(); | 1844 rv = callback.WaitForResult(); |
| 1843 EXPECT_THAT(rv, IsOk()); | 1845 EXPECT_THAT(rv, IsOk()); |
| 1844 | 1846 |
| 1845 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1847 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 1846 ASSERT_TRUE(response); | 1848 ASSERT_TRUE(response); |
| 1847 EXPECT_TRUE(response->headers); | 1849 EXPECT_TRUE(response->headers); |
| 1848 EXPECT_TRUE(response->was_fetched_via_spdy); | 1850 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 1849 std::string response_data; | 1851 std::string response_data; |
| 1850 rv = ReadTransaction(trans, &response_data); | 1852 rv = ReadTransaction(trans, &response_data); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1868 }; | 1870 }; |
| 1869 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(headers, 1, 1)); | 1871 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(headers, 1, 1)); |
| 1870 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); | 1872 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); |
| 1871 MockRead reads[] = { | 1873 MockRead reads[] = { |
| 1872 CreateMockRead(resp, 1), CreateMockRead(body, 3), | 1874 CreateMockRead(resp, 1), CreateMockRead(body, 3), |
| 1873 MockRead(ASYNC, 0, 4) // EOF | 1875 MockRead(ASYNC, 0, 4) // EOF |
| 1874 }; | 1876 }; |
| 1875 | 1877 |
| 1876 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 1878 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 1877 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 1879 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 1878 BoundNetLog(), NULL); | 1880 NetLogWithSource(), NULL); |
| 1879 helper.RunToCompletion(&data); | 1881 helper.RunToCompletion(&data); |
| 1880 TransactionHelperResult out = helper.output(); | 1882 TransactionHelperResult out = helper.output(); |
| 1881 EXPECT_THAT(out.rv, IsError(ERR_SPDY_PROTOCOL_ERROR)); | 1883 EXPECT_THAT(out.rv, IsError(ERR_SPDY_PROTOCOL_ERROR)); |
| 1882 | 1884 |
| 1883 helper.session()->spdy_session_pool()->CloseAllSessions(); | 1885 helper.session()->spdy_session_pool()->CloseAllSessions(); |
| 1884 helper.VerifyDataConsumed(); | 1886 helper.VerifyDataConsumed(); |
| 1885 } | 1887 } |
| 1886 | 1888 |
| 1887 TEST_F(SpdyNetworkTransactionTest, ResetPushWithTransferEncoding) { | 1889 TEST_F(SpdyNetworkTransactionTest, ResetPushWithTransferEncoding) { |
| 1888 // Construct the request. | 1890 // Construct the request. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1902 spdy_util_.ConstructSpdyPush(headers, arraysize(headers) / 2, 2, 1, | 1904 spdy_util_.ConstructSpdyPush(headers, arraysize(headers) / 2, 2, 1, |
| 1903 GetDefaultUrlWithPath("/1").c_str())); | 1905 GetDefaultUrlWithPath("/1").c_str())); |
| 1904 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); | 1906 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); |
| 1905 MockRead reads[] = { | 1907 MockRead reads[] = { |
| 1906 CreateMockRead(resp, 1), CreateMockRead(push, 2), CreateMockRead(body, 3), | 1908 CreateMockRead(resp, 1), CreateMockRead(push, 2), CreateMockRead(body, 3), |
| 1907 MockRead(ASYNC, 0, 5) // EOF | 1909 MockRead(ASYNC, 0, 5) // EOF |
| 1908 }; | 1910 }; |
| 1909 | 1911 |
| 1910 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 1912 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 1911 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 1913 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 1912 BoundNetLog(), NULL); | 1914 NetLogWithSource(), NULL); |
| 1913 helper.RunToCompletion(&data); | 1915 helper.RunToCompletion(&data); |
| 1914 TransactionHelperResult out = helper.output(); | 1916 TransactionHelperResult out = helper.output(); |
| 1915 EXPECT_THAT(out.rv, IsOk()); | 1917 EXPECT_THAT(out.rv, IsOk()); |
| 1916 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 1918 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
| 1917 EXPECT_EQ("hello!", out.response_data); | 1919 EXPECT_EQ("hello!", out.response_data); |
| 1918 | 1920 |
| 1919 helper.session()->spdy_session_pool()->CloseAllSessions(); | 1921 helper.session()->spdy_session_pool()->CloseAllSessions(); |
| 1920 helper.VerifyDataConsumed(); | 1922 helper.VerifyDataConsumed(); |
| 1921 } | 1923 } |
| 1922 | 1924 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1935 // RunUntilIdle() call at the end since the SpdySession survives the | 1937 // RunUntilIdle() call at the end since the SpdySession survives the |
| 1936 // HttpNetworkTransaction and still tries to continue Read()'ing. Any | 1938 // HttpNetworkTransaction and still tries to continue Read()'ing. Any |
| 1937 // MockRead will do here. | 1939 // MockRead will do here. |
| 1938 MockRead(ASYNC, 0, 0) // EOF | 1940 MockRead(ASYNC, 0, 0) // EOF |
| 1939 }; | 1941 }; |
| 1940 | 1942 |
| 1941 StaticSocketDataProvider data(reads, arraysize(reads), | 1943 StaticSocketDataProvider data(reads, arraysize(reads), |
| 1942 writes, arraysize(writes)); | 1944 writes, arraysize(writes)); |
| 1943 | 1945 |
| 1944 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 1946 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 1945 BoundNetLog(), NULL); | 1947 NetLogWithSource(), NULL); |
| 1946 helper.RunPreTestSetup(); | 1948 helper.RunPreTestSetup(); |
| 1947 helper.AddData(&data); | 1949 helper.AddData(&data); |
| 1948 HttpNetworkTransaction* trans = helper.trans(); | 1950 HttpNetworkTransaction* trans = helper.trans(); |
| 1949 | 1951 |
| 1950 TestCompletionCallback callback; | 1952 TestCompletionCallback callback; |
| 1951 int rv = trans->Start( | 1953 int rv = trans->Start(&CreateGetRequest(), callback.callback(), |
| 1952 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 1954 NetLogWithSource()); |
| 1953 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 1955 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 1954 helper.ResetTrans(); // Cancel the transaction. | 1956 helper.ResetTrans(); // Cancel the transaction. |
| 1955 | 1957 |
| 1956 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the | 1958 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the |
| 1957 // MockClientSocketFactory) are still alive. | 1959 // MockClientSocketFactory) are still alive. |
| 1958 base::RunLoop().RunUntilIdle(); | 1960 base::RunLoop().RunUntilIdle(); |
| 1959 helper.VerifyDataNotConsumed(); | 1961 helper.VerifyDataNotConsumed(); |
| 1960 } | 1962 } |
| 1961 | 1963 |
| 1962 // Verify that the client sends a Rst Frame upon cancelling the stream. | 1964 // Verify that the client sends a Rst Frame upon cancelling the stream. |
| 1963 TEST_F(SpdyNetworkTransactionTest, CancelledTransactionSendRst) { | 1965 TEST_F(SpdyNetworkTransactionTest, CancelledTransactionSendRst) { |
| 1964 SpdySerializedFrame req( | 1966 SpdySerializedFrame req( |
| 1965 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 1967 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 1966 SpdySerializedFrame rst( | 1968 SpdySerializedFrame rst( |
| 1967 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); | 1969 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); |
| 1968 MockWrite writes[] = { | 1970 MockWrite writes[] = { |
| 1969 CreateMockWrite(req, 0, SYNCHRONOUS), | 1971 CreateMockWrite(req, 0, SYNCHRONOUS), |
| 1970 CreateMockWrite(rst, 2, SYNCHRONOUS), | 1972 CreateMockWrite(rst, 2, SYNCHRONOUS), |
| 1971 }; | 1973 }; |
| 1972 | 1974 |
| 1973 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); | 1975 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); |
| 1974 MockRead reads[] = { | 1976 MockRead reads[] = { |
| 1975 CreateMockRead(resp, 1, ASYNC), MockRead(ASYNC, 0, 0, 3) // EOF | 1977 CreateMockRead(resp, 1, ASYNC), MockRead(ASYNC, 0, 0, 3) // EOF |
| 1976 }; | 1978 }; |
| 1977 | 1979 |
| 1978 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 1980 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 1979 | 1981 |
| 1980 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 1982 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 1981 BoundNetLog(), NULL); | 1983 NetLogWithSource(), NULL); |
| 1982 helper.RunPreTestSetup(); | 1984 helper.RunPreTestSetup(); |
| 1983 helper.AddData(&data); | 1985 helper.AddData(&data); |
| 1984 HttpNetworkTransaction* trans = helper.trans(); | 1986 HttpNetworkTransaction* trans = helper.trans(); |
| 1985 | 1987 |
| 1986 TestCompletionCallback callback; | 1988 TestCompletionCallback callback; |
| 1987 | 1989 |
| 1988 int rv = trans->Start( | 1990 int rv = trans->Start(&CreateGetRequest(), callback.callback(), |
| 1989 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 1991 NetLogWithSource()); |
| 1990 EXPECT_THAT(callback.GetResult(rv), IsOk()); | 1992 EXPECT_THAT(callback.GetResult(rv), IsOk()); |
| 1991 | 1993 |
| 1992 helper.ResetTrans(); | 1994 helper.ResetTrans(); |
| 1993 base::RunLoop().RunUntilIdle(); | 1995 base::RunLoop().RunUntilIdle(); |
| 1994 | 1996 |
| 1995 helper.VerifyDataConsumed(); | 1997 helper.VerifyDataConsumed(); |
| 1996 } | 1998 } |
| 1997 | 1999 |
| 1998 // Verify that the client can correctly deal with the user callback attempting | 2000 // Verify that the client can correctly deal with the user callback attempting |
| 1999 // to start another transaction on a session that is closing down. See | 2001 // to start another transaction on a session that is closing down. See |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2023 }; | 2025 }; |
| 2024 MockRead reads2[] = { | 2026 MockRead reads2[] = { |
| 2025 CreateMockRead(resp, 1), MockRead(ASYNC, 0, 0, 2), // EOF | 2027 CreateMockRead(resp, 1), MockRead(ASYNC, 0, 0, 2), // EOF |
| 2026 }; | 2028 }; |
| 2027 | 2029 |
| 2028 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 2030 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 2029 SequencedSocketData data2(reads2, arraysize(reads2), writes2, | 2031 SequencedSocketData data2(reads2, arraysize(reads2), writes2, |
| 2030 arraysize(writes2)); | 2032 arraysize(writes2)); |
| 2031 | 2033 |
| 2032 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 2034 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 2033 BoundNetLog(), NULL); | 2035 NetLogWithSource(), NULL); |
| 2034 helper.RunPreTestSetup(); | 2036 helper.RunPreTestSetup(); |
| 2035 helper.AddData(&data); | 2037 helper.AddData(&data); |
| 2036 helper.AddData(&data2); | 2038 helper.AddData(&data2); |
| 2037 HttpNetworkTransaction* trans = helper.trans(); | 2039 HttpNetworkTransaction* trans = helper.trans(); |
| 2038 | 2040 |
| 2039 // Start the transaction with basic parameters. | 2041 // Start the transaction with basic parameters. |
| 2040 TestCompletionCallback callback; | 2042 TestCompletionCallback callback; |
| 2041 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); | 2043 int rv = |
| 2044 trans->Start(&helper.request(), callback.callback(), NetLogWithSource()); |
| 2042 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 2045 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 2043 rv = callback.WaitForResult(); | 2046 rv = callback.WaitForResult(); |
| 2044 | 2047 |
| 2045 const int kSize = 3000; | 2048 const int kSize = 3000; |
| 2046 scoped_refptr<IOBuffer> buf(new IOBuffer(kSize)); | 2049 scoped_refptr<IOBuffer> buf(new IOBuffer(kSize)); |
| 2047 rv = trans->Read( | 2050 rv = trans->Read( |
| 2048 buf.get(), kSize, | 2051 buf.get(), kSize, |
| 2049 base::Bind(&SpdyNetworkTransactionTest::StartTransactionCallback, | 2052 base::Bind(&SpdyNetworkTransactionTest::StartTransactionCallback, |
| 2050 helper.session(), default_url_)); | 2053 helper.session(), default_url_)); |
| 2051 ASSERT_THAT(rv, IsError(ERR_IO_PENDING)); | 2054 ASSERT_THAT(rv, IsError(ERR_IO_PENDING)); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2071 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); | 2074 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); |
| 2072 MockRead reads[] = { | 2075 MockRead reads[] = { |
| 2073 CreateMockRead(resp, 1), | 2076 CreateMockRead(resp, 1), |
| 2074 MockRead(ASYNC, ERR_IO_PENDING, 2), // Force a pause | 2077 MockRead(ASYNC, ERR_IO_PENDING, 2), // Force a pause |
| 2075 CreateMockRead(body, 3), MockRead(ASYNC, 0, 0, 4), // EOF | 2078 CreateMockRead(body, 3), MockRead(ASYNC, 0, 0, 4), // EOF |
| 2076 }; | 2079 }; |
| 2077 | 2080 |
| 2078 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 2081 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 2079 | 2082 |
| 2080 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 2083 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 2081 BoundNetLog(), NULL); | 2084 NetLogWithSource(), NULL); |
| 2082 helper.RunPreTestSetup(); | 2085 helper.RunPreTestSetup(); |
| 2083 helper.AddData(&data); | 2086 helper.AddData(&data); |
| 2084 HttpNetworkTransaction* trans = helper.trans(); | 2087 HttpNetworkTransaction* trans = helper.trans(); |
| 2085 | 2088 |
| 2086 // Start the transaction with basic parameters. | 2089 // Start the transaction with basic parameters. |
| 2087 TestCompletionCallback callback; | 2090 TestCompletionCallback callback; |
| 2088 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); | 2091 int rv = |
| 2092 trans->Start(&helper.request(), callback.callback(), NetLogWithSource()); |
| 2089 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 2093 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 2090 rv = callback.WaitForResult(); | 2094 rv = callback.WaitForResult(); |
| 2091 | 2095 |
| 2092 // Setup a user callback which will delete the session, and clear out the | 2096 // Setup a user callback which will delete the session, and clear out the |
| 2093 // memory holding the stream object. Note that the callback deletes trans. | 2097 // memory holding the stream object. Note that the callback deletes trans. |
| 2094 const int kSize = 3000; | 2098 const int kSize = 3000; |
| 2095 scoped_refptr<IOBuffer> buf(new IOBuffer(kSize)); | 2099 scoped_refptr<IOBuffer> buf(new IOBuffer(kSize)); |
| 2096 rv = trans->Read( | 2100 rv = trans->Read( |
| 2097 buf.get(), | 2101 buf.get(), |
| 2098 kSize, | 2102 kSize, |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2524 MockRead reads[] = { | 2528 MockRead reads[] = { |
| 2525 CreateMockRead(stream1_reply, 1), | 2529 CreateMockRead(stream1_reply, 1), |
| 2526 CreateMockRead(stream2_syn, 2), | 2530 CreateMockRead(stream2_syn, 2), |
| 2527 CreateMockRead(stream2_rst, 3), | 2531 CreateMockRead(stream2_rst, 3), |
| 2528 CreateMockRead(stream1_body, 4, SYNCHRONOUS), | 2532 CreateMockRead(stream1_body, 4, SYNCHRONOUS), |
| 2529 MockRead(SYNCHRONOUS, ERR_IO_PENDING, 5), // Force a pause | 2533 MockRead(SYNCHRONOUS, ERR_IO_PENDING, 5), // Force a pause |
| 2530 }; | 2534 }; |
| 2531 | 2535 |
| 2532 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 2536 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 2533 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 2537 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 2534 BoundNetLog(), NULL); | 2538 NetLogWithSource(), NULL); |
| 2535 | 2539 |
| 2536 helper.RunPreTestSetup(); | 2540 helper.RunPreTestSetup(); |
| 2537 helper.AddData(&data); | 2541 helper.AddData(&data); |
| 2538 | 2542 |
| 2539 HttpNetworkTransaction* trans = helper.trans(); | 2543 HttpNetworkTransaction* trans = helper.trans(); |
| 2540 | 2544 |
| 2541 // Start the transaction with basic parameters. | 2545 // Start the transaction with basic parameters. |
| 2542 TestCompletionCallback callback; | 2546 TestCompletionCallback callback; |
| 2543 int rv = trans->Start( | 2547 int rv = trans->Start(&CreateGetRequest(), callback.callback(), |
| 2544 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 2548 NetLogWithSource()); |
| 2545 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 2549 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 2546 rv = callback.WaitForResult(); | 2550 rv = callback.WaitForResult(); |
| 2547 EXPECT_THAT(rv, IsOk()); | 2551 EXPECT_THAT(rv, IsOk()); |
| 2548 | 2552 |
| 2549 // Verify that we consumed all test data. | 2553 // Verify that we consumed all test data. |
| 2550 EXPECT_TRUE(data.AllReadDataConsumed()); | 2554 EXPECT_TRUE(data.AllReadDataConsumed()); |
| 2551 EXPECT_TRUE(data.AllWriteDataConsumed()); | 2555 EXPECT_TRUE(data.AllWriteDataConsumed()); |
| 2552 | 2556 |
| 2553 // Verify the response headers. | 2557 // Verify the response headers. |
| 2554 HttpResponseInfo response = *trans->GetResponseInfo(); | 2558 HttpResponseInfo response = *trans->GetResponseInfo(); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2717 SpdySerializedFrame stream1_reply( | 2721 SpdySerializedFrame stream1_reply( |
| 2718 spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); | 2722 spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); |
| 2719 SpdySerializedFrame stream2_syn(spdy_util_.ConstructSpdyPush( | 2723 SpdySerializedFrame stream2_syn(spdy_util_.ConstructSpdyPush( |
| 2720 NULL, 0, 2, 0, GetDefaultUrlWithPath("/foo.dat").c_str())); | 2724 NULL, 0, 2, 0, GetDefaultUrlWithPath("/foo.dat").c_str())); |
| 2721 MockRead reads[] = { | 2725 MockRead reads[] = { |
| 2722 CreateMockRead(stream1_reply, 1), CreateMockRead(stream2_syn, 2), | 2726 CreateMockRead(stream1_reply, 1), CreateMockRead(stream2_syn, 2), |
| 2723 }; | 2727 }; |
| 2724 | 2728 |
| 2725 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 2729 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 2726 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 2730 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 2727 BoundNetLog(), NULL); | 2731 NetLogWithSource(), NULL); |
| 2728 | 2732 |
| 2729 helper.RunPreTestSetup(); | 2733 helper.RunPreTestSetup(); |
| 2730 helper.AddData(&data); | 2734 helper.AddData(&data); |
| 2731 | 2735 |
| 2732 HttpNetworkTransaction* trans = helper.trans(); | 2736 HttpNetworkTransaction* trans = helper.trans(); |
| 2733 | 2737 |
| 2734 // Start the transaction with basic parameters. | 2738 // Start the transaction with basic parameters. |
| 2735 TestCompletionCallback callback; | 2739 TestCompletionCallback callback; |
| 2736 int rv = trans->Start( | 2740 int rv = trans->Start(&CreateGetRequest(), callback.callback(), |
| 2737 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 2741 NetLogWithSource()); |
| 2738 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 2742 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 2739 rv = callback.WaitForResult(); | 2743 rv = callback.WaitForResult(); |
| 2740 EXPECT_THAT(rv, IsOk()); | 2744 EXPECT_THAT(rv, IsOk()); |
| 2741 | 2745 |
| 2742 // Verify that we consumed all test data. | 2746 // Verify that we consumed all test data. |
| 2743 EXPECT_TRUE(data.AllReadDataConsumed()); | 2747 EXPECT_TRUE(data.AllReadDataConsumed()); |
| 2744 EXPECT_TRUE(data.AllWriteDataConsumed()); | 2748 EXPECT_TRUE(data.AllWriteDataConsumed()); |
| 2745 | 2749 |
| 2746 // Verify the response headers. | 2750 // Verify the response headers. |
| 2747 HttpResponseInfo response = *trans->GetResponseInfo(); | 2751 HttpResponseInfo response = *trans->GetResponseInfo(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2764 SpdySerializedFrame stream2_syn(spdy_util_.ConstructSpdyPush( | 2768 SpdySerializedFrame stream2_syn(spdy_util_.ConstructSpdyPush( |
| 2765 NULL, 0, 2, 9, GetDefaultUrlWithPath("/foo.dat").c_str())); | 2769 NULL, 0, 2, 9, GetDefaultUrlWithPath("/foo.dat").c_str())); |
| 2766 MockRead reads[] = { | 2770 MockRead reads[] = { |
| 2767 CreateMockRead(stream1_reply, 1), CreateMockRead(stream2_syn, 2), | 2771 CreateMockRead(stream1_reply, 1), CreateMockRead(stream2_syn, 2), |
| 2768 CreateMockRead(stream1_body, 4), | 2772 CreateMockRead(stream1_body, 4), |
| 2769 MockRead(SYNCHRONOUS, ERR_IO_PENDING, 5), // Force a pause | 2773 MockRead(SYNCHRONOUS, ERR_IO_PENDING, 5), // Force a pause |
| 2770 }; | 2774 }; |
| 2771 | 2775 |
| 2772 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 2776 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 2773 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 2777 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 2774 BoundNetLog(), NULL); | 2778 NetLogWithSource(), NULL); |
| 2775 | 2779 |
| 2776 helper.RunPreTestSetup(); | 2780 helper.RunPreTestSetup(); |
| 2777 helper.AddData(&data); | 2781 helper.AddData(&data); |
| 2778 | 2782 |
| 2779 HttpNetworkTransaction* trans = helper.trans(); | 2783 HttpNetworkTransaction* trans = helper.trans(); |
| 2780 | 2784 |
| 2781 // Start the transaction with basic parameters. | 2785 // Start the transaction with basic parameters. |
| 2782 TestCompletionCallback callback; | 2786 TestCompletionCallback callback; |
| 2783 int rv = trans->Start( | 2787 int rv = trans->Start(&CreateGetRequest(), callback.callback(), |
| 2784 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 2788 NetLogWithSource()); |
| 2785 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 2789 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 2786 rv = callback.WaitForResult(); | 2790 rv = callback.WaitForResult(); |
| 2787 EXPECT_THAT(rv, IsOk()); | 2791 EXPECT_THAT(rv, IsOk()); |
| 2788 | 2792 |
| 2789 // Verify that we consumed all test data. | 2793 // Verify that we consumed all test data. |
| 2790 EXPECT_TRUE(data.AllReadDataConsumed()); | 2794 EXPECT_TRUE(data.AllReadDataConsumed()); |
| 2791 EXPECT_TRUE(data.AllWriteDataConsumed()); | 2795 EXPECT_TRUE(data.AllWriteDataConsumed()); |
| 2792 | 2796 |
| 2793 // Verify the response headers. | 2797 // Verify the response headers. |
| 2794 HttpResponseInfo response = *trans->GetResponseInfo(); | 2798 HttpResponseInfo response = *trans->GetResponseInfo(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2814 SpdySerializedFrame stream2_syn(spdy_util_.ConstructInitialSpdyPushFrame( | 2818 SpdySerializedFrame stream2_syn(spdy_util_.ConstructInitialSpdyPushFrame( |
| 2815 std::move(incomplete_headers), 2, 1)); | 2819 std::move(incomplete_headers), 2, 1)); |
| 2816 MockRead reads[] = { | 2820 MockRead reads[] = { |
| 2817 CreateMockRead(stream1_reply, 1), CreateMockRead(stream2_syn, 2), | 2821 CreateMockRead(stream1_reply, 1), CreateMockRead(stream2_syn, 2), |
| 2818 CreateMockRead(stream1_body, 4), | 2822 CreateMockRead(stream1_body, 4), |
| 2819 MockRead(SYNCHRONOUS, ERR_IO_PENDING, 5) // Force a pause | 2823 MockRead(SYNCHRONOUS, ERR_IO_PENDING, 5) // Force a pause |
| 2820 }; | 2824 }; |
| 2821 | 2825 |
| 2822 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 2826 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 2823 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 2827 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 2824 BoundNetLog(), NULL); | 2828 NetLogWithSource(), NULL); |
| 2825 | 2829 |
| 2826 helper.RunPreTestSetup(); | 2830 helper.RunPreTestSetup(); |
| 2827 helper.AddData(&data); | 2831 helper.AddData(&data); |
| 2828 | 2832 |
| 2829 HttpNetworkTransaction* trans = helper.trans(); | 2833 HttpNetworkTransaction* trans = helper.trans(); |
| 2830 | 2834 |
| 2831 // Start the transaction with basic parameters. | 2835 // Start the transaction with basic parameters. |
| 2832 TestCompletionCallback callback; | 2836 TestCompletionCallback callback; |
| 2833 int rv = trans->Start( | 2837 int rv = trans->Start(&CreateGetRequest(), callback.callback(), |
| 2834 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 2838 NetLogWithSource()); |
| 2835 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 2839 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 2836 rv = callback.WaitForResult(); | 2840 rv = callback.WaitForResult(); |
| 2837 EXPECT_THAT(rv, IsOk()); | 2841 EXPECT_THAT(rv, IsOk()); |
| 2838 | 2842 |
| 2839 // Verify that we consumed all test data. | 2843 // Verify that we consumed all test data. |
| 2840 EXPECT_TRUE(data.AllReadDataConsumed()); | 2844 EXPECT_TRUE(data.AllReadDataConsumed()); |
| 2841 EXPECT_TRUE(data.AllWriteDataConsumed()); | 2845 EXPECT_TRUE(data.AllWriteDataConsumed()); |
| 2842 | 2846 |
| 2843 // Verify the response headers. | 2847 // Verify the response headers. |
| 2844 HttpResponseInfo response = *trans->GetResponseInfo(); | 2848 HttpResponseInfo response = *trans->GetResponseInfo(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2862 nullptr, 0, 2, 1, GetDefaultUrlWithPath("/foo.dat").c_str())); | 2866 nullptr, 0, 2, 1, GetDefaultUrlWithPath("/foo.dat").c_str())); |
| 2863 SpdySerializedFrame stream3_syn(spdy_util_.ConstructSpdyPush( | 2867 SpdySerializedFrame stream3_syn(spdy_util_.ConstructSpdyPush( |
| 2864 nullptr, 0, 4, 2, GetDefaultUrlWithPath("/bar.dat").c_str())); | 2868 nullptr, 0, 4, 2, GetDefaultUrlWithPath("/bar.dat").c_str())); |
| 2865 MockRead reads[] = { | 2869 MockRead reads[] = { |
| 2866 CreateMockRead(stream1_reply, 1), CreateMockRead(stream2_syn, 2), | 2870 CreateMockRead(stream1_reply, 1), CreateMockRead(stream2_syn, 2), |
| 2867 CreateMockRead(stream3_syn, 3), | 2871 CreateMockRead(stream3_syn, 3), |
| 2868 }; | 2872 }; |
| 2869 | 2873 |
| 2870 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 2874 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 2871 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 2875 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 2872 BoundNetLog(), nullptr); | 2876 NetLogWithSource(), nullptr); |
| 2873 helper.RunToCompletion(&data); | 2877 helper.RunToCompletion(&data); |
| 2874 } | 2878 } |
| 2875 | 2879 |
| 2876 // PUSH_PROMISE on a closed client-initiated stream should trigger RST_STREAM. | 2880 // PUSH_PROMISE on a closed client-initiated stream should trigger RST_STREAM. |
| 2877 TEST_F(SpdyNetworkTransactionTest, ServerPushOnClosedStream) { | 2881 TEST_F(SpdyNetworkTransactionTest, ServerPushOnClosedStream) { |
| 2878 SpdySerializedFrame stream1_syn( | 2882 SpdySerializedFrame stream1_syn( |
| 2879 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 2883 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 2880 SpdySerializedFrame rst( | 2884 SpdySerializedFrame rst( |
| 2881 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_INVALID_STREAM)); | 2885 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_INVALID_STREAM)); |
| 2882 MockWrite writes[] = { | 2886 MockWrite writes[] = { |
| 2883 CreateMockWrite(stream1_syn, 0), CreateMockWrite(rst, 5), | 2887 CreateMockWrite(stream1_syn, 0), CreateMockWrite(rst, 5), |
| 2884 }; | 2888 }; |
| 2885 | 2889 |
| 2886 SpdySerializedFrame stream1_reply( | 2890 SpdySerializedFrame stream1_reply( |
| 2887 spdy_util_.ConstructSpdyGetReply(nullptr, 0, 1)); | 2891 spdy_util_.ConstructSpdyGetReply(nullptr, 0, 1)); |
| 2888 SpdySerializedFrame stream1_body(spdy_util_.ConstructSpdyDataFrame(1, true)); | 2892 SpdySerializedFrame stream1_body(spdy_util_.ConstructSpdyDataFrame(1, true)); |
| 2889 SpdySerializedFrame stream2_syn(spdy_util_.ConstructSpdyPush( | 2893 SpdySerializedFrame stream2_syn(spdy_util_.ConstructSpdyPush( |
| 2890 nullptr, 0, 2, 1, GetDefaultUrlWithPath("/foo.dat").c_str())); | 2894 nullptr, 0, 2, 1, GetDefaultUrlWithPath("/foo.dat").c_str())); |
| 2891 MockRead reads[] = { | 2895 MockRead reads[] = { |
| 2892 CreateMockRead(stream1_reply, 1), CreateMockRead(stream1_body, 2), | 2896 CreateMockRead(stream1_reply, 1), CreateMockRead(stream1_body, 2), |
| 2893 CreateMockRead(stream2_syn, 3), MockRead(SYNCHRONOUS, ERR_IO_PENDING, 4), | 2897 CreateMockRead(stream2_syn, 3), MockRead(SYNCHRONOUS, ERR_IO_PENDING, 4), |
| 2894 }; | 2898 }; |
| 2895 | 2899 |
| 2896 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 2900 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 2897 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 2901 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 2898 BoundNetLog(), nullptr); | 2902 NetLogWithSource(), nullptr); |
| 2899 helper.RunPreTestSetup(); | 2903 helper.RunPreTestSetup(); |
| 2900 helper.AddData(&data); | 2904 helper.AddData(&data); |
| 2901 | 2905 |
| 2902 HttpNetworkTransaction* trans = helper.trans(); | 2906 HttpNetworkTransaction* trans = helper.trans(); |
| 2903 | 2907 |
| 2904 TestCompletionCallback callback; | 2908 TestCompletionCallback callback; |
| 2905 int rv = | 2909 int rv = trans->Start(&CreateGetRequest(), callback.callback(), |
| 2906 trans->Start(&CreateGetRequest(), callback.callback(), BoundNetLog()); | 2910 NetLogWithSource()); |
| 2907 rv = callback.GetResult(rv); | 2911 rv = callback.GetResult(rv); |
| 2908 EXPECT_THAT(rv, IsOk()); | 2912 EXPECT_THAT(rv, IsOk()); |
| 2909 HttpResponseInfo response = *trans->GetResponseInfo(); | 2913 HttpResponseInfo response = *trans->GetResponseInfo(); |
| 2910 EXPECT_TRUE(response.headers); | 2914 EXPECT_TRUE(response.headers); |
| 2911 EXPECT_EQ("HTTP/1.1 200", response.headers->GetStatusLine()); | 2915 EXPECT_EQ("HTTP/1.1 200", response.headers->GetStatusLine()); |
| 2912 | 2916 |
| 2913 EXPECT_TRUE(data.AllReadDataConsumed()); | 2917 EXPECT_TRUE(data.AllReadDataConsumed()); |
| 2914 EXPECT_TRUE(data.AllWriteDataConsumed()); | 2918 EXPECT_TRUE(data.AllWriteDataConsumed()); |
| 2915 VerifyStreamsClosed(helper); | 2919 VerifyStreamsClosed(helper); |
| 2916 } | 2920 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2938 nullptr, 0, 4, 2, GetDefaultUrlWithPath("/bar.dat").c_str())); | 2942 nullptr, 0, 4, 2, GetDefaultUrlWithPath("/bar.dat").c_str())); |
| 2939 | 2943 |
| 2940 MockRead reads[] = { | 2944 MockRead reads[] = { |
| 2941 CreateMockRead(stream1_reply, 1), CreateMockRead(stream2_syn, 2), | 2945 CreateMockRead(stream1_reply, 1), CreateMockRead(stream2_syn, 2), |
| 2942 CreateMockRead(stream1_body, 3), CreateMockRead(stream2_body, 4), | 2946 CreateMockRead(stream1_body, 3), CreateMockRead(stream2_body, 4), |
| 2943 MockRead(ASYNC, ERR_IO_PENDING, 5), CreateMockRead(stream3_syn, 6), | 2947 MockRead(ASYNC, ERR_IO_PENDING, 5), CreateMockRead(stream3_syn, 6), |
| 2944 }; | 2948 }; |
| 2945 | 2949 |
| 2946 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 2950 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 2947 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 2951 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 2948 BoundNetLog(), nullptr); | 2952 NetLogWithSource(), nullptr); |
| 2949 helper.RunPreTestSetup(); | 2953 helper.RunPreTestSetup(); |
| 2950 helper.AddData(&data); | 2954 helper.AddData(&data); |
| 2951 | 2955 |
| 2952 HttpNetworkTransaction* trans1 = helper.trans(); | 2956 HttpNetworkTransaction* trans1 = helper.trans(); |
| 2953 TestCompletionCallback callback1; | 2957 TestCompletionCallback callback1; |
| 2954 int rv = | 2958 int rv = trans1->Start(&CreateGetRequest(), callback1.callback(), |
| 2955 trans1->Start(&CreateGetRequest(), callback1.callback(), BoundNetLog()); | 2959 NetLogWithSource()); |
| 2956 rv = callback1.GetResult(rv); | 2960 rv = callback1.GetResult(rv); |
| 2957 EXPECT_THAT(rv, IsOk()); | 2961 EXPECT_THAT(rv, IsOk()); |
| 2958 HttpResponseInfo response = *trans1->GetResponseInfo(); | 2962 HttpResponseInfo response = *trans1->GetResponseInfo(); |
| 2959 EXPECT_TRUE(response.headers); | 2963 EXPECT_TRUE(response.headers); |
| 2960 EXPECT_EQ("HTTP/1.1 200", response.headers->GetStatusLine()); | 2964 EXPECT_EQ("HTTP/1.1 200", response.headers->GetStatusLine()); |
| 2961 | 2965 |
| 2962 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, helper.session()); | 2966 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, helper.session()); |
| 2963 TestCompletionCallback callback2; | 2967 TestCompletionCallback callback2; |
| 2964 rv = trans2.Start(&CreateGetPushRequest(), callback2.callback(), | 2968 rv = trans2.Start(&CreateGetPushRequest(), callback2.callback(), |
| 2965 BoundNetLog()); | 2969 NetLogWithSource()); |
| 2966 rv = callback2.GetResult(rv); | 2970 rv = callback2.GetResult(rv); |
| 2967 EXPECT_THAT(rv, IsOk()); | 2971 EXPECT_THAT(rv, IsOk()); |
| 2968 response = *trans2.GetResponseInfo(); | 2972 response = *trans2.GetResponseInfo(); |
| 2969 EXPECT_TRUE(response.headers); | 2973 EXPECT_TRUE(response.headers); |
| 2970 EXPECT_EQ("HTTP/1.1 200", response.headers->GetStatusLine()); | 2974 EXPECT_EQ("HTTP/1.1 200", response.headers->GetStatusLine()); |
| 2971 std::string result; | 2975 std::string result; |
| 2972 ReadResult(&trans2, &result); | 2976 ReadResult(&trans2, &result); |
| 2973 EXPECT_EQ(kPushedData, result); | 2977 EXPECT_EQ(kPushedData, result); |
| 2974 | 2978 |
| 2975 data.Resume(); | 2979 data.Resume(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3026 test_cases[i].extra_headers, test_cases[i].num_headers, 1)); | 3030 test_cases[i].extra_headers, test_cases[i].num_headers, 1)); |
| 3027 SpdySerializedFrame body(spdy_test_util.ConstructSpdyDataFrame(1, true)); | 3031 SpdySerializedFrame body(spdy_test_util.ConstructSpdyDataFrame(1, true)); |
| 3028 MockRead reads[] = { | 3032 MockRead reads[] = { |
| 3029 CreateMockRead(resp, 1), CreateMockRead(body, 2), | 3033 CreateMockRead(resp, 1), CreateMockRead(body, 2), |
| 3030 MockRead(ASYNC, 0, 3) // EOF | 3034 MockRead(ASYNC, 0, 3) // EOF |
| 3031 }; | 3035 }; |
| 3032 | 3036 |
| 3033 SequencedSocketData data(reads, arraysize(reads), writes, | 3037 SequencedSocketData data(reads, arraysize(reads), writes, |
| 3034 arraysize(writes)); | 3038 arraysize(writes)); |
| 3035 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3039 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 3036 BoundNetLog(), NULL); | 3040 NetLogWithSource(), NULL); |
| 3037 helper.RunToCompletion(&data); | 3041 helper.RunToCompletion(&data); |
| 3038 TransactionHelperResult out = helper.output(); | 3042 TransactionHelperResult out = helper.output(); |
| 3039 | 3043 |
| 3040 EXPECT_THAT(out.rv, IsOk()); | 3044 EXPECT_THAT(out.rv, IsOk()); |
| 3041 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 3045 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
| 3042 EXPECT_EQ("hello!", out.response_data); | 3046 EXPECT_EQ("hello!", out.response_data); |
| 3043 | 3047 |
| 3044 scoped_refptr<HttpResponseHeaders> headers = out.response_info.headers; | 3048 scoped_refptr<HttpResponseHeaders> headers = out.response_info.headers; |
| 3045 EXPECT_TRUE(headers); | 3049 EXPECT_TRUE(headers); |
| 3046 size_t iter = 0; | 3050 size_t iter = 0; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3132 | 3136 |
| 3133 HttpRequestInfo request = CreateGetRequest(); | 3137 HttpRequestInfo request = CreateGetRequest(); |
| 3134 for (int ct = 0; ct < header_count; ct++) { | 3138 for (int ct = 0; ct < header_count; ct++) { |
| 3135 const char* header_key = test_cases[i].extra_headers[0][ct * 2]; | 3139 const char* header_key = test_cases[i].extra_headers[0][ct * 2]; |
| 3136 const char* header_value = test_cases[i].extra_headers[0][ct * 2 + 1]; | 3140 const char* header_value = test_cases[i].extra_headers[0][ct * 2 + 1]; |
| 3137 request.extra_headers.SetHeader(header_key, header_value); | 3141 request.extra_headers.SetHeader(header_key, header_value); |
| 3138 } | 3142 } |
| 3139 | 3143 |
| 3140 SequencedSocketData data(reads, arraysize(reads), writes, | 3144 SequencedSocketData data(reads, arraysize(reads), writes, |
| 3141 arraysize(writes)); | 3145 arraysize(writes)); |
| 3142 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, BoundNetLog(), | 3146 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, |
| 3143 NULL); | 3147 NetLogWithSource(), NULL); |
| 3144 helper.RunToCompletion(&data); | 3148 helper.RunToCompletion(&data); |
| 3145 TransactionHelperResult out = helper.output(); | 3149 TransactionHelperResult out = helper.output(); |
| 3146 | 3150 |
| 3147 EXPECT_EQ(OK, out.rv) << i; | 3151 EXPECT_EQ(OK, out.rv) << i; |
| 3148 EXPECT_EQ("HTTP/1.1 200", out.status_line) << i; | 3152 EXPECT_EQ("HTTP/1.1 200", out.status_line) << i; |
| 3149 EXPECT_EQ("hello!", out.response_data) << i; | 3153 EXPECT_EQ("hello!", out.response_data) << i; |
| 3150 | 3154 |
| 3151 // Test the response information. | 3155 // Test the response information. |
| 3152 EXPECT_EQ(out.response_info.vary_data.is_valid(), | 3156 EXPECT_EQ(out.response_info.vary_data.is_valid(), |
| 3153 test_cases[i].vary_matches) << i; | 3157 test_cases[i].vary_matches) << i; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3207 test_cases[i].headers, test_cases[i].num_headers, &reply_headers); | 3211 test_cases[i].headers, test_cases[i].num_headers, &reply_headers); |
| 3208 SpdySerializedFrame resp( | 3212 SpdySerializedFrame resp( |
| 3209 spdy_test_util.ConstructSpdyReply(1, std::move(reply_headers))); | 3213 spdy_test_util.ConstructSpdyReply(1, std::move(reply_headers))); |
| 3210 MockRead reads[] = { | 3214 MockRead reads[] = { |
| 3211 CreateMockRead(resp, 1), MockRead(ASYNC, 0, 3) // EOF | 3215 CreateMockRead(resp, 1), MockRead(ASYNC, 0, 3) // EOF |
| 3212 }; | 3216 }; |
| 3213 | 3217 |
| 3214 SequencedSocketData data(reads, arraysize(reads), writes, | 3218 SequencedSocketData data(reads, arraysize(reads), writes, |
| 3215 arraysize(writes)); | 3219 arraysize(writes)); |
| 3216 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3220 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 3217 BoundNetLog(), NULL); | 3221 NetLogWithSource(), NULL); |
| 3218 helper.RunToCompletion(&data); | 3222 helper.RunToCompletion(&data); |
| 3219 TransactionHelperResult out = helper.output(); | 3223 TransactionHelperResult out = helper.output(); |
| 3220 EXPECT_THAT(out.rv, IsError(ERR_SPDY_PROTOCOL_ERROR)); | 3224 EXPECT_THAT(out.rv, IsError(ERR_SPDY_PROTOCOL_ERROR)); |
| 3221 } | 3225 } |
| 3222 } | 3226 } |
| 3223 | 3227 |
| 3224 TEST_F(SpdyNetworkTransactionTest, CorruptFrameSessionError) { | 3228 TEST_F(SpdyNetworkTransactionTest, CorruptFrameSessionError) { |
| 3225 SpdySerializedFrame req( | 3229 SpdySerializedFrame req( |
| 3226 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 3230 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 3227 SpdySerializedFrame goaway(spdy_util_.ConstructSpdyGoAway( | 3231 SpdySerializedFrame goaway(spdy_util_.ConstructSpdyGoAway( |
| 3228 0, GOAWAY_COMPRESSION_ERROR, "Framer error: 6 (DECOMPRESS_FAILURE).")); | 3232 0, GOAWAY_COMPRESSION_ERROR, "Framer error: 6 (DECOMPRESS_FAILURE).")); |
| 3229 MockWrite writes[] = {CreateMockWrite(req, 0), CreateMockWrite(goaway, 2)}; | 3233 MockWrite writes[] = {CreateMockWrite(req, 0), CreateMockWrite(goaway, 2)}; |
| 3230 | 3234 |
| 3231 // This is the length field that's too short. | 3235 // This is the length field that's too short. |
| 3232 SpdySerializedFrame reply_wrong_length( | 3236 SpdySerializedFrame reply_wrong_length( |
| 3233 spdy_util_.ConstructSpdyGetReply(nullptr, 0, 1)); | 3237 spdy_util_.ConstructSpdyGetReply(nullptr, 0, 1)); |
| 3234 size_t right_size = | 3238 size_t right_size = |
| 3235 reply_wrong_length.size() - SpdyConstants::GetFrameHeaderSize(HTTP2); | 3239 reply_wrong_length.size() - SpdyConstants::GetFrameHeaderSize(HTTP2); |
| 3236 size_t wrong_size = right_size - 4; | 3240 size_t wrong_size = right_size - 4; |
| 3237 test::SetFrameLength(&reply_wrong_length, wrong_size, HTTP2); | 3241 test::SetFrameLength(&reply_wrong_length, wrong_size, HTTP2); |
| 3238 | 3242 |
| 3239 MockRead reads[] = { | 3243 MockRead reads[] = { |
| 3240 MockRead(ASYNC, reply_wrong_length.data(), reply_wrong_length.size() - 4, | 3244 MockRead(ASYNC, reply_wrong_length.data(), reply_wrong_length.size() - 4, |
| 3241 1), | 3245 1), |
| 3242 }; | 3246 }; |
| 3243 | 3247 |
| 3244 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 3248 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 3245 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3249 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 3246 BoundNetLog(), NULL); | 3250 NetLogWithSource(), NULL); |
| 3247 helper.RunToCompletion(&data); | 3251 helper.RunToCompletion(&data); |
| 3248 TransactionHelperResult out = helper.output(); | 3252 TransactionHelperResult out = helper.output(); |
| 3249 EXPECT_THAT(out.rv, IsError(ERR_SPDY_COMPRESSION_ERROR)); | 3253 EXPECT_THAT(out.rv, IsError(ERR_SPDY_COMPRESSION_ERROR)); |
| 3250 } | 3254 } |
| 3251 | 3255 |
| 3252 TEST_F(SpdyNetworkTransactionTest, GoAwayOnDecompressionFailure) { | 3256 TEST_F(SpdyNetworkTransactionTest, GoAwayOnDecompressionFailure) { |
| 3253 SpdySerializedFrame req( | 3257 SpdySerializedFrame req( |
| 3254 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 3258 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 3255 SpdySerializedFrame goaway(spdy_util_.ConstructSpdyGoAway( | 3259 SpdySerializedFrame goaway(spdy_util_.ConstructSpdyGoAway( |
| 3256 0, GOAWAY_COMPRESSION_ERROR, "Framer error: 6 (DECOMPRESS_FAILURE).")); | 3260 0, GOAWAY_COMPRESSION_ERROR, "Framer error: 6 (DECOMPRESS_FAILURE).")); |
| 3257 MockWrite writes[] = {CreateMockWrite(req, 0), CreateMockWrite(goaway, 2)}; | 3261 MockWrite writes[] = {CreateMockWrite(req, 0), CreateMockWrite(goaway, 2)}; |
| 3258 | 3262 |
| 3259 // Read HEADERS with corrupted payload. | 3263 // Read HEADERS with corrupted payload. |
| 3260 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); | 3264 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); |
| 3261 memset(resp.data() + 12, 0xcf, resp.size() - 12); | 3265 memset(resp.data() + 12, 0xcf, resp.size() - 12); |
| 3262 MockRead reads[] = {CreateMockRead(resp, 1)}; | 3266 MockRead reads[] = {CreateMockRead(resp, 1)}; |
| 3263 | 3267 |
| 3264 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 3268 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 3265 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3269 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 3266 BoundNetLog(), NULL); | 3270 NetLogWithSource(), NULL); |
| 3267 helper.RunToCompletion(&data); | 3271 helper.RunToCompletion(&data); |
| 3268 TransactionHelperResult out = helper.output(); | 3272 TransactionHelperResult out = helper.output(); |
| 3269 EXPECT_THAT(out.rv, IsError(ERR_SPDY_COMPRESSION_ERROR)); | 3273 EXPECT_THAT(out.rv, IsError(ERR_SPDY_COMPRESSION_ERROR)); |
| 3270 } | 3274 } |
| 3271 | 3275 |
| 3272 TEST_F(SpdyNetworkTransactionTest, GoAwayOnFrameSizeError) { | 3276 TEST_F(SpdyNetworkTransactionTest, GoAwayOnFrameSizeError) { |
| 3273 SpdySerializedFrame req( | 3277 SpdySerializedFrame req( |
| 3274 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 3278 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 3275 SpdySerializedFrame goaway(spdy_util_.ConstructSpdyGoAway( | 3279 SpdySerializedFrame goaway(spdy_util_.ConstructSpdyGoAway( |
| 3276 0, GOAWAY_FRAME_SIZE_ERROR, | 3280 0, GOAWAY_FRAME_SIZE_ERROR, |
| 3277 "Framer error: 15 (INVALID_CONTROL_FRAME_SIZE).")); | 3281 "Framer error: 15 (INVALID_CONTROL_FRAME_SIZE).")); |
| 3278 MockWrite writes[] = {CreateMockWrite(req, 0), CreateMockWrite(goaway, 2)}; | 3282 MockWrite writes[] = {CreateMockWrite(req, 0), CreateMockWrite(goaway, 2)}; |
| 3279 | 3283 |
| 3280 // Read WINDOW_UPDATE with incorrectly-sized payload. | 3284 // Read WINDOW_UPDATE with incorrectly-sized payload. |
| 3281 SpdySerializedFrame bad_window_update( | 3285 SpdySerializedFrame bad_window_update( |
| 3282 spdy_util_.ConstructSpdyWindowUpdate(1, 1)); | 3286 spdy_util_.ConstructSpdyWindowUpdate(1, 1)); |
| 3283 test::SetFrameLength(&bad_window_update, bad_window_update.size() - 1, HTTP2); | 3287 test::SetFrameLength(&bad_window_update, bad_window_update.size() - 1, HTTP2); |
| 3284 MockRead reads[] = {CreateMockRead(bad_window_update, 1)}; | 3288 MockRead reads[] = {CreateMockRead(bad_window_update, 1)}; |
| 3285 | 3289 |
| 3286 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 3290 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 3287 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3291 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 3288 BoundNetLog(), NULL); | 3292 NetLogWithSource(), NULL); |
| 3289 helper.RunToCompletion(&data); | 3293 helper.RunToCompletion(&data); |
| 3290 TransactionHelperResult out = helper.output(); | 3294 TransactionHelperResult out = helper.output(); |
| 3291 EXPECT_THAT(out.rv, IsError(ERR_SPDY_FRAME_SIZE_ERROR)); | 3295 EXPECT_THAT(out.rv, IsError(ERR_SPDY_FRAME_SIZE_ERROR)); |
| 3292 } | 3296 } |
| 3293 | 3297 |
| 3294 // Test that we shutdown correctly on write errors. | 3298 // Test that we shutdown correctly on write errors. |
| 3295 TEST_F(SpdyNetworkTransactionTest, WriteError) { | 3299 TEST_F(SpdyNetworkTransactionTest, WriteError) { |
| 3296 SpdySerializedFrame req( | 3300 SpdySerializedFrame req( |
| 3297 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 3301 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 3298 MockWrite writes[] = { | 3302 MockWrite writes[] = { |
| 3299 // We'll write 10 bytes successfully | 3303 // We'll write 10 bytes successfully |
| 3300 MockWrite(ASYNC, req.data(), 10, 1), | 3304 MockWrite(ASYNC, req.data(), 10, 1), |
| 3301 // Followed by ERROR! | 3305 // Followed by ERROR! |
| 3302 MockWrite(ASYNC, ERR_FAILED, 2), | 3306 MockWrite(ASYNC, ERR_FAILED, 2), |
| 3303 // Session drains and attempts to write a GOAWAY: Another ERROR! | 3307 // Session drains and attempts to write a GOAWAY: Another ERROR! |
| 3304 MockWrite(ASYNC, ERR_FAILED, 3), | 3308 MockWrite(ASYNC, ERR_FAILED, 3), |
| 3305 }; | 3309 }; |
| 3306 | 3310 |
| 3307 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; | 3311 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; |
| 3308 | 3312 |
| 3309 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 3313 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 3310 | 3314 |
| 3311 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3315 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 3312 BoundNetLog(), NULL); | 3316 NetLogWithSource(), NULL); |
| 3313 helper.RunPreTestSetup(); | 3317 helper.RunPreTestSetup(); |
| 3314 helper.AddData(&data); | 3318 helper.AddData(&data); |
| 3315 EXPECT_TRUE(helper.StartDefaultTest()); | 3319 EXPECT_TRUE(helper.StartDefaultTest()); |
| 3316 helper.FinishDefaultTest(); | 3320 helper.FinishDefaultTest(); |
| 3317 EXPECT_TRUE(data.AllWriteDataConsumed()); | 3321 EXPECT_TRUE(data.AllWriteDataConsumed()); |
| 3318 EXPECT_TRUE(data.AllReadDataConsumed()); | 3322 EXPECT_TRUE(data.AllReadDataConsumed()); |
| 3319 TransactionHelperResult out = helper.output(); | 3323 TransactionHelperResult out = helper.output(); |
| 3320 EXPECT_THAT(out.rv, IsError(ERR_FAILED)); | 3324 EXPECT_THAT(out.rv, IsError(ERR_FAILED)); |
| 3321 } | 3325 } |
| 3322 | 3326 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 3333 | 3337 |
| 3334 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); | 3338 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); |
| 3335 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); | 3339 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); |
| 3336 MockRead reads[] = { | 3340 MockRead reads[] = { |
| 3337 CreateMockRead(resp, kChunks), CreateMockRead(body, kChunks + 1), | 3341 CreateMockRead(resp, kChunks), CreateMockRead(body, kChunks + 1), |
| 3338 MockRead(ASYNC, 0, kChunks + 2) // EOF | 3342 MockRead(ASYNC, 0, kChunks + 2) // EOF |
| 3339 }; | 3343 }; |
| 3340 | 3344 |
| 3341 SequencedSocketData data(reads, arraysize(reads), writes.get(), kChunks); | 3345 SequencedSocketData data(reads, arraysize(reads), writes.get(), kChunks); |
| 3342 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3346 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 3343 BoundNetLog(), NULL); | 3347 NetLogWithSource(), NULL); |
| 3344 helper.RunToCompletion(&data); | 3348 helper.RunToCompletion(&data); |
| 3345 TransactionHelperResult out = helper.output(); | 3349 TransactionHelperResult out = helper.output(); |
| 3346 EXPECT_THAT(out.rv, IsOk()); | 3350 EXPECT_THAT(out.rv, IsOk()); |
| 3347 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 3351 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
| 3348 EXPECT_EQ("hello!", out.response_data); | 3352 EXPECT_EQ("hello!", out.response_data); |
| 3349 } | 3353 } |
| 3350 | 3354 |
| 3351 // Test that the NetLog contains good data for a simple GET request. | 3355 // Test that the NetLog contains good data for a simple GET request. |
| 3352 TEST_F(SpdyNetworkTransactionTest, NetLog) { | 3356 TEST_F(SpdyNetworkTransactionTest, NetLog) { |
| 3353 static const char* const kExtraHeaders[] = { | 3357 static const char* const kExtraHeaders[] = { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3462 MockRead(ASYNC, ERR_IO_PENDING, 4), // Force a pause | 3466 MockRead(ASYNC, ERR_IO_PENDING, 4), // Force a pause |
| 3463 CreateMockRead(last_frame, 5), | 3467 CreateMockRead(last_frame, 5), |
| 3464 MockRead(ASYNC, 0, 6) // EOF | 3468 MockRead(ASYNC, 0, 6) // EOF |
| 3465 }; | 3469 }; |
| 3466 | 3470 |
| 3467 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 3471 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 3468 | 3472 |
| 3469 TestCompletionCallback callback; | 3473 TestCompletionCallback callback; |
| 3470 | 3474 |
| 3471 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3475 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 3472 BoundNetLog(), NULL); | 3476 NetLogWithSource(), NULL); |
| 3473 helper.RunPreTestSetup(); | 3477 helper.RunPreTestSetup(); |
| 3474 helper.AddData(&data); | 3478 helper.AddData(&data); |
| 3475 HttpNetworkTransaction* trans = helper.trans(); | 3479 HttpNetworkTransaction* trans = helper.trans(); |
| 3476 int rv = trans->Start( | 3480 int rv = trans->Start(&CreateGetRequest(), callback.callback(), |
| 3477 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 3481 NetLogWithSource()); |
| 3478 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 3482 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 3479 | 3483 |
| 3480 TransactionHelperResult out = helper.output(); | 3484 TransactionHelperResult out = helper.output(); |
| 3481 out.rv = callback.WaitForResult(); | 3485 out.rv = callback.WaitForResult(); |
| 3482 EXPECT_EQ(out.rv, OK); | 3486 EXPECT_EQ(out.rv, OK); |
| 3483 | 3487 |
| 3484 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3488 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 3485 EXPECT_TRUE(response->headers); | 3489 EXPECT_TRUE(response->headers); |
| 3486 EXPECT_TRUE(response->was_fetched_via_spdy); | 3490 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 3487 out.status_line = response->headers->GetStatusLine(); | 3491 out.status_line = response->headers->GetStatusLine(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3545 MockRead reads[] = { | 3549 MockRead reads[] = { |
| 3546 CreateMockRead(resp, 1), | 3550 CreateMockRead(resp, 1), |
| 3547 MockRead(ASYNC, ERR_IO_PENDING, 2), // Force a pause | 3551 MockRead(ASYNC, ERR_IO_PENDING, 2), // Force a pause |
| 3548 MockRead(ASYNC, combined_data_frames, combined_data_frames_len, 3), | 3552 MockRead(ASYNC, combined_data_frames, combined_data_frames_len, 3), |
| 3549 MockRead(ASYNC, 0, 4) // EOF | 3553 MockRead(ASYNC, 0, 4) // EOF |
| 3550 }; | 3554 }; |
| 3551 | 3555 |
| 3552 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 3556 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 3553 | 3557 |
| 3554 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3558 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 3555 BoundNetLog(), NULL); | 3559 NetLogWithSource(), NULL); |
| 3556 helper.RunPreTestSetup(); | 3560 helper.RunPreTestSetup(); |
| 3557 helper.AddData(&data); | 3561 helper.AddData(&data); |
| 3558 HttpNetworkTransaction* trans = helper.trans(); | 3562 HttpNetworkTransaction* trans = helper.trans(); |
| 3559 | 3563 |
| 3560 TestCompletionCallback callback; | 3564 TestCompletionCallback callback; |
| 3561 int rv = trans->Start( | 3565 int rv = trans->Start(&CreateGetRequest(), callback.callback(), |
| 3562 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 3566 NetLogWithSource()); |
| 3563 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 3567 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 3564 | 3568 |
| 3565 TransactionHelperResult out = helper.output(); | 3569 TransactionHelperResult out = helper.output(); |
| 3566 out.rv = callback.WaitForResult(); | 3570 out.rv = callback.WaitForResult(); |
| 3567 EXPECT_EQ(out.rv, OK); | 3571 EXPECT_EQ(out.rv, OK); |
| 3568 | 3572 |
| 3569 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3573 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 3570 EXPECT_TRUE(response->headers); | 3574 EXPECT_TRUE(response->headers); |
| 3571 EXPECT_TRUE(response->was_fetched_via_spdy); | 3575 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 3572 out.status_line = response->headers->GetStatusLine(); | 3576 out.status_line = response->headers->GetStatusLine(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3631 combined_frames, arraysize(combined_frames)); | 3635 combined_frames, arraysize(combined_frames)); |
| 3632 | 3636 |
| 3633 MockRead reads[] = { | 3637 MockRead reads[] = { |
| 3634 MockRead(ASYNC, combined_frames, combined_frames_len, 1), | 3638 MockRead(ASYNC, combined_frames, combined_frames_len, 1), |
| 3635 MockRead(ASYNC, 0, 2) // EOF | 3639 MockRead(ASYNC, 0, 2) // EOF |
| 3636 }; | 3640 }; |
| 3637 | 3641 |
| 3638 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 3642 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 3639 | 3643 |
| 3640 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3644 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 3641 BoundNetLog(), NULL); | 3645 NetLogWithSource(), NULL); |
| 3642 helper.RunPreTestSetup(); | 3646 helper.RunPreTestSetup(); |
| 3643 helper.AddData(&data); | 3647 helper.AddData(&data); |
| 3644 HttpNetworkTransaction* trans = helper.trans(); | 3648 HttpNetworkTransaction* trans = helper.trans(); |
| 3645 | 3649 |
| 3646 TestCompletionCallback callback; | 3650 TestCompletionCallback callback; |
| 3647 int rv = trans->Start( | 3651 int rv = trans->Start(&CreateGetRequest(), callback.callback(), |
| 3648 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 3652 NetLogWithSource()); |
| 3649 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 3653 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 3650 | 3654 |
| 3651 TransactionHelperResult out = helper.output(); | 3655 TransactionHelperResult out = helper.output(); |
| 3652 out.rv = callback.WaitForResult(); | 3656 out.rv = callback.WaitForResult(); |
| 3653 EXPECT_EQ(out.rv, OK); | 3657 EXPECT_EQ(out.rv, OK); |
| 3654 | 3658 |
| 3655 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3659 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 3656 EXPECT_TRUE(response->headers); | 3660 EXPECT_TRUE(response->headers); |
| 3657 EXPECT_TRUE(response->was_fetched_via_spdy); | 3661 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 3658 out.status_line = response->headers->GetStatusLine(); | 3662 out.status_line = response->headers->GetStatusLine(); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3713 MockRead reads[] = { | 3717 MockRead reads[] = { |
| 3714 CreateMockRead(resp, 1), | 3718 CreateMockRead(resp, 1), |
| 3715 MockRead(ASYNC, ERR_IO_PENDING, 2), // Force a wait | 3719 MockRead(ASYNC, ERR_IO_PENDING, 2), // Force a wait |
| 3716 MockRead(ASYNC, combined_data_frames, combined_data_frames_len, 3), | 3720 MockRead(ASYNC, combined_data_frames, combined_data_frames_len, 3), |
| 3717 MockRead(ASYNC, 0, 4) // EOF | 3721 MockRead(ASYNC, 0, 4) // EOF |
| 3718 }; | 3722 }; |
| 3719 | 3723 |
| 3720 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 3724 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 3721 | 3725 |
| 3722 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3726 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 3723 BoundNetLog(), NULL); | 3727 NetLogWithSource(), NULL); |
| 3724 helper.RunPreTestSetup(); | 3728 helper.RunPreTestSetup(); |
| 3725 helper.AddData(&data); | 3729 helper.AddData(&data); |
| 3726 HttpNetworkTransaction* trans = helper.trans(); | 3730 HttpNetworkTransaction* trans = helper.trans(); |
| 3727 | 3731 |
| 3728 TestCompletionCallback callback; | 3732 TestCompletionCallback callback; |
| 3729 | 3733 |
| 3730 int rv = trans->Start( | 3734 int rv = trans->Start(&CreateGetRequest(), callback.callback(), |
| 3731 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 3735 NetLogWithSource()); |
| 3732 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 3736 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 3733 | 3737 |
| 3734 TransactionHelperResult out = helper.output(); | 3738 TransactionHelperResult out = helper.output(); |
| 3735 out.rv = callback.WaitForResult(); | 3739 out.rv = callback.WaitForResult(); |
| 3736 EXPECT_EQ(out.rv, OK); | 3740 EXPECT_EQ(out.rv, OK); |
| 3737 | 3741 |
| 3738 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3742 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 3739 EXPECT_TRUE(response->headers); | 3743 EXPECT_TRUE(response->headers); |
| 3740 EXPECT_TRUE(response->was_fetched_via_spdy); | 3744 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 3741 out.status_line = response->headers->GetStatusLine(); | 3745 out.status_line = response->headers->GetStatusLine(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3792 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); | 3796 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); |
| 3793 MockRead reads[] = { | 3797 MockRead reads[] = { |
| 3794 CreateMockRead(resp, 1), | 3798 CreateMockRead(resp, 1), |
| 3795 MockRead(ASYNC, ERR_IO_PENDING, 2), // Force a wait | 3799 MockRead(ASYNC, ERR_IO_PENDING, 2), // Force a wait |
| 3796 CreateMockRead(data_frame, 3), MockRead(ASYNC, 0, 5) // EOF | 3800 CreateMockRead(data_frame, 3), MockRead(ASYNC, 0, 5) // EOF |
| 3797 }; | 3801 }; |
| 3798 | 3802 |
| 3799 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 3803 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 3800 | 3804 |
| 3801 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3805 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 3802 BoundNetLog(), NULL); | 3806 NetLogWithSource(), NULL); |
| 3803 helper.RunPreTestSetup(); | 3807 helper.RunPreTestSetup(); |
| 3804 helper.AddData(&data); | 3808 helper.AddData(&data); |
| 3805 HttpNetworkTransaction* trans = helper.trans(); | 3809 HttpNetworkTransaction* trans = helper.trans(); |
| 3806 TestCompletionCallback callback; | 3810 TestCompletionCallback callback; |
| 3807 | 3811 |
| 3808 int rv = trans->Start( | 3812 int rv = trans->Start(&CreateGetRequest(), callback.callback(), |
| 3809 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 3813 NetLogWithSource()); |
| 3810 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 3814 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 3811 | 3815 |
| 3812 TransactionHelperResult out = helper.output(); | 3816 TransactionHelperResult out = helper.output(); |
| 3813 out.rv = callback.WaitForResult(); | 3817 out.rv = callback.WaitForResult(); |
| 3814 EXPECT_EQ(out.rv, OK); | 3818 EXPECT_EQ(out.rv, OK); |
| 3815 | 3819 |
| 3816 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3820 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 3817 EXPECT_TRUE(response->headers); | 3821 EXPECT_TRUE(response->headers); |
| 3818 EXPECT_TRUE(response->was_fetched_via_spdy); | 3822 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 3819 out.status_line = response->headers->GetStatusLine(); | 3823 out.status_line = response->headers->GetStatusLine(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 3847 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 3851 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 3848 MockWrite writes[] = {CreateMockWrite(req, 0)}; | 3852 MockWrite writes[] = {CreateMockWrite(req, 0)}; |
| 3849 | 3853 |
| 3850 SpdySerializedFrame go_away(spdy_util_.ConstructSpdyGoAway()); | 3854 SpdySerializedFrame go_away(spdy_util_.ConstructSpdyGoAway()); |
| 3851 MockRead reads[] = { | 3855 MockRead reads[] = { |
| 3852 CreateMockRead(go_away, 1), | 3856 CreateMockRead(go_away, 1), |
| 3853 }; | 3857 }; |
| 3854 | 3858 |
| 3855 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 3859 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 3856 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3860 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 3857 BoundNetLog(), NULL); | 3861 NetLogWithSource(), NULL); |
| 3858 helper.AddData(&data); | 3862 helper.AddData(&data); |
| 3859 helper.RunToCompletion(&data); | 3863 helper.RunToCompletion(&data); |
| 3860 TransactionHelperResult out = helper.output(); | 3864 TransactionHelperResult out = helper.output(); |
| 3861 EXPECT_THAT(out.rv, IsError(ERR_ABORTED)); | 3865 EXPECT_THAT(out.rv, IsError(ERR_ABORTED)); |
| 3862 } | 3866 } |
| 3863 | 3867 |
| 3864 TEST_F(SpdyNetworkTransactionTest, CloseWithActiveStream) { | 3868 TEST_F(SpdyNetworkTransactionTest, CloseWithActiveStream) { |
| 3865 SpdySerializedFrame req( | 3869 SpdySerializedFrame req( |
| 3866 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 3870 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 3867 MockWrite writes[] = {CreateMockWrite(req, 0)}; | 3871 MockWrite writes[] = {CreateMockWrite(req, 0)}; |
| 3868 | 3872 |
| 3869 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); | 3873 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); |
| 3870 MockRead reads[] = { | 3874 MockRead reads[] = { |
| 3871 CreateMockRead(resp, 1), MockRead(SYNCHRONOUS, 0, 2) // EOF | 3875 CreateMockRead(resp, 1), MockRead(SYNCHRONOUS, 0, 2) // EOF |
| 3872 }; | 3876 }; |
| 3873 | 3877 |
| 3874 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 3878 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 3875 | 3879 |
| 3876 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3880 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 3877 BoundNetLog(), NULL); | 3881 NetLogWithSource(), NULL); |
| 3878 helper.RunPreTestSetup(); | 3882 helper.RunPreTestSetup(); |
| 3879 helper.AddData(&data); | 3883 helper.AddData(&data); |
| 3880 helper.StartDefaultTest(); | 3884 helper.StartDefaultTest(); |
| 3881 EXPECT_THAT(helper.output().rv, IsError(ERR_IO_PENDING)); | 3885 EXPECT_THAT(helper.output().rv, IsError(ERR_IO_PENDING)); |
| 3882 | 3886 |
| 3883 helper.WaitForCallbackToComplete(); | 3887 helper.WaitForCallbackToComplete(); |
| 3884 EXPECT_THAT(helper.output().rv, IsError(ERR_CONNECTION_CLOSED)); | 3888 EXPECT_THAT(helper.output().rv, IsError(ERR_CONNECTION_CLOSED)); |
| 3885 | 3889 |
| 3886 const HttpResponseInfo* response = helper.trans()->GetResponseInfo(); | 3890 const HttpResponseInfo* response = helper.trans()->GetResponseInfo(); |
| 3887 EXPECT_TRUE(response->headers); | 3891 EXPECT_TRUE(response->headers); |
| 3888 EXPECT_TRUE(response->was_fetched_via_spdy); | 3892 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 3889 | 3893 |
| 3890 // Verify that we consumed all test data. | 3894 // Verify that we consumed all test data. |
| 3891 helper.VerifyDataConsumed(); | 3895 helper.VerifyDataConsumed(); |
| 3892 } | 3896 } |
| 3893 | 3897 |
| 3894 // Retry with HTTP/1.1 when receiving HTTP_1_1_REQUIRED. Note that no actual | 3898 // Retry with HTTP/1.1 when receiving HTTP_1_1_REQUIRED. Note that no actual |
| 3895 // protocol negotiation happens, instead this test forces protocols for both | 3899 // protocol negotiation happens, instead this test forces protocols for both |
| 3896 // sockets. | 3900 // sockets. |
| 3897 TEST_F(SpdyNetworkTransactionTest, HTTP11RequiredRetry) { | 3901 TEST_F(SpdyNetworkTransactionTest, HTTP11RequiredRetry) { |
| 3898 HttpRequestInfo request; | 3902 HttpRequestInfo request; |
| 3899 request.method = "GET"; | 3903 request.method = "GET"; |
| 3900 request.url = default_url_; | 3904 request.url = default_url_; |
| 3901 // Do not force SPDY so that second socket can negotiate HTTP/1.1. | 3905 // Do not force SPDY so that second socket can negotiate HTTP/1.1. |
| 3902 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, BoundNetLog(), | 3906 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, |
| 3903 nullptr); | 3907 NetLogWithSource(), nullptr); |
| 3904 | 3908 |
| 3905 // First socket: HTTP/2 request rejected with HTTP_1_1_REQUIRED. | 3909 // First socket: HTTP/2 request rejected with HTTP_1_1_REQUIRED. |
| 3906 SpdyHeaderBlock headers(spdy_util_.ConstructGetHeaderBlock(kDefaultUrl)); | 3910 SpdyHeaderBlock headers(spdy_util_.ConstructGetHeaderBlock(kDefaultUrl)); |
| 3907 SpdySerializedFrame req( | 3911 SpdySerializedFrame req( |
| 3908 spdy_util_.ConstructSpdyHeaders(1, std::move(headers), LOWEST, true)); | 3912 spdy_util_.ConstructSpdyHeaders(1, std::move(headers), LOWEST, true)); |
| 3909 MockWrite writes0[] = {CreateMockWrite(req, 0)}; | 3913 MockWrite writes0[] = {CreateMockWrite(req, 0)}; |
| 3910 SpdySerializedFrame go_away(spdy_util_.ConstructSpdyGoAway( | 3914 SpdySerializedFrame go_away(spdy_util_.ConstructSpdyGoAway( |
| 3911 0, GOAWAY_HTTP_1_1_REQUIRED, "Try again using HTTP/1.1 please.")); | 3915 0, GOAWAY_HTTP_1_1_REQUIRED, "Try again using HTTP/1.1 please.")); |
| 3912 MockRead reads0[] = {CreateMockRead(go_away, 1)}; | 3916 MockRead reads0[] = {CreateMockRead(go_away, 1)}; |
| 3913 SequencedSocketData data0(reads0, arraysize(reads0), writes0, | 3917 SequencedSocketData data0(reads0, arraysize(reads0), writes0, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3971 // Retry with HTTP/1.1 to the proxy when receiving HTTP_1_1_REQUIRED from the | 3975 // Retry with HTTP/1.1 to the proxy when receiving HTTP_1_1_REQUIRED from the |
| 3972 // proxy. Note that no actual protocol negotiation happens, instead this test | 3976 // proxy. Note that no actual protocol negotiation happens, instead this test |
| 3973 // forces protocols for both sockets. | 3977 // forces protocols for both sockets. |
| 3974 TEST_F(SpdyNetworkTransactionTest, HTTP11RequiredProxyRetry) { | 3978 TEST_F(SpdyNetworkTransactionTest, HTTP11RequiredProxyRetry) { |
| 3975 HttpRequestInfo request; | 3979 HttpRequestInfo request; |
| 3976 request.method = "GET"; | 3980 request.method = "GET"; |
| 3977 request.url = default_url_; | 3981 request.url = default_url_; |
| 3978 auto session_deps = base::MakeUnique<SpdySessionDependencies>( | 3982 auto session_deps = base::MakeUnique<SpdySessionDependencies>( |
| 3979 ProxyService::CreateFixedFromPacResult("HTTPS myproxy:70")); | 3983 ProxyService::CreateFixedFromPacResult("HTTPS myproxy:70")); |
| 3980 // Do not force SPDY so that second socket can negotiate HTTP/1.1. | 3984 // Do not force SPDY so that second socket can negotiate HTTP/1.1. |
| 3981 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, BoundNetLog(), | 3985 NormalSpdyTransactionHelper helper( |
| 3982 std::move(session_deps)); | 3986 request, DEFAULT_PRIORITY, NetLogWithSource(), std::move(session_deps)); |
| 3983 | 3987 |
| 3984 // First socket: HTTP/2 CONNECT rejected with HTTP_1_1_REQUIRED. | 3988 // First socket: HTTP/2 CONNECT rejected with HTTP_1_1_REQUIRED. |
| 3985 SpdySerializedFrame req(spdy_util_.ConstructSpdyConnect( | 3989 SpdySerializedFrame req(spdy_util_.ConstructSpdyConnect( |
| 3986 nullptr, 0, 1, LOWEST, HostPortPair("www.example.org", 443))); | 3990 nullptr, 0, 1, LOWEST, HostPortPair("www.example.org", 443))); |
| 3987 MockWrite writes0[] = {CreateMockWrite(req, 0)}; | 3991 MockWrite writes0[] = {CreateMockWrite(req, 0)}; |
| 3988 SpdySerializedFrame go_away(spdy_util_.ConstructSpdyGoAway( | 3992 SpdySerializedFrame go_away(spdy_util_.ConstructSpdyGoAway( |
| 3989 0, GOAWAY_HTTP_1_1_REQUIRED, "Try again using HTTP/1.1 please.")); | 3993 0, GOAWAY_HTTP_1_1_REQUIRED, "Try again using HTTP/1.1 please.")); |
| 3990 MockRead reads0[] = {CreateMockRead(go_away, 1)}; | 3994 MockRead reads0[] = {CreateMockRead(go_away, 1)}; |
| 3991 SequencedSocketData data0(reads0, arraysize(reads0), writes0, | 3995 SequencedSocketData data0(reads0, arraysize(reads0), writes0, |
| 3992 arraysize(writes0)); | 3996 arraysize(writes0)); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4061 std::string response_data; | 4065 std::string response_data; |
| 4062 ASSERT_THAT(ReadTransaction(helper.trans(), &response_data), IsOk()); | 4066 ASSERT_THAT(ReadTransaction(helper.trans(), &response_data), IsOk()); |
| 4063 EXPECT_EQ("hello", response_data); | 4067 EXPECT_EQ("hello", response_data); |
| 4064 } | 4068 } |
| 4065 | 4069 |
| 4066 // Test to make sure we can correctly connect through a proxy. | 4070 // Test to make sure we can correctly connect through a proxy. |
| 4067 TEST_F(SpdyNetworkTransactionTest, ProxyConnect) { | 4071 TEST_F(SpdyNetworkTransactionTest, ProxyConnect) { |
| 4068 auto session_deps = base::MakeUnique<SpdySessionDependencies>( | 4072 auto session_deps = base::MakeUnique<SpdySessionDependencies>( |
| 4069 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70")); | 4073 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70")); |
| 4070 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 4074 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 4071 BoundNetLog(), std::move(session_deps)); | 4075 NetLogWithSource(), |
| 4076 std::move(session_deps)); |
| 4072 helper.RunPreTestSetup(); | 4077 helper.RunPreTestSetup(); |
| 4073 HttpNetworkTransaction* trans = helper.trans(); | 4078 HttpNetworkTransaction* trans = helper.trans(); |
| 4074 | 4079 |
| 4075 const char kConnect443[] = { | 4080 const char kConnect443[] = { |
| 4076 "CONNECT www.example.org:443 HTTP/1.1\r\n" | 4081 "CONNECT www.example.org:443 HTTP/1.1\r\n" |
| 4077 "Host: www.example.org:443\r\n" | 4082 "Host: www.example.org:443\r\n" |
| 4078 "Proxy-Connection: keep-alive\r\n\r\n"}; | 4083 "Proxy-Connection: keep-alive\r\n\r\n"}; |
| 4079 const char kHTTP200[] = {"HTTP/1.1 200 OK\r\n\r\n"}; | 4084 const char kHTTP200[] = {"HTTP/1.1 200 OK\r\n\r\n"}; |
| 4080 SpdySerializedFrame req( | 4085 SpdySerializedFrame req( |
| 4081 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 4086 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 4082 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); | 4087 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); |
| 4083 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); | 4088 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); |
| 4084 | 4089 |
| 4085 MockWrite writes[] = { | 4090 MockWrite writes[] = { |
| 4086 MockWrite(SYNCHRONOUS, kConnect443, arraysize(kConnect443) - 1, 0), | 4091 MockWrite(SYNCHRONOUS, kConnect443, arraysize(kConnect443) - 1, 0), |
| 4087 CreateMockWrite(req, 2), | 4092 CreateMockWrite(req, 2), |
| 4088 }; | 4093 }; |
| 4089 MockRead reads[] = { | 4094 MockRead reads[] = { |
| 4090 MockRead(SYNCHRONOUS, kHTTP200, arraysize(kHTTP200) - 1, 1), | 4095 MockRead(SYNCHRONOUS, kHTTP200, arraysize(kHTTP200) - 1, 1), |
| 4091 CreateMockRead(resp, 3), CreateMockRead(body, 4), | 4096 CreateMockRead(resp, 3), CreateMockRead(body, 4), |
| 4092 MockRead(ASYNC, 0, 0, 5), | 4097 MockRead(ASYNC, 0, 0, 5), |
| 4093 }; | 4098 }; |
| 4094 std::unique_ptr<SequencedSocketData> data(new SequencedSocketData( | 4099 std::unique_ptr<SequencedSocketData> data(new SequencedSocketData( |
| 4095 reads, arraysize(reads), writes, arraysize(writes))); | 4100 reads, arraysize(reads), writes, arraysize(writes))); |
| 4096 | 4101 |
| 4097 helper.AddData(data.get()); | 4102 helper.AddData(data.get()); |
| 4098 TestCompletionCallback callback; | 4103 TestCompletionCallback callback; |
| 4099 | 4104 |
| 4100 int rv = trans->Start( | 4105 int rv = trans->Start(&CreateGetRequest(), callback.callback(), |
| 4101 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 4106 NetLogWithSource()); |
| 4102 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 4107 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 4103 | 4108 |
| 4104 rv = callback.WaitForResult(); | 4109 rv = callback.WaitForResult(); |
| 4105 EXPECT_EQ(0, rv); | 4110 EXPECT_EQ(0, rv); |
| 4106 | 4111 |
| 4107 // Verify the response headers. | 4112 // Verify the response headers. |
| 4108 HttpResponseInfo response = *trans->GetResponseInfo(); | 4113 HttpResponseInfo response = *trans->GetResponseInfo(); |
| 4109 ASSERT_TRUE(response.headers); | 4114 ASSERT_TRUE(response.headers); |
| 4110 EXPECT_EQ("HTTP/1.1 200", response.headers->GetStatusLine()); | 4115 EXPECT_EQ("HTTP/1.1 200", response.headers->GetStatusLine()); |
| 4111 | 4116 |
| 4112 std::string response_data; | 4117 std::string response_data; |
| 4113 ASSERT_THAT(ReadTransaction(trans, &response_data), IsOk()); | 4118 ASSERT_THAT(ReadTransaction(trans, &response_data), IsOk()); |
| 4114 EXPECT_EQ("hello!", response_data); | 4119 EXPECT_EQ("hello!", response_data); |
| 4115 helper.VerifyDataConsumed(); | 4120 helper.VerifyDataConsumed(); |
| 4116 } | 4121 } |
| 4117 | 4122 |
| 4118 // Test to make sure we can correctly connect through a proxy to | 4123 // Test to make sure we can correctly connect through a proxy to |
| 4119 // www.example.org, if there already exists a direct spdy connection to | 4124 // www.example.org, if there already exists a direct spdy connection to |
| 4120 // www.example.org. See https://crbug.com/49874. | 4125 // www.example.org. See https://crbug.com/49874. |
| 4121 TEST_F(SpdyNetworkTransactionTest, DirectConnectProxyReconnect) { | 4126 TEST_F(SpdyNetworkTransactionTest, DirectConnectProxyReconnect) { |
| 4122 // Use a proxy service which returns a proxy fallback list from DIRECT to | 4127 // Use a proxy service which returns a proxy fallback list from DIRECT to |
| 4123 // myproxy:70. For this test there will be no fallback, so it is equivalent | 4128 // myproxy:70. For this test there will be no fallback, so it is equivalent |
| 4124 // to simply DIRECT. The reason for appending the second proxy is to verify | 4129 // to simply DIRECT. The reason for appending the second proxy is to verify |
| 4125 // that the session pool key used does is just "DIRECT". | 4130 // that the session pool key used does is just "DIRECT". |
| 4126 auto session_deps = base::MakeUnique<SpdySessionDependencies>( | 4131 auto session_deps = base::MakeUnique<SpdySessionDependencies>( |
| 4127 ProxyService::CreateFixedFromPacResult("DIRECT; PROXY myproxy:70")); | 4132 ProxyService::CreateFixedFromPacResult("DIRECT; PROXY myproxy:70")); |
| 4128 // When setting up the first transaction, we store the SpdySessionPool so that | 4133 // When setting up the first transaction, we store the SpdySessionPool so that |
| 4129 // we can use the same pool in the second transaction. | 4134 // we can use the same pool in the second transaction. |
| 4130 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 4135 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 4131 BoundNetLog(), std::move(session_deps)); | 4136 NetLogWithSource(), |
| 4137 std::move(session_deps)); |
| 4132 | 4138 |
| 4133 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); | 4139 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); |
| 4134 helper.RunPreTestSetup(); | 4140 helper.RunPreTestSetup(); |
| 4135 | 4141 |
| 4136 // Construct and send a simple GET request. | 4142 // Construct and send a simple GET request. |
| 4137 SpdySerializedFrame req( | 4143 SpdySerializedFrame req( |
| 4138 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 4144 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 4139 MockWrite writes[] = { | 4145 MockWrite writes[] = { |
| 4140 CreateMockWrite(req, 0), | 4146 CreateMockWrite(req, 0), |
| 4141 }; | 4147 }; |
| 4142 | 4148 |
| 4143 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); | 4149 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); |
| 4144 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); | 4150 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); |
| 4145 MockRead reads[] = { | 4151 MockRead reads[] = { |
| 4146 CreateMockRead(resp, 1), CreateMockRead(body, 2), | 4152 CreateMockRead(resp, 1), CreateMockRead(body, 2), |
| 4147 MockRead(SYNCHRONOUS, ERR_IO_PENDING, 3), // Force a pause | 4153 MockRead(SYNCHRONOUS, ERR_IO_PENDING, 3), // Force a pause |
| 4148 }; | 4154 }; |
| 4149 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 4155 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 4150 helper.AddData(&data); | 4156 helper.AddData(&data); |
| 4151 HttpNetworkTransaction* trans = helper.trans(); | 4157 HttpNetworkTransaction* trans = helper.trans(); |
| 4152 | 4158 |
| 4153 TestCompletionCallback callback; | 4159 TestCompletionCallback callback; |
| 4154 TransactionHelperResult out; | 4160 TransactionHelperResult out; |
| 4155 out.rv = trans->Start( | 4161 out.rv = trans->Start(&CreateGetRequest(), callback.callback(), |
| 4156 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 4162 NetLogWithSource()); |
| 4157 | 4163 |
| 4158 EXPECT_EQ(out.rv, ERR_IO_PENDING); | 4164 EXPECT_EQ(out.rv, ERR_IO_PENDING); |
| 4159 out.rv = callback.WaitForResult(); | 4165 out.rv = callback.WaitForResult(); |
| 4160 EXPECT_EQ(out.rv, OK); | 4166 EXPECT_EQ(out.rv, OK); |
| 4161 | 4167 |
| 4162 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4168 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 4163 EXPECT_TRUE(response->headers); | 4169 EXPECT_TRUE(response->headers); |
| 4164 EXPECT_TRUE(response->was_fetched_via_spdy); | 4170 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 4165 out.rv = ReadTransaction(trans, &out.response_data); | 4171 out.rv = ReadTransaction(trans, &out.response_data); |
| 4166 EXPECT_THAT(out.rv, IsOk()); | 4172 EXPECT_THAT(out.rv, IsOk()); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4207 reads2, arraysize(reads2), writes2, arraysize(writes2))); | 4213 reads2, arraysize(reads2), writes2, arraysize(writes2))); |
| 4208 | 4214 |
| 4209 // Create another request to www.example.org, but this time through a proxy. | 4215 // Create another request to www.example.org, but this time through a proxy. |
| 4210 HttpRequestInfo request_proxy; | 4216 HttpRequestInfo request_proxy; |
| 4211 request_proxy.method = "GET"; | 4217 request_proxy.method = "GET"; |
| 4212 request_proxy.url = GURL(GetDefaultUrlWithPath("/foo.dat")); | 4218 request_proxy.url = GURL(GetDefaultUrlWithPath("/foo.dat")); |
| 4213 request_proxy.load_flags = 0; | 4219 request_proxy.load_flags = 0; |
| 4214 auto session_deps_proxy = base::MakeUnique<SpdySessionDependencies>( | 4220 auto session_deps_proxy = base::MakeUnique<SpdySessionDependencies>( |
| 4215 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70")); | 4221 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70")); |
| 4216 NormalSpdyTransactionHelper helper_proxy(request_proxy, DEFAULT_PRIORITY, | 4222 NormalSpdyTransactionHelper helper_proxy(request_proxy, DEFAULT_PRIORITY, |
| 4217 BoundNetLog(), | 4223 NetLogWithSource(), |
| 4218 std::move(session_deps_proxy)); | 4224 std::move(session_deps_proxy)); |
| 4219 helper_proxy.RunPreTestSetup(); | 4225 helper_proxy.RunPreTestSetup(); |
| 4220 helper_proxy.AddData(data_proxy.get()); | 4226 helper_proxy.AddData(data_proxy.get()); |
| 4221 | 4227 |
| 4222 HttpNetworkTransaction* trans_proxy = helper_proxy.trans(); | 4228 HttpNetworkTransaction* trans_proxy = helper_proxy.trans(); |
| 4223 TestCompletionCallback callback_proxy; | 4229 TestCompletionCallback callback_proxy; |
| 4224 int rv = trans_proxy->Start( | 4230 int rv = trans_proxy->Start(&request_proxy, callback_proxy.callback(), |
| 4225 &request_proxy, callback_proxy.callback(), BoundNetLog()); | 4231 NetLogWithSource()); |
| 4226 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 4232 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 4227 rv = callback_proxy.WaitForResult(); | 4233 rv = callback_proxy.WaitForResult(); |
| 4228 EXPECT_EQ(0, rv); | 4234 EXPECT_EQ(0, rv); |
| 4229 | 4235 |
| 4230 HttpResponseInfo response_proxy = *trans_proxy->GetResponseInfo(); | 4236 HttpResponseInfo response_proxy = *trans_proxy->GetResponseInfo(); |
| 4231 ASSERT_TRUE(response_proxy.headers); | 4237 ASSERT_TRUE(response_proxy.headers); |
| 4232 EXPECT_EQ("HTTP/1.1 200", response_proxy.headers->GetStatusLine()); | 4238 EXPECT_EQ("HTTP/1.1 200", response_proxy.headers->GetStatusLine()); |
| 4233 | 4239 |
| 4234 std::string response_data; | 4240 std::string response_data; |
| 4235 ASSERT_THAT(ReadTransaction(trans_proxy, &response_data), IsOk()); | 4241 ASSERT_THAT(ReadTransaction(trans_proxy, &response_data), IsOk()); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4277 | 4283 |
| 4278 for (int variant = VARIANT_RST_DURING_SEND_COMPLETION; | 4284 for (int variant = VARIANT_RST_DURING_SEND_COMPLETION; |
| 4279 variant <= VARIANT_RST_DURING_READ_COMPLETION; | 4285 variant <= VARIANT_RST_DURING_READ_COMPLETION; |
| 4280 ++variant) { | 4286 ++variant) { |
| 4281 SequencedSocketData data1(reads, arraysize(reads), writes1, 1 + variant); | 4287 SequencedSocketData data1(reads, arraysize(reads), writes1, 1 + variant); |
| 4282 | 4288 |
| 4283 SequencedSocketData data2(reads2, arraysize(reads2), writes2, | 4289 SequencedSocketData data2(reads2, arraysize(reads2), writes2, |
| 4284 arraysize(writes2)); | 4290 arraysize(writes2)); |
| 4285 | 4291 |
| 4286 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 4292 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 4287 BoundNetLog(), NULL); | 4293 NetLogWithSource(), NULL); |
| 4288 helper.AddData(&data1); | 4294 helper.AddData(&data1); |
| 4289 helper.AddData(&data2); | 4295 helper.AddData(&data2); |
| 4290 helper.RunPreTestSetup(); | 4296 helper.RunPreTestSetup(); |
| 4291 | 4297 |
| 4292 for (int i = 0; i < 2; ++i) { | 4298 for (int i = 0; i < 2; ++i) { |
| 4293 HttpNetworkTransaction trans(DEFAULT_PRIORITY, helper.session()); | 4299 HttpNetworkTransaction trans(DEFAULT_PRIORITY, helper.session()); |
| 4294 | 4300 |
| 4295 TestCompletionCallback callback; | 4301 TestCompletionCallback callback; |
| 4296 int rv = | 4302 int rv = trans.Start(&helper.request(), callback.callback(), |
| 4297 trans.Start(&helper.request(), callback.callback(), BoundNetLog()); | 4303 NetLogWithSource()); |
| 4298 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 4304 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 4299 // On the second transaction, we trigger the RST. | 4305 // On the second transaction, we trigger the RST. |
| 4300 if (i == 1) { | 4306 if (i == 1) { |
| 4301 if (variant == VARIANT_RST_DURING_READ_COMPLETION) { | 4307 if (variant == VARIANT_RST_DURING_READ_COMPLETION) { |
| 4302 // Writes to the socket complete asynchronously on SPDY by running | 4308 // Writes to the socket complete asynchronously on SPDY by running |
| 4303 // through the message loop. Complete the write here. | 4309 // through the message loop. Complete the write here. |
| 4304 base::RunLoop().RunUntilIdle(); | 4310 base::RunLoop().RunUntilIdle(); |
| 4305 } | 4311 } |
| 4306 | 4312 |
| 4307 // Now schedule the ERR_CONNECTION_RESET. | 4313 // Now schedule the ERR_CONNECTION_RESET. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4363 CreateMockRead(resp_authentication, 1), | 4369 CreateMockRead(resp_authentication, 1), |
| 4364 CreateMockRead(body_authentication, 2), | 4370 CreateMockRead(body_authentication, 2), |
| 4365 CreateMockRead(resp_data, 4), | 4371 CreateMockRead(resp_data, 4), |
| 4366 CreateMockRead(body_data, 5), | 4372 CreateMockRead(body_data, 5), |
| 4367 MockRead(ASYNC, 0, 6), | 4373 MockRead(ASYNC, 0, 6), |
| 4368 }; | 4374 }; |
| 4369 | 4375 |
| 4370 SequencedSocketData data(spdy_reads, arraysize(spdy_reads), spdy_writes, | 4376 SequencedSocketData data(spdy_reads, arraysize(spdy_reads), spdy_writes, |
| 4371 arraysize(spdy_writes)); | 4377 arraysize(spdy_writes)); |
| 4372 HttpRequestInfo request(CreateGetRequest()); | 4378 HttpRequestInfo request(CreateGetRequest()); |
| 4373 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, BoundNetLog(), | 4379 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, |
| 4374 NULL); | 4380 NetLogWithSource(), NULL); |
| 4375 | 4381 |
| 4376 helper.RunPreTestSetup(); | 4382 helper.RunPreTestSetup(); |
| 4377 helper.AddData(&data); | 4383 helper.AddData(&data); |
| 4378 helper.StartDefaultTest(); | 4384 helper.StartDefaultTest(); |
| 4379 EXPECT_THAT(helper.output().rv, IsError(ERR_IO_PENDING)); | 4385 EXPECT_THAT(helper.output().rv, IsError(ERR_IO_PENDING)); |
| 4380 | 4386 |
| 4381 helper.WaitForCallbackToComplete(); | 4387 helper.WaitForCallbackToComplete(); |
| 4382 EXPECT_THAT(helper.output().rv, IsOk()); | 4388 EXPECT_THAT(helper.output().rv, IsOk()); |
| 4383 | 4389 |
| 4384 // Make sure the response has an auth challenge. | 4390 // Make sure the response has an auth challenge. |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4497 CreateMockRead(stream2_headers, 5), CreateMockRead(stream2_body, 6), | 4503 CreateMockRead(stream2_headers, 5), CreateMockRead(stream2_body, 6), |
| 4498 MockRead(ASYNC, ERR_IO_PENDING, 7), MockRead(ASYNC, 0, 8), // EOF | 4504 MockRead(ASYNC, ERR_IO_PENDING, 7), MockRead(ASYNC, 0, 8), // EOF |
| 4499 }; | 4505 }; |
| 4500 | 4506 |
| 4501 HttpResponseInfo response; | 4507 HttpResponseInfo response; |
| 4502 HttpResponseInfo response2; | 4508 HttpResponseInfo response2; |
| 4503 std::string expected_push_result("pushed"); | 4509 std::string expected_push_result("pushed"); |
| 4504 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 4510 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 4505 | 4511 |
| 4506 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 4512 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 4507 BoundNetLog(), NULL); | 4513 NetLogWithSource(), NULL); |
| 4508 helper.AddData(&data); | 4514 helper.AddData(&data); |
| 4509 helper.RunPreTestSetup(); | 4515 helper.RunPreTestSetup(); |
| 4510 | 4516 |
| 4511 HttpNetworkTransaction* trans = helper.trans(); | 4517 HttpNetworkTransaction* trans = helper.trans(); |
| 4512 | 4518 |
| 4513 // Start the transaction. | 4519 // Start the transaction. |
| 4514 TestCompletionCallback callback; | 4520 TestCompletionCallback callback; |
| 4515 int rv = trans->Start( | 4521 int rv = trans->Start(&CreateGetRequest(), callback.callback(), |
| 4516 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 4522 NetLogWithSource()); |
| 4517 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 4523 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 4518 // Run until we've received the primary HEADERS, the pushed HEADERS, | 4524 // Run until we've received the primary HEADERS, the pushed HEADERS, |
| 4519 // and the body of the primary stream, but before we've received the HEADERS | 4525 // and the body of the primary stream, but before we've received the HEADERS |
| 4520 // for the pushed stream. | 4526 // for the pushed stream. |
| 4521 data.RunUntilPaused(); | 4527 data.RunUntilPaused(); |
| 4522 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 4528 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
| 4523 | 4529 |
| 4524 // Request the pushed path. At this point, we've received the push, but the | 4530 // Request the pushed path. At this point, we've received the push, but the |
| 4525 // headers are not yet complete. | 4531 // headers are not yet complete. |
| 4526 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, helper.session()); | 4532 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, helper.session()); |
| 4527 rv = | 4533 rv = trans2.Start(&CreateGetPushRequest(), callback.callback(), |
| 4528 trans2.Start(&CreateGetPushRequest(), callback.callback(), BoundNetLog()); | 4534 NetLogWithSource()); |
| 4529 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 4535 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 4530 data.Resume(); | 4536 data.Resume(); |
| 4531 data.RunUntilPaused(); | 4537 data.RunUntilPaused(); |
| 4532 base::RunLoop().RunUntilIdle(); | 4538 base::RunLoop().RunUntilIdle(); |
| 4533 | 4539 |
| 4534 // Read the server push body. | 4540 // Read the server push body. |
| 4535 std::string result2; | 4541 std::string result2; |
| 4536 ReadResult(&trans2, &result2); | 4542 ReadResult(&trans2, &result2); |
| 4537 // Read the response body. | 4543 // Read the response body. |
| 4538 std::string result; | 4544 std::string result; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4612 CreateMockRead(stream2_body, 8), MockRead(ASYNC, ERR_IO_PENDING, 9), | 4618 CreateMockRead(stream2_body, 8), MockRead(ASYNC, ERR_IO_PENDING, 9), |
| 4613 MockRead(ASYNC, 0, 10), // EOF | 4619 MockRead(ASYNC, 0, 10), // EOF |
| 4614 }; | 4620 }; |
| 4615 | 4621 |
| 4616 HttpResponseInfo response; | 4622 HttpResponseInfo response; |
| 4617 HttpResponseInfo response2; | 4623 HttpResponseInfo response2; |
| 4618 std::string expected_push_result("pushed"); | 4624 std::string expected_push_result("pushed"); |
| 4619 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 4625 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 4620 | 4626 |
| 4621 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 4627 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 4622 BoundNetLog(), NULL); | 4628 NetLogWithSource(), NULL); |
| 4623 helper.AddData(&data); | 4629 helper.AddData(&data); |
| 4624 helper.RunPreTestSetup(); | 4630 helper.RunPreTestSetup(); |
| 4625 | 4631 |
| 4626 HttpNetworkTransaction* trans = helper.trans(); | 4632 HttpNetworkTransaction* trans = helper.trans(); |
| 4627 | 4633 |
| 4628 // Start the transaction. | 4634 // Start the transaction. |
| 4629 TestCompletionCallback callback; | 4635 TestCompletionCallback callback; |
| 4630 int rv = trans->Start( | 4636 int rv = trans->Start(&CreateGetRequest(), callback.callback(), |
| 4631 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 4637 NetLogWithSource()); |
| 4632 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 4638 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 4633 // Run until we've received the primary HEADERS, the pushed HEADERS, | 4639 // Run until we've received the primary HEADERS, the pushed HEADERS, |
| 4634 // the first HEADERS frame, and the body of the primary stream, but before | 4640 // the first HEADERS frame, and the body of the primary stream, but before |
| 4635 // we've received the final HEADERS for the pushed stream. | 4641 // we've received the final HEADERS for the pushed stream. |
| 4636 data.RunUntilPaused(); | 4642 data.RunUntilPaused(); |
| 4637 EXPECT_EQ(0, callback.WaitForResult()); | 4643 EXPECT_EQ(0, callback.WaitForResult()); |
| 4638 | 4644 |
| 4639 // Request the pushed path. At this point, we've received the push, but the | 4645 // Request the pushed path. At this point, we've received the push, but the |
| 4640 // headers are not yet complete. | 4646 // headers are not yet complete. |
| 4641 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, helper.session()); | 4647 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, helper.session()); |
| 4642 rv = | 4648 rv = trans2.Start(&CreateGetPushRequest(), callback.callback(), |
| 4643 trans2.Start(&CreateGetPushRequest(), callback.callback(), BoundNetLog()); | 4649 NetLogWithSource()); |
| 4644 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 4650 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 4645 data.Resume(); | 4651 data.Resume(); |
| 4646 data.RunUntilPaused(); | 4652 data.RunUntilPaused(); |
| 4647 base::RunLoop().RunUntilIdle(); | 4653 base::RunLoop().RunUntilIdle(); |
| 4648 // This is needed to work around https://crbug.com/571102. | 4654 // This is needed to work around https://crbug.com/571102. |
| 4649 data.Resume(); | 4655 data.Resume(); |
| 4650 data.RunUntilPaused(); | 4656 data.RunUntilPaused(); |
| 4651 base::RunLoop().RunUntilIdle(); | 4657 base::RunLoop().RunUntilIdle(); |
| 4652 | 4658 |
| 4653 // Read the server push body. | 4659 // Read the server push body. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4719 MockRead reads[] = { | 4725 MockRead reads[] = { |
| 4720 CreateMockRead(stream1_reply, 1), CreateMockRead(stream2_syn, 2), | 4726 CreateMockRead(stream1_reply, 1), CreateMockRead(stream2_syn, 2), |
| 4721 CreateMockRead(stream1_body, 3), MockRead(ASYNC, ERR_IO_PENDING, 4), | 4727 CreateMockRead(stream1_body, 3), MockRead(ASYNC, ERR_IO_PENDING, 4), |
| 4722 CreateMockRead(stream2_headers1, 5), CreateMockRead(stream2_body, 6), | 4728 CreateMockRead(stream2_headers1, 5), CreateMockRead(stream2_body, 6), |
| 4723 MockRead(ASYNC, ERR_IO_PENDING, 7), MockRead(ASYNC, 0, 8), // EOF | 4729 MockRead(ASYNC, ERR_IO_PENDING, 7), MockRead(ASYNC, 0, 8), // EOF |
| 4724 }; | 4730 }; |
| 4725 | 4731 |
| 4726 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 4732 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 4727 | 4733 |
| 4728 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 4734 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 4729 BoundNetLog(), NULL); | 4735 NetLogWithSource(), NULL); |
| 4730 helper.AddData(&data); | 4736 helper.AddData(&data); |
| 4731 helper.RunPreTestSetup(); | 4737 helper.RunPreTestSetup(); |
| 4732 | 4738 |
| 4733 HttpNetworkTransaction* trans = helper.trans(); | 4739 HttpNetworkTransaction* trans = helper.trans(); |
| 4734 | 4740 |
| 4735 // Start the transaction. | 4741 // Start the transaction. |
| 4736 TestCompletionCallback callback; | 4742 TestCompletionCallback callback; |
| 4737 int rv = trans->Start( | 4743 int rv = trans->Start(&CreateGetRequest(), callback.callback(), |
| 4738 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 4744 NetLogWithSource()); |
| 4739 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 4745 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 4740 // Run until we've received the primary HEADERS, the pushed HEADERS, | 4746 // Run until we've received the primary HEADERS, the pushed HEADERS, |
| 4741 // the first HEADERS frame, and the body of the primary stream, but before | 4747 // the first HEADERS frame, and the body of the primary stream, but before |
| 4742 // we've received the final HEADERS for the pushed stream. | 4748 // we've received the final HEADERS for the pushed stream. |
| 4743 data.RunUntilPaused(); | 4749 data.RunUntilPaused(); |
| 4744 EXPECT_EQ(0, callback.WaitForResult()); | 4750 EXPECT_EQ(0, callback.WaitForResult()); |
| 4745 | 4751 |
| 4746 // Request the pushed path. At this point, we've received the push, but the | 4752 // Request the pushed path. At this point, we've received the push, but the |
| 4747 // headers are not yet complete. | 4753 // headers are not yet complete. |
| 4748 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, helper.session()); | 4754 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, helper.session()); |
| 4749 rv = | 4755 rv = trans2.Start(&CreateGetPushRequest(), callback.callback(), |
| 4750 trans2.Start(&CreateGetPushRequest(), callback.callback(), BoundNetLog()); | 4756 NetLogWithSource()); |
| 4751 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 4757 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 4752 data.Resume(); | 4758 data.Resume(); |
| 4753 data.RunUntilPaused(); | 4759 data.RunUntilPaused(); |
| 4754 base::RunLoop().RunUntilIdle(); | 4760 base::RunLoop().RunUntilIdle(); |
| 4755 | 4761 |
| 4756 // Read the server push body. | 4762 // Read the server push body. |
| 4757 std::string result2; | 4763 std::string result2; |
| 4758 ReadResult(&trans2, &result2); | 4764 ReadResult(&trans2, &result2); |
| 4759 // Read the response body. | 4765 // Read the response body. |
| 4760 std::string result; | 4766 std::string result; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4800 SpdySerializedFrame stream1_headers(spdy_util_.ConstructSpdyResponseHeaders( | 4806 SpdySerializedFrame stream1_headers(spdy_util_.ConstructSpdyResponseHeaders( |
| 4801 1, std::move(late_headers), false)); | 4807 1, std::move(late_headers), false)); |
| 4802 SpdySerializedFrame stream1_body(spdy_util_.ConstructSpdyDataFrame(1, true)); | 4808 SpdySerializedFrame stream1_body(spdy_util_.ConstructSpdyDataFrame(1, true)); |
| 4803 MockRead reads[] = { | 4809 MockRead reads[] = { |
| 4804 CreateMockRead(stream1_reply, 1), CreateMockRead(stream1_headers, 2), | 4810 CreateMockRead(stream1_reply, 1), CreateMockRead(stream1_headers, 2), |
| 4805 CreateMockRead(stream1_body, 3), MockRead(ASYNC, 0, 5) // EOF | 4811 CreateMockRead(stream1_body, 3), MockRead(ASYNC, 0, 5) // EOF |
| 4806 }; | 4812 }; |
| 4807 | 4813 |
| 4808 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 4814 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 4809 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 4815 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 4810 BoundNetLog(), NULL); | 4816 NetLogWithSource(), NULL); |
| 4811 helper.RunToCompletion(&data); | 4817 helper.RunToCompletion(&data); |
| 4812 TransactionHelperResult out = helper.output(); | 4818 TransactionHelperResult out = helper.output(); |
| 4813 EXPECT_THAT(out.rv, IsError(ERR_SPDY_PROTOCOL_ERROR)); | 4819 EXPECT_THAT(out.rv, IsError(ERR_SPDY_PROTOCOL_ERROR)); |
| 4814 } | 4820 } |
| 4815 | 4821 |
| 4816 // Tests that receiving HEADERS, DATA, HEADERS, and DATA in that sequence will | 4822 // Tests that receiving HEADERS, DATA, HEADERS, and DATA in that sequence will |
| 4817 // trigger a ERR_SPDY_PROTOCOL_ERROR because trailing HEADERS must not be | 4823 // trigger a ERR_SPDY_PROTOCOL_ERROR because trailing HEADERS must not be |
| 4818 // followed by any DATA frames. | 4824 // followed by any DATA frames. |
| 4819 TEST_F(SpdyNetworkTransactionTest, SyncReplyDataAfterTrailers) { | 4825 TEST_F(SpdyNetworkTransactionTest, SyncReplyDataAfterTrailers) { |
| 4820 SpdySerializedFrame req( | 4826 SpdySerializedFrame req( |
| (...skipping 14 matching lines...) Expand all Loading... |
| 4835 1, std::move(late_headers), false)); | 4841 1, std::move(late_headers), false)); |
| 4836 SpdySerializedFrame stream1_body2(spdy_util_.ConstructSpdyDataFrame(1, true)); | 4842 SpdySerializedFrame stream1_body2(spdy_util_.ConstructSpdyDataFrame(1, true)); |
| 4837 MockRead reads[] = { | 4843 MockRead reads[] = { |
| 4838 CreateMockRead(stream1_reply, 1), CreateMockRead(stream1_body, 2), | 4844 CreateMockRead(stream1_reply, 1), CreateMockRead(stream1_body, 2), |
| 4839 CreateMockRead(stream1_headers, 3), CreateMockRead(stream1_body2, 4), | 4845 CreateMockRead(stream1_headers, 3), CreateMockRead(stream1_body2, 4), |
| 4840 MockRead(ASYNC, 0, 6) // EOF | 4846 MockRead(ASYNC, 0, 6) // EOF |
| 4841 }; | 4847 }; |
| 4842 | 4848 |
| 4843 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 4849 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 4844 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 4850 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 4845 BoundNetLog(), NULL); | 4851 NetLogWithSource(), NULL); |
| 4846 helper.RunToCompletion(&data); | 4852 helper.RunToCompletion(&data); |
| 4847 TransactionHelperResult out = helper.output(); | 4853 TransactionHelperResult out = helper.output(); |
| 4848 EXPECT_THAT(out.rv, IsError(ERR_SPDY_PROTOCOL_ERROR)); | 4854 EXPECT_THAT(out.rv, IsError(ERR_SPDY_PROTOCOL_ERROR)); |
| 4849 } | 4855 } |
| 4850 | 4856 |
| 4851 TEST_F(SpdyNetworkTransactionTest, ServerPushCrossOriginCorrectness) { | 4857 TEST_F(SpdyNetworkTransactionTest, ServerPushCrossOriginCorrectness) { |
| 4852 // In this test we want to verify that we can't accidentally push content | 4858 // In this test we want to verify that we can't accidentally push content |
| 4853 // which can't be pushed by this content server. | 4859 // which can't be pushed by this content server. |
| 4854 // This test assumes that: | 4860 // This test assumes that: |
| 4855 // - if we're requesting http://www.foo.com/barbaz | 4861 // - if we're requesting http://www.foo.com/barbaz |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4912 request.url = GURL(url_to_fetch); | 4918 request.url = GURL(url_to_fetch); |
| 4913 request.load_flags = 0; | 4919 request.load_flags = 0; |
| 4914 | 4920 |
| 4915 // Enable cross-origin push. Since we are not using a proxy, this should | 4921 // Enable cross-origin push. Since we are not using a proxy, this should |
| 4916 // not actually enable cross-origin SPDY push. | 4922 // not actually enable cross-origin SPDY push. |
| 4917 auto session_deps = base::MakeUnique<SpdySessionDependencies>(); | 4923 auto session_deps = base::MakeUnique<SpdySessionDependencies>(); |
| 4918 std::unique_ptr<TestProxyDelegate> proxy_delegate(new TestProxyDelegate()); | 4924 std::unique_ptr<TestProxyDelegate> proxy_delegate(new TestProxyDelegate()); |
| 4919 proxy_delegate->set_trusted_spdy_proxy(net::ProxyServer::FromURI( | 4925 proxy_delegate->set_trusted_spdy_proxy(net::ProxyServer::FromURI( |
| 4920 "https://123.45.67.89:443", net::ProxyServer::SCHEME_HTTP)); | 4926 "https://123.45.67.89:443", net::ProxyServer::SCHEME_HTTP)); |
| 4921 session_deps->proxy_delegate.reset(proxy_delegate.release()); | 4927 session_deps->proxy_delegate.reset(proxy_delegate.release()); |
| 4922 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, BoundNetLog(), | 4928 NormalSpdyTransactionHelper helper( |
| 4923 std::move(session_deps)); | 4929 request, DEFAULT_PRIORITY, NetLogWithSource(), std::move(session_deps)); |
| 4924 helper.RunPreTestSetup(); | 4930 helper.RunPreTestSetup(); |
| 4925 helper.AddData(&data); | 4931 helper.AddData(&data); |
| 4926 | 4932 |
| 4927 HttpNetworkTransaction* trans = helper.trans(); | 4933 HttpNetworkTransaction* trans = helper.trans(); |
| 4928 | 4934 |
| 4929 // Start the transaction with basic parameters. | 4935 // Start the transaction with basic parameters. |
| 4930 TestCompletionCallback callback; | 4936 TestCompletionCallback callback; |
| 4931 | 4937 |
| 4932 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 4938 int rv = trans->Start(&request, callback.callback(), NetLogWithSource()); |
| 4933 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 4939 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 4934 rv = callback.WaitForResult(); | 4940 rv = callback.WaitForResult(); |
| 4935 | 4941 |
| 4936 // Read the response body. | 4942 // Read the response body. |
| 4937 std::string result; | 4943 std::string result; |
| 4938 ReadResult(trans, &result); | 4944 ReadResult(trans, &result); |
| 4939 | 4945 |
| 4940 // Verify that we consumed all test data. | 4946 // Verify that we consumed all test data. |
| 4941 EXPECT_TRUE(data.AllReadDataConsumed()); | 4947 EXPECT_TRUE(data.AllReadDataConsumed()); |
| 4942 EXPECT_TRUE(data.AllWriteDataConsumed()); | 4948 EXPECT_TRUE(data.AllWriteDataConsumed()); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4981 MockRead(SYNCHRONOUS, ERR_IO_PENDING, 5), | 4987 MockRead(SYNCHRONOUS, ERR_IO_PENDING, 5), |
| 4982 }; | 4988 }; |
| 4983 | 4989 |
| 4984 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 4990 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 4985 | 4991 |
| 4986 HttpRequestInfo request; | 4992 HttpRequestInfo request; |
| 4987 request.method = "GET"; | 4993 request.method = "GET"; |
| 4988 request.url = GURL(url_to_fetch); | 4994 request.url = GURL(url_to_fetch); |
| 4989 request.load_flags = 0; | 4995 request.load_flags = 0; |
| 4990 | 4996 |
| 4991 BoundNetLog log; | 4997 NetLogWithSource log; |
| 4992 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, log, nullptr); | 4998 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, log, nullptr); |
| 4993 helper.RunPreTestSetup(); | 4999 helper.RunPreTestSetup(); |
| 4994 helper.AddData(&data); | 5000 helper.AddData(&data); |
| 4995 | 5001 |
| 4996 HttpNetworkTransaction* trans0 = helper.trans(); | 5002 HttpNetworkTransaction* trans0 = helper.trans(); |
| 4997 TestCompletionCallback callback0; | 5003 TestCompletionCallback callback0; |
| 4998 int rv = trans0->Start(&request, callback0.callback(), log); | 5004 int rv = trans0->Start(&request, callback0.callback(), log); |
| 4999 rv = callback0.GetResult(rv); | 5005 rv = callback0.GetResult(rv); |
| 5000 EXPECT_THAT(rv, IsOk()); | 5006 EXPECT_THAT(rv, IsOk()); |
| 5001 | 5007 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5096 | 5102 |
| 5097 SequencedSocketData data1(reads1, arraysize(reads1), writes1, | 5103 SequencedSocketData data1(reads1, arraysize(reads1), writes1, |
| 5098 arraysize(writes1)); | 5104 arraysize(writes1)); |
| 5099 | 5105 |
| 5100 // Request |url_to_fetch0| to open connection to mail.example.org. | 5106 // Request |url_to_fetch0| to open connection to mail.example.org. |
| 5101 HttpRequestInfo request0; | 5107 HttpRequestInfo request0; |
| 5102 request0.method = "GET"; | 5108 request0.method = "GET"; |
| 5103 request0.url = GURL(url_to_fetch0); | 5109 request0.url = GURL(url_to_fetch0); |
| 5104 request0.load_flags = 0; | 5110 request0.load_flags = 0; |
| 5105 | 5111 |
| 5106 BoundNetLog log; | 5112 NetLogWithSource log; |
| 5107 NormalSpdyTransactionHelper helper(request0, DEFAULT_PRIORITY, log, nullptr); | 5113 NormalSpdyTransactionHelper helper(request0, DEFAULT_PRIORITY, log, nullptr); |
| 5108 helper.RunPreTestSetup(); | 5114 helper.RunPreTestSetup(); |
| 5109 | 5115 |
| 5110 // "spdy_pooling.pem" is valid for www.example.org, but not for | 5116 // "spdy_pooling.pem" is valid for www.example.org, but not for |
| 5111 // docs.example.org. | 5117 // docs.example.org. |
| 5112 std::unique_ptr<SSLSocketDataProvider> ssl_provider0( | 5118 std::unique_ptr<SSLSocketDataProvider> ssl_provider0( |
| 5113 new SSLSocketDataProvider(ASYNC, OK)); | 5119 new SSLSocketDataProvider(ASYNC, OK)); |
| 5114 ssl_provider0->cert = | 5120 ssl_provider0->cert = |
| 5115 ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); | 5121 ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); |
| 5116 helper.AddDataWithSSLSocketDataProvider(&data0, std::move(ssl_provider0)); | 5122 helper.AddDataWithSSLSocketDataProvider(&data0, std::move(ssl_provider0)); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5236 MockRead(SYNCHRONOUS, ERR_IO_PENDING, 6), | 5242 MockRead(SYNCHRONOUS, ERR_IO_PENDING, 6), |
| 5237 }; | 5243 }; |
| 5238 | 5244 |
| 5239 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 5245 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 5240 | 5246 |
| 5241 HttpRequestInfo request; | 5247 HttpRequestInfo request; |
| 5242 request.method = "GET"; | 5248 request.method = "GET"; |
| 5243 request.url = GURL(url_to_fetch); | 5249 request.url = GURL(url_to_fetch); |
| 5244 request.load_flags = 0; | 5250 request.load_flags = 0; |
| 5245 | 5251 |
| 5246 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, BoundNetLog(), | 5252 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, |
| 5247 nullptr); | 5253 NetLogWithSource(), nullptr); |
| 5248 helper.RunToCompletion(&data); | 5254 helper.RunToCompletion(&data); |
| 5249 TransactionHelperResult out = helper.output(); | 5255 TransactionHelperResult out = helper.output(); |
| 5250 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 5256 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
| 5251 EXPECT_EQ("hello!", out.response_data); | 5257 EXPECT_EQ("hello!", out.response_data); |
| 5252 } | 5258 } |
| 5253 | 5259 |
| 5254 TEST_F(SpdyNetworkTransactionTest, RetryAfterRefused) { | 5260 TEST_F(SpdyNetworkTransactionTest, RetryAfterRefused) { |
| 5255 // Construct the request. | 5261 // Construct the request. |
| 5256 SpdySerializedFrame req( | 5262 SpdySerializedFrame req( |
| 5257 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 5263 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 5258 // Will be destroyed by the RST before stream 3 starts. | 5264 // Will be destroyed by the RST before stream 3 starts. |
| 5259 spdy_util_.UpdateWithStreamDestruction(1); | 5265 spdy_util_.UpdateWithStreamDestruction(1); |
| 5260 SpdySerializedFrame req2( | 5266 SpdySerializedFrame req2( |
| 5261 spdy_util_.ConstructSpdyGet(nullptr, 0, 3, LOWEST, true)); | 5267 spdy_util_.ConstructSpdyGet(nullptr, 0, 3, LOWEST, true)); |
| 5262 MockWrite writes[] = { | 5268 MockWrite writes[] = { |
| 5263 CreateMockWrite(req, 0), CreateMockWrite(req2, 2), | 5269 CreateMockWrite(req, 0), CreateMockWrite(req2, 2), |
| 5264 }; | 5270 }; |
| 5265 | 5271 |
| 5266 SpdySerializedFrame refused( | 5272 SpdySerializedFrame refused( |
| 5267 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_REFUSED_STREAM)); | 5273 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_REFUSED_STREAM)); |
| 5268 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 3)); | 5274 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 3)); |
| 5269 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(3, true)); | 5275 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(3, true)); |
| 5270 MockRead reads[] = { | 5276 MockRead reads[] = { |
| 5271 CreateMockRead(refused, 1), CreateMockRead(resp, 3), | 5277 CreateMockRead(refused, 1), CreateMockRead(resp, 3), |
| 5272 CreateMockRead(body, 4), MockRead(ASYNC, 0, 5) // EOF | 5278 CreateMockRead(body, 4), MockRead(ASYNC, 0, 5) // EOF |
| 5273 }; | 5279 }; |
| 5274 | 5280 |
| 5275 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 5281 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 5276 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 5282 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 5277 BoundNetLog(), NULL); | 5283 NetLogWithSource(), NULL); |
| 5278 | 5284 |
| 5279 helper.RunPreTestSetup(); | 5285 helper.RunPreTestSetup(); |
| 5280 helper.AddData(&data); | 5286 helper.AddData(&data); |
| 5281 | 5287 |
| 5282 HttpNetworkTransaction* trans = helper.trans(); | 5288 HttpNetworkTransaction* trans = helper.trans(); |
| 5283 | 5289 |
| 5284 // Start the transaction with basic parameters. | 5290 // Start the transaction with basic parameters. |
| 5285 TestCompletionCallback callback; | 5291 TestCompletionCallback callback; |
| 5286 int rv = trans->Start( | 5292 int rv = trans->Start(&CreateGetRequest(), callback.callback(), |
| 5287 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 5293 NetLogWithSource()); |
| 5288 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 5294 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 5289 rv = callback.WaitForResult(); | 5295 rv = callback.WaitForResult(); |
| 5290 EXPECT_THAT(rv, IsOk()); | 5296 EXPECT_THAT(rv, IsOk()); |
| 5291 | 5297 |
| 5292 // Verify that we consumed all test data. | 5298 // Verify that we consumed all test data. |
| 5293 EXPECT_TRUE(data.AllReadDataConsumed()); | 5299 EXPECT_TRUE(data.AllReadDataConsumed()); |
| 5294 EXPECT_TRUE(data.AllWriteDataConsumed()); | 5300 EXPECT_TRUE(data.AllWriteDataConsumed()); |
| 5295 | 5301 |
| 5296 // Verify the response headers. | 5302 // Verify the response headers. |
| 5297 HttpResponseInfo response = *trans->GetResponseInfo(); | 5303 HttpResponseInfo response = *trans->GetResponseInfo(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5335 SpdySerializedFrame resp3(spdy_util_.ConstructSpdyGetReply(NULL, 0, 5)); | 5341 SpdySerializedFrame resp3(spdy_util_.ConstructSpdyGetReply(NULL, 0, 5)); |
| 5336 SpdySerializedFrame body3(spdy_util_.ConstructSpdyDataFrame(5, true)); | 5342 SpdySerializedFrame body3(spdy_util_.ConstructSpdyDataFrame(5, true)); |
| 5337 MockRead reads[] = { | 5343 MockRead reads[] = { |
| 5338 CreateMockRead(resp1, 2), MockRead(ASYNC, ERR_IO_PENDING, 3), | 5344 CreateMockRead(resp1, 2), MockRead(ASYNC, ERR_IO_PENDING, 3), |
| 5339 CreateMockRead(body1, 4), CreateMockRead(resp2, 7), | 5345 CreateMockRead(body1, 4), CreateMockRead(resp2, 7), |
| 5340 CreateMockRead(body2, 8), CreateMockRead(resp3, 9), | 5346 CreateMockRead(body2, 8), CreateMockRead(resp3, 9), |
| 5341 CreateMockRead(body3, 10), MockRead(ASYNC, 0, 11) // EOF | 5347 CreateMockRead(body3, 10), MockRead(ASYNC, 0, 11) // EOF |
| 5342 }; | 5348 }; |
| 5343 | 5349 |
| 5344 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 5350 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 5345 NormalSpdyTransactionHelper helper(CreateGetRequest(), LOWEST, BoundNetLog(), | 5351 NormalSpdyTransactionHelper helper(CreateGetRequest(), LOWEST, |
| 5346 NULL); | 5352 NetLogWithSource(), NULL); |
| 5347 helper.RunPreTestSetup(); | 5353 helper.RunPreTestSetup(); |
| 5348 helper.AddData(&data); | 5354 helper.AddData(&data); |
| 5349 | 5355 |
| 5350 // Start the first transaction to set up the SpdySession | 5356 // Start the first transaction to set up the SpdySession |
| 5351 HttpNetworkTransaction* trans = helper.trans(); | 5357 HttpNetworkTransaction* trans = helper.trans(); |
| 5352 TestCompletionCallback callback; | 5358 TestCompletionCallback callback; |
| 5353 HttpRequestInfo info1 = CreateGetRequest(); | 5359 HttpRequestInfo info1 = CreateGetRequest(); |
| 5354 int rv = trans->Start(&info1, callback.callback(), BoundNetLog()); | 5360 int rv = trans->Start(&info1, callback.callback(), NetLogWithSource()); |
| 5355 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 5361 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 5356 | 5362 |
| 5357 // Run the message loop, but do not allow the write to complete. | 5363 // Run the message loop, but do not allow the write to complete. |
| 5358 // This leaves the SpdySession with a write pending, which prevents | 5364 // This leaves the SpdySession with a write pending, which prevents |
| 5359 // SpdySession from attempting subsequent writes until this write completes. | 5365 // SpdySession from attempting subsequent writes until this write completes. |
| 5360 base::RunLoop().RunUntilIdle(); | 5366 base::RunLoop().RunUntilIdle(); |
| 5361 | 5367 |
| 5362 // Now, start both new transactions | 5368 // Now, start both new transactions |
| 5363 HttpRequestInfo info2 = CreateGetRequest(); | 5369 HttpRequestInfo info2 = CreateGetRequest(); |
| 5364 TestCompletionCallback callback2; | 5370 TestCompletionCallback callback2; |
| 5365 HttpNetworkTransaction trans2(MEDIUM, helper.session()); | 5371 HttpNetworkTransaction trans2(MEDIUM, helper.session()); |
| 5366 rv = trans2.Start(&info2, callback2.callback(), BoundNetLog()); | 5372 rv = trans2.Start(&info2, callback2.callback(), NetLogWithSource()); |
| 5367 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 5373 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 5368 base::RunLoop().RunUntilIdle(); | 5374 base::RunLoop().RunUntilIdle(); |
| 5369 | 5375 |
| 5370 HttpRequestInfo info3 = CreateGetRequest(); | 5376 HttpRequestInfo info3 = CreateGetRequest(); |
| 5371 TestCompletionCallback callback3; | 5377 TestCompletionCallback callback3; |
| 5372 HttpNetworkTransaction trans3(HIGHEST, helper.session()); | 5378 HttpNetworkTransaction trans3(HIGHEST, helper.session()); |
| 5373 rv = trans3.Start(&info3, callback3.callback(), BoundNetLog()); | 5379 rv = trans3.Start(&info3, callback3.callback(), NetLogWithSource()); |
| 5374 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 5380 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 5375 base::RunLoop().RunUntilIdle(); | 5381 base::RunLoop().RunUntilIdle(); |
| 5376 | 5382 |
| 5377 // We now have two HEADERS frames queued up which will be | 5383 // We now have two HEADERS frames queued up which will be |
| 5378 // dequeued only once the first write completes, which we | 5384 // dequeued only once the first write completes, which we |
| 5379 // now allow to happen. | 5385 // now allow to happen. |
| 5380 ASSERT_TRUE(data.IsPaused()); | 5386 ASSERT_TRUE(data.IsPaused()); |
| 5381 data.Resume(); | 5387 data.Resume(); |
| 5382 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 5388 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
| 5383 | 5389 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5456 new UploadBytesElementReader(content->c_str(), content->size()))); | 5462 new UploadBytesElementReader(content->c_str(), content->size()))); |
| 5457 } | 5463 } |
| 5458 ElementsUploadDataStream upload_data_stream(std::move(element_readers), 0); | 5464 ElementsUploadDataStream upload_data_stream(std::move(element_readers), 0); |
| 5459 | 5465 |
| 5460 // Setup the request | 5466 // Setup the request |
| 5461 HttpRequestInfo request; | 5467 HttpRequestInfo request; |
| 5462 request.method = "POST"; | 5468 request.method = "POST"; |
| 5463 request.url = default_url_; | 5469 request.url = default_url_; |
| 5464 request.upload_data_stream = &upload_data_stream; | 5470 request.upload_data_stream = &upload_data_stream; |
| 5465 | 5471 |
| 5466 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, BoundNetLog(), | 5472 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, |
| 5467 NULL); | 5473 NetLogWithSource(), NULL); |
| 5468 helper.AddData(&data); | 5474 helper.AddData(&data); |
| 5469 helper.RunPreTestSetup(); | 5475 helper.RunPreTestSetup(); |
| 5470 | 5476 |
| 5471 HttpNetworkTransaction* trans = helper.trans(); | 5477 HttpNetworkTransaction* trans = helper.trans(); |
| 5472 | 5478 |
| 5473 TestCompletionCallback callback; | 5479 TestCompletionCallback callback; |
| 5474 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); | 5480 int rv = |
| 5481 trans->Start(&helper.request(), callback.callback(), NetLogWithSource()); |
| 5475 | 5482 |
| 5476 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 5483 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 5477 | 5484 |
| 5478 data.RunUntilPaused(); | 5485 data.RunUntilPaused(); |
| 5479 base::RunLoop().RunUntilIdle(); | 5486 base::RunLoop().RunUntilIdle(); |
| 5480 | 5487 |
| 5481 SpdyHttpStream* stream = static_cast<SpdyHttpStream*>(trans->stream_.get()); | 5488 SpdyHttpStream* stream = static_cast<SpdyHttpStream*>(trans->stream_.get()); |
| 5482 ASSERT_TRUE(stream); | 5489 ASSERT_TRUE(stream); |
| 5483 ASSERT_TRUE(stream->stream()); | 5490 ASSERT_TRUE(stream->stream()); |
| 5484 EXPECT_EQ(static_cast<int>(kDefaultInitialWindowSize) + | 5491 EXPECT_EQ(static_cast<int>(kDefaultInitialWindowSize) + |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5572 | 5579 |
| 5573 writes.push_back( | 5580 writes.push_back( |
| 5574 CreateMockWrite(session_window_update, writes.size() + reads.size())); | 5581 CreateMockWrite(session_window_update, writes.size() + reads.size())); |
| 5575 writes.push_back( | 5582 writes.push_back( |
| 5576 CreateMockWrite(stream_window_update, writes.size() + reads.size())); | 5583 CreateMockWrite(stream_window_update, writes.size() + reads.size())); |
| 5577 | 5584 |
| 5578 SequencedSocketData data(reads.data(), reads.size(), writes.data(), | 5585 SequencedSocketData data(reads.data(), reads.size(), writes.data(), |
| 5579 writes.size()); | 5586 writes.size()); |
| 5580 | 5587 |
| 5581 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 5588 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 5582 BoundNetLog(), NULL); | 5589 NetLogWithSource(), NULL); |
| 5583 helper.AddData(&data); | 5590 helper.AddData(&data); |
| 5584 helper.RunPreTestSetup(); | 5591 helper.RunPreTestSetup(); |
| 5585 | 5592 |
| 5586 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); | 5593 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); |
| 5587 SpdySessionPoolPeer pool_peer(spdy_session_pool); | 5594 SpdySessionPoolPeer pool_peer(spdy_session_pool); |
| 5588 pool_peer.SetEnableSendingInitialData(true); | 5595 pool_peer.SetEnableSendingInitialData(true); |
| 5589 pool_peer.SetSessionMaxRecvWindowSize(session_max_recv_window_size); | 5596 pool_peer.SetSessionMaxRecvWindowSize(session_max_recv_window_size); |
| 5590 pool_peer.SetStreamInitialRecvWindowSize(stream_max_recv_window_size); | 5597 pool_peer.SetStreamInitialRecvWindowSize(stream_max_recv_window_size); |
| 5591 | 5598 |
| 5592 HttpNetworkTransaction* trans = helper.trans(); | 5599 HttpNetworkTransaction* trans = helper.trans(); |
| 5593 TestCompletionCallback callback; | 5600 TestCompletionCallback callback; |
| 5594 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); | 5601 int rv = |
| 5602 trans->Start(&helper.request(), callback.callback(), NetLogWithSource()); |
| 5595 | 5603 |
| 5596 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 5604 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 5597 rv = callback.WaitForResult(); | 5605 rv = callback.WaitForResult(); |
| 5598 EXPECT_THAT(rv, IsOk()); | 5606 EXPECT_THAT(rv, IsOk()); |
| 5599 | 5607 |
| 5600 SpdyHttpStream* stream = | 5608 SpdyHttpStream* stream = |
| 5601 static_cast<SpdyHttpStream*>(trans->stream_.get()); | 5609 static_cast<SpdyHttpStream*>(trans->stream_.get()); |
| 5602 ASSERT_TRUE(stream); | 5610 ASSERT_TRUE(stream); |
| 5603 ASSERT_TRUE(stream->stream()); | 5611 ASSERT_TRUE(stream->stream()); |
| 5604 | 5612 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5663 new UploadBytesElementReader(content->c_str(), content->size()))); | 5671 new UploadBytesElementReader(content->c_str(), content->size()))); |
| 5664 } | 5672 } |
| 5665 ElementsUploadDataStream upload_data_stream(std::move(element_readers), 0); | 5673 ElementsUploadDataStream upload_data_stream(std::move(element_readers), 0); |
| 5666 | 5674 |
| 5667 // Setup the request | 5675 // Setup the request |
| 5668 HttpRequestInfo request; | 5676 HttpRequestInfo request; |
| 5669 request.method = "POST"; | 5677 request.method = "POST"; |
| 5670 request.url = default_url_; | 5678 request.url = default_url_; |
| 5671 request.upload_data_stream = &upload_data_stream; | 5679 request.upload_data_stream = &upload_data_stream; |
| 5672 | 5680 |
| 5673 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, BoundNetLog(), | 5681 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, |
| 5674 NULL); | 5682 NetLogWithSource(), NULL); |
| 5675 helper.RunPreTestSetup(); | 5683 helper.RunPreTestSetup(); |
| 5676 helper.AddData(&data); | 5684 helper.AddData(&data); |
| 5677 HttpNetworkTransaction* trans = helper.trans(); | 5685 HttpNetworkTransaction* trans = helper.trans(); |
| 5678 | 5686 |
| 5679 TestCompletionCallback callback; | 5687 TestCompletionCallback callback; |
| 5680 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); | 5688 int rv = |
| 5689 trans->Start(&helper.request(), callback.callback(), NetLogWithSource()); |
| 5681 ASSERT_THAT(rv, IsError(ERR_IO_PENDING)); | 5690 ASSERT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 5682 | 5691 |
| 5683 base::RunLoop().RunUntilIdle(); | 5692 base::RunLoop().RunUntilIdle(); |
| 5684 ASSERT_TRUE(callback.have_result()); | 5693 ASSERT_TRUE(callback.have_result()); |
| 5685 EXPECT_THAT(callback.WaitForResult(), IsError(ERR_SPDY_PROTOCOL_ERROR)); | 5694 EXPECT_THAT(callback.WaitForResult(), IsError(ERR_SPDY_PROTOCOL_ERROR)); |
| 5686 helper.VerifyDataConsumed(); | 5695 helper.VerifyDataConsumed(); |
| 5687 } | 5696 } |
| 5688 | 5697 |
| 5689 // Test that after hitting a send window size of 0, the write process | 5698 // Test that after hitting a send window size of 0, the write process |
| 5690 // stalls and upon receiving WINDOW_UPDATE frame write resumes. | 5699 // stalls and upon receiving WINDOW_UPDATE frame write resumes. |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5800 std::string upload_data_string(kBufferSize * num_upload_buffers, 'a'); | 5809 std::string upload_data_string(kBufferSize * num_upload_buffers, 'a'); |
| 5801 upload_data_string.append(kUploadData, kUploadDataSize); | 5810 upload_data_string.append(kUploadData, kUploadDataSize); |
| 5802 element_readers.push_back(base::WrapUnique(new UploadBytesElementReader( | 5811 element_readers.push_back(base::WrapUnique(new UploadBytesElementReader( |
| 5803 upload_data_string.c_str(), upload_data_string.size()))); | 5812 upload_data_string.c_str(), upload_data_string.size()))); |
| 5804 ElementsUploadDataStream upload_data_stream(std::move(element_readers), 0); | 5813 ElementsUploadDataStream upload_data_stream(std::move(element_readers), 0); |
| 5805 | 5814 |
| 5806 HttpRequestInfo request; | 5815 HttpRequestInfo request; |
| 5807 request.method = "POST"; | 5816 request.method = "POST"; |
| 5808 request.url = default_url_; | 5817 request.url = default_url_; |
| 5809 request.upload_data_stream = &upload_data_stream; | 5818 request.upload_data_stream = &upload_data_stream; |
| 5810 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, BoundNetLog(), | 5819 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, |
| 5811 NULL); | 5820 NetLogWithSource(), NULL); |
| 5812 helper.AddData(&data); | 5821 helper.AddData(&data); |
| 5813 helper.RunPreTestSetup(); | 5822 helper.RunPreTestSetup(); |
| 5814 | 5823 |
| 5815 HttpNetworkTransaction* trans = helper.trans(); | 5824 HttpNetworkTransaction* trans = helper.trans(); |
| 5816 | 5825 |
| 5817 TestCompletionCallback callback; | 5826 TestCompletionCallback callback; |
| 5818 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); | 5827 int rv = |
| 5828 trans->Start(&helper.request(), callback.callback(), NetLogWithSource()); |
| 5819 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 5829 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 5820 | 5830 |
| 5821 base::RunLoop().RunUntilIdle(); // Write as much as we can. | 5831 base::RunLoop().RunUntilIdle(); // Write as much as we can. |
| 5822 | 5832 |
| 5823 SpdyHttpStream* stream = static_cast<SpdyHttpStream*>(trans->stream_.get()); | 5833 SpdyHttpStream* stream = static_cast<SpdyHttpStream*>(trans->stream_.get()); |
| 5824 ASSERT_TRUE(stream); | 5834 ASSERT_TRUE(stream); |
| 5825 ASSERT_TRUE(stream->stream()); | 5835 ASSERT_TRUE(stream->stream()); |
| 5826 EXPECT_EQ(0, stream->stream()->send_window_size()); | 5836 EXPECT_EQ(0, stream->stream()->send_window_size()); |
| 5827 if (initial_window_size % kBufferSize != 0) { | 5837 if (initial_window_size % kBufferSize != 0) { |
| 5828 // If it does not take whole number of full upload buffer to zero out | 5838 // If it does not take whole number of full upload buffer to zero out |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5955 std::string upload_data_string(kBufferSize * num_upload_buffers, 'a'); | 5965 std::string upload_data_string(kBufferSize * num_upload_buffers, 'a'); |
| 5956 upload_data_string.append(kUploadData, kUploadDataSize); | 5966 upload_data_string.append(kUploadData, kUploadDataSize); |
| 5957 element_readers.push_back(base::WrapUnique(new UploadBytesElementReader( | 5967 element_readers.push_back(base::WrapUnique(new UploadBytesElementReader( |
| 5958 upload_data_string.c_str(), upload_data_string.size()))); | 5968 upload_data_string.c_str(), upload_data_string.size()))); |
| 5959 ElementsUploadDataStream upload_data_stream(std::move(element_readers), 0); | 5969 ElementsUploadDataStream upload_data_stream(std::move(element_readers), 0); |
| 5960 | 5970 |
| 5961 HttpRequestInfo request; | 5971 HttpRequestInfo request; |
| 5962 request.method = "POST"; | 5972 request.method = "POST"; |
| 5963 request.url = default_url_; | 5973 request.url = default_url_; |
| 5964 request.upload_data_stream = &upload_data_stream; | 5974 request.upload_data_stream = &upload_data_stream; |
| 5965 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, BoundNetLog(), | 5975 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, |
| 5966 NULL); | 5976 NetLogWithSource(), NULL); |
| 5967 helper.RunPreTestSetup(); | 5977 helper.RunPreTestSetup(); |
| 5968 helper.AddData(&data); | 5978 helper.AddData(&data); |
| 5969 | 5979 |
| 5970 HttpNetworkTransaction* trans = helper.trans(); | 5980 HttpNetworkTransaction* trans = helper.trans(); |
| 5971 | 5981 |
| 5972 TestCompletionCallback callback; | 5982 TestCompletionCallback callback; |
| 5973 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); | 5983 int rv = |
| 5984 trans->Start(&helper.request(), callback.callback(), NetLogWithSource()); |
| 5974 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 5985 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 5975 | 5986 |
| 5976 data.RunUntilPaused(); // Write as much as we can. | 5987 data.RunUntilPaused(); // Write as much as we can. |
| 5977 base::RunLoop().RunUntilIdle(); | 5988 base::RunLoop().RunUntilIdle(); |
| 5978 | 5989 |
| 5979 SpdyHttpStream* stream = static_cast<SpdyHttpStream*>(trans->stream_.get()); | 5990 SpdyHttpStream* stream = static_cast<SpdyHttpStream*>(trans->stream_.get()); |
| 5980 ASSERT_TRUE(stream); | 5991 ASSERT_TRUE(stream); |
| 5981 ASSERT_TRUE(stream->stream()); | 5992 ASSERT_TRUE(stream->stream()); |
| 5982 EXPECT_EQ(0, stream->stream()->send_window_size()); | 5993 EXPECT_EQ(0, stream->stream()->send_window_size()); |
| 5983 | 5994 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6119 std::string upload_data_string(kBufferSize * num_upload_buffers, 'a'); | 6130 std::string upload_data_string(kBufferSize * num_upload_buffers, 'a'); |
| 6120 upload_data_string.append(kUploadData, kUploadDataSize); | 6131 upload_data_string.append(kUploadData, kUploadDataSize); |
| 6121 element_readers.push_back(base::WrapUnique(new UploadBytesElementReader( | 6132 element_readers.push_back(base::WrapUnique(new UploadBytesElementReader( |
| 6122 upload_data_string.c_str(), upload_data_string.size()))); | 6133 upload_data_string.c_str(), upload_data_string.size()))); |
| 6123 ElementsUploadDataStream upload_data_stream(std::move(element_readers), 0); | 6134 ElementsUploadDataStream upload_data_stream(std::move(element_readers), 0); |
| 6124 | 6135 |
| 6125 HttpRequestInfo request; | 6136 HttpRequestInfo request; |
| 6126 request.method = "POST"; | 6137 request.method = "POST"; |
| 6127 request.url = default_url_; | 6138 request.url = default_url_; |
| 6128 request.upload_data_stream = &upload_data_stream; | 6139 request.upload_data_stream = &upload_data_stream; |
| 6129 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, BoundNetLog(), | 6140 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, |
| 6130 NULL); | 6141 NetLogWithSource(), NULL); |
| 6131 helper.RunPreTestSetup(); | 6142 helper.RunPreTestSetup(); |
| 6132 helper.AddData(&data); | 6143 helper.AddData(&data); |
| 6133 | 6144 |
| 6134 HttpNetworkTransaction* trans = helper.trans(); | 6145 HttpNetworkTransaction* trans = helper.trans(); |
| 6135 | 6146 |
| 6136 TestCompletionCallback callback; | 6147 TestCompletionCallback callback; |
| 6137 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); | 6148 int rv = |
| 6149 trans->Start(&helper.request(), callback.callback(), NetLogWithSource()); |
| 6138 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 6150 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 6139 | 6151 |
| 6140 data.RunUntilPaused(); // Write as much as we can. | 6152 data.RunUntilPaused(); // Write as much as we can. |
| 6141 base::RunLoop().RunUntilIdle(); | 6153 base::RunLoop().RunUntilIdle(); |
| 6142 | 6154 |
| 6143 SpdyHttpStream* stream = static_cast<SpdyHttpStream*>(trans->stream_.get()); | 6155 SpdyHttpStream* stream = static_cast<SpdyHttpStream*>(trans->stream_.get()); |
| 6144 ASSERT_TRUE(stream); | 6156 ASSERT_TRUE(stream); |
| 6145 ASSERT_TRUE(stream->stream()); | 6157 ASSERT_TRUE(stream->stream()); |
| 6146 EXPECT_EQ(0, stream->stream()->send_window_size()); | 6158 EXPECT_EQ(0, stream->stream()->send_window_size()); |
| 6147 | 6159 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 6174 SpdySerializedFrame req( | 6186 SpdySerializedFrame req( |
| 6175 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 6187 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 6176 SpdySerializedFrame goaway(spdy_util_.ConstructSpdyGoAway( | 6188 SpdySerializedFrame goaway(spdy_util_.ConstructSpdyGoAway( |
| 6177 0, GOAWAY_PROTOCOL_ERROR, "Odd push stream id.")); | 6189 0, GOAWAY_PROTOCOL_ERROR, "Odd push stream id.")); |
| 6178 MockWrite writes[] = { | 6190 MockWrite writes[] = { |
| 6179 CreateMockWrite(req, 0), CreateMockWrite(goaway, 2), | 6191 CreateMockWrite(req, 0), CreateMockWrite(goaway, 2), |
| 6180 }; | 6192 }; |
| 6181 | 6193 |
| 6182 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 6194 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 6183 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 6195 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 6184 BoundNetLog(), NULL); | 6196 NetLogWithSource(), NULL); |
| 6185 helper.RunToCompletion(&data); | 6197 helper.RunToCompletion(&data); |
| 6186 TransactionHelperResult out = helper.output(); | 6198 TransactionHelperResult out = helper.output(); |
| 6187 EXPECT_THAT(out.rv, IsError(ERR_SPDY_PROTOCOL_ERROR)); | 6199 EXPECT_THAT(out.rv, IsError(ERR_SPDY_PROTOCOL_ERROR)); |
| 6188 } | 6200 } |
| 6189 | 6201 |
| 6190 TEST_F(SpdyNetworkTransactionTest, | 6202 TEST_F(SpdyNetworkTransactionTest, |
| 6191 GoAwayOnPushStreamIdLesserOrEqualThanLastAccepted) { | 6203 GoAwayOnPushStreamIdLesserOrEqualThanLastAccepted) { |
| 6192 SpdySerializedFrame push_a(spdy_util_.ConstructSpdyPush( | 6204 SpdySerializedFrame push_a(spdy_util_.ConstructSpdyPush( |
| 6193 NULL, 0, 4, 1, GetDefaultUrlWithPath("/a.dat").c_str())); | 6205 NULL, 0, 4, 1, GetDefaultUrlWithPath("/a.dat").c_str())); |
| 6194 SpdyHeaderBlock push_b_headers; | 6206 SpdyHeaderBlock push_b_headers; |
| 6195 spdy_util_.AddUrlToHeaderBlock(GetDefaultUrlWithPath("/b.dat"), | 6207 spdy_util_.AddUrlToHeaderBlock(GetDefaultUrlWithPath("/b.dat"), |
| 6196 &push_b_headers); | 6208 &push_b_headers); |
| 6197 SpdySerializedFrame push_b(spdy_util_.ConstructInitialSpdyPushFrame( | 6209 SpdySerializedFrame push_b(spdy_util_.ConstructInitialSpdyPushFrame( |
| 6198 std::move(push_b_headers), 2, 1)); | 6210 std::move(push_b_headers), 2, 1)); |
| 6199 MockRead reads[] = { | 6211 MockRead reads[] = { |
| 6200 CreateMockRead(push_a, 1), CreateMockRead(push_b, 2), | 6212 CreateMockRead(push_a, 1), CreateMockRead(push_b, 2), |
| 6201 }; | 6213 }; |
| 6202 | 6214 |
| 6203 SpdySerializedFrame req( | 6215 SpdySerializedFrame req( |
| 6204 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 6216 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 6205 SpdySerializedFrame goaway(spdy_util_.ConstructSpdyGoAway( | 6217 SpdySerializedFrame goaway(spdy_util_.ConstructSpdyGoAway( |
| 6206 4, GOAWAY_PROTOCOL_ERROR, | 6218 4, GOAWAY_PROTOCOL_ERROR, |
| 6207 "New push stream id must be greater than the last accepted.")); | 6219 "New push stream id must be greater than the last accepted.")); |
| 6208 MockWrite writes[] = { | 6220 MockWrite writes[] = { |
| 6209 CreateMockWrite(req, 0), CreateMockWrite(goaway, 3), | 6221 CreateMockWrite(req, 0), CreateMockWrite(goaway, 3), |
| 6210 }; | 6222 }; |
| 6211 | 6223 |
| 6212 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 6224 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 6213 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 6225 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 6214 BoundNetLog(), NULL); | 6226 NetLogWithSource(), NULL); |
| 6215 helper.RunToCompletion(&data); | 6227 helper.RunToCompletion(&data); |
| 6216 TransactionHelperResult out = helper.output(); | 6228 TransactionHelperResult out = helper.output(); |
| 6217 EXPECT_THAT(out.rv, IsError(ERR_SPDY_PROTOCOL_ERROR)); | 6229 EXPECT_THAT(out.rv, IsError(ERR_SPDY_PROTOCOL_ERROR)); |
| 6218 } | 6230 } |
| 6219 | 6231 |
| 6220 // Regression test for https://crbug.com/493348: request header exceeds 16 kB | 6232 // Regression test for https://crbug.com/493348: request header exceeds 16 kB |
| 6221 // and thus sent in multiple frames when using HTTP/2. | 6233 // and thus sent in multiple frames when using HTTP/2. |
| 6222 TEST_F(SpdyNetworkTransactionTest, LargeRequest) { | 6234 TEST_F(SpdyNetworkTransactionTest, LargeRequest) { |
| 6223 const std::string kKey("foo"); | 6235 const std::string kKey("foo"); |
| 6224 const std::string kValue(1 << 15, 'z'); | 6236 const std::string kValue(1 << 15, 'z'); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 6237 }; | 6249 }; |
| 6238 | 6250 |
| 6239 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(nullptr, 0, 1)); | 6251 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(nullptr, 0, 1)); |
| 6240 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); | 6252 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); |
| 6241 MockRead reads[] = { | 6253 MockRead reads[] = { |
| 6242 CreateMockRead(resp, 1), CreateMockRead(body, 2), | 6254 CreateMockRead(resp, 1), CreateMockRead(body, 2), |
| 6243 MockRead(ASYNC, 0, 3) // EOF | 6255 MockRead(ASYNC, 0, 3) // EOF |
| 6244 }; | 6256 }; |
| 6245 | 6257 |
| 6246 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 6258 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 6247 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, BoundNetLog(), | 6259 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, |
| 6248 nullptr); | 6260 NetLogWithSource(), nullptr); |
| 6249 helper.RunToCompletion(&data); | 6261 helper.RunToCompletion(&data); |
| 6250 TransactionHelperResult out = helper.output(); | 6262 TransactionHelperResult out = helper.output(); |
| 6251 | 6263 |
| 6252 EXPECT_THAT(out.rv, IsOk()); | 6264 EXPECT_THAT(out.rv, IsOk()); |
| 6253 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 6265 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
| 6254 EXPECT_EQ("hello!", out.response_data); | 6266 EXPECT_EQ("hello!", out.response_data); |
| 6255 } | 6267 } |
| 6256 | 6268 |
| 6257 // Regression test for https://crbug.com/535629: response header exceeds 16 kB. | 6269 // Regression test for https://crbug.com/535629: response header exceeds 16 kB. |
| 6258 TEST_F(SpdyNetworkTransactionTest, LargeResponseHeader) { | 6270 TEST_F(SpdyNetworkTransactionTest, LargeResponseHeader) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 6274 spdy_util_.ConstructSpdyGetReply(response_headers, 1, 1)); | 6286 spdy_util_.ConstructSpdyGetReply(response_headers, 1, 1)); |
| 6275 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); | 6287 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); |
| 6276 MockRead reads[] = { | 6288 MockRead reads[] = { |
| 6277 CreateMockRead(resp, 1), CreateMockRead(body, 2), | 6289 CreateMockRead(resp, 1), CreateMockRead(body, 2), |
| 6278 MockRead(ASYNC, 0, 3) // EOF | 6290 MockRead(ASYNC, 0, 3) // EOF |
| 6279 }; | 6291 }; |
| 6280 | 6292 |
| 6281 HttpRequestInfo request; | 6293 HttpRequestInfo request; |
| 6282 request.method = "GET"; | 6294 request.method = "GET"; |
| 6283 request.url = default_url_; | 6295 request.url = default_url_; |
| 6284 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, BoundNetLog(), | 6296 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, |
| 6285 nullptr); | 6297 NetLogWithSource(), nullptr); |
| 6286 | 6298 |
| 6287 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 6299 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 6288 helper.RunToCompletion(&data); | 6300 helper.RunToCompletion(&data); |
| 6289 TransactionHelperResult out = helper.output(); | 6301 TransactionHelperResult out = helper.output(); |
| 6290 | 6302 |
| 6291 EXPECT_THAT(out.rv, IsOk()); | 6303 EXPECT_THAT(out.rv, IsOk()); |
| 6292 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 6304 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
| 6293 EXPECT_EQ("hello!", out.response_data); | 6305 EXPECT_EQ("hello!", out.response_data); |
| 6294 ASSERT_TRUE(out.response_info.headers->HasHeaderValue(kKey, kValue)); | 6306 ASSERT_TRUE(out.response_info.headers->HasHeaderValue(kKey, kValue)); |
| 6295 } | 6307 } |
| 6296 | 6308 |
| 6297 // End of line delimiter is forbidden according to RFC 7230 Section 3.2. | 6309 // End of line delimiter is forbidden according to RFC 7230 Section 3.2. |
| 6298 TEST_F(SpdyNetworkTransactionTest, CRLFInHeaderValue) { | 6310 TEST_F(SpdyNetworkTransactionTest, CRLFInHeaderValue) { |
| 6299 SpdySerializedFrame req( | 6311 SpdySerializedFrame req( |
| 6300 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 6312 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 6301 SpdySerializedFrame rst( | 6313 SpdySerializedFrame rst( |
| 6302 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); | 6314 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); |
| 6303 MockWrite writes[] = {CreateMockWrite(req, 0), CreateMockWrite(rst, 2)}; | 6315 MockWrite writes[] = {CreateMockWrite(req, 0), CreateMockWrite(rst, 2)}; |
| 6304 | 6316 |
| 6305 const char* response_headers[] = {"folded", "foo\r\nbar"}; | 6317 const char* response_headers[] = {"folded", "foo\r\nbar"}; |
| 6306 SpdySerializedFrame resp( | 6318 SpdySerializedFrame resp( |
| 6307 spdy_util_.ConstructSpdyGetReply(response_headers, 1, 1)); | 6319 spdy_util_.ConstructSpdyGetReply(response_headers, 1, 1)); |
| 6308 MockRead reads[] = {CreateMockRead(resp, 1), MockRead(ASYNC, 0, 3)}; | 6320 MockRead reads[] = {CreateMockRead(resp, 1), MockRead(ASYNC, 0, 3)}; |
| 6309 | 6321 |
| 6310 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 6322 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 6311 | 6323 |
| 6312 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 6324 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 6313 BoundNetLog(), nullptr); | 6325 NetLogWithSource(), nullptr); |
| 6314 helper.RunToCompletion(&data); | 6326 helper.RunToCompletion(&data); |
| 6315 TransactionHelperResult out = helper.output(); | 6327 TransactionHelperResult out = helper.output(); |
| 6316 | 6328 |
| 6317 EXPECT_THAT(out.rv, IsError(ERR_SPDY_PROTOCOL_ERROR)); | 6329 EXPECT_THAT(out.rv, IsError(ERR_SPDY_PROTOCOL_ERROR)); |
| 6318 } | 6330 } |
| 6319 | 6331 |
| 6320 class SpdyNetworkTransactionTLSUsageCheckTest | 6332 class SpdyNetworkTransactionTLSUsageCheckTest |
| 6321 : public SpdyNetworkTransactionTest { | 6333 : public SpdyNetworkTransactionTest { |
| 6322 protected: | 6334 protected: |
| 6323 void RunTLSUsageCheckTest( | 6335 void RunTLSUsageCheckTest( |
| 6324 std::unique_ptr<SSLSocketDataProvider> ssl_provider) { | 6336 std::unique_ptr<SSLSocketDataProvider> ssl_provider) { |
| 6325 SpdySerializedFrame goaway( | 6337 SpdySerializedFrame goaway( |
| 6326 spdy_util_.ConstructSpdyGoAway(0, GOAWAY_INADEQUATE_SECURITY, "")); | 6338 spdy_util_.ConstructSpdyGoAway(0, GOAWAY_INADEQUATE_SECURITY, "")); |
| 6327 MockWrite writes[] = {CreateMockWrite(goaway)}; | 6339 MockWrite writes[] = {CreateMockWrite(goaway)}; |
| 6328 | 6340 |
| 6329 StaticSocketDataProvider data(NULL, 0, writes, arraysize(writes)); | 6341 StaticSocketDataProvider data(NULL, 0, writes, arraysize(writes)); |
| 6330 HttpRequestInfo request; | 6342 HttpRequestInfo request; |
| 6331 request.method = "GET"; | 6343 request.method = "GET"; |
| 6332 request.url = default_url_; | 6344 request.url = default_url_; |
| 6333 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, BoundNetLog(), | 6345 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, |
| 6334 NULL); | 6346 NetLogWithSource(), NULL); |
| 6335 helper.RunToCompletionWithSSLData(&data, std::move(ssl_provider)); | 6347 helper.RunToCompletionWithSSLData(&data, std::move(ssl_provider)); |
| 6336 TransactionHelperResult out = helper.output(); | 6348 TransactionHelperResult out = helper.output(); |
| 6337 EXPECT_THAT(out.rv, IsError(ERR_SPDY_INADEQUATE_TRANSPORT_SECURITY)); | 6349 EXPECT_THAT(out.rv, IsError(ERR_SPDY_INADEQUATE_TRANSPORT_SECURITY)); |
| 6338 } | 6350 } |
| 6339 }; | 6351 }; |
| 6340 | 6352 |
| 6341 TEST_F(SpdyNetworkTransactionTLSUsageCheckTest, TLSVersionTooOld) { | 6353 TEST_F(SpdyNetworkTransactionTLSUsageCheckTest, TLSVersionTooOld) { |
| 6342 std::unique_ptr<SSLSocketDataProvider> ssl_provider( | 6354 std::unique_ptr<SSLSocketDataProvider> ssl_provider( |
| 6343 new SSLSocketDataProvider(ASYNC, OK)); | 6355 new SSLSocketDataProvider(ASYNC, OK)); |
| 6344 SSLConnectionStatusSetVersion(SSL_CONNECTION_VERSION_SSL3, | 6356 SSLConnectionStatusSetVersion(SSL_CONNECTION_VERSION_SSL3, |
| 6345 &ssl_provider->connection_status); | 6357 &ssl_provider->connection_status); |
| 6346 | 6358 |
| 6347 RunTLSUsageCheckTest(std::move(ssl_provider)); | 6359 RunTLSUsageCheckTest(std::move(ssl_provider)); |
| 6348 } | 6360 } |
| 6349 | 6361 |
| 6350 TEST_F(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { | 6362 TEST_F(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { |
| 6351 std::unique_ptr<SSLSocketDataProvider> ssl_provider( | 6363 std::unique_ptr<SSLSocketDataProvider> ssl_provider( |
| 6352 new SSLSocketDataProvider(ASYNC, OK)); | 6364 new SSLSocketDataProvider(ASYNC, OK)); |
| 6353 // Set to TLS_RSA_WITH_NULL_MD5 | 6365 // Set to TLS_RSA_WITH_NULL_MD5 |
| 6354 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); | 6366 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); |
| 6355 | 6367 |
| 6356 RunTLSUsageCheckTest(std::move(ssl_provider)); | 6368 RunTLSUsageCheckTest(std::move(ssl_provider)); |
| 6357 } | 6369 } |
| 6358 | 6370 |
| 6359 } // namespace net | 6371 } // namespace net |
| OLD | NEW |