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 27 matching lines...) Expand all Loading... |
38 #include "net/socket/next_proto.h" | 38 #include "net/socket/next_proto.h" |
39 #include "net/spdy/buffered_spdy_framer.h" | 39 #include "net/spdy/buffered_spdy_framer.h" |
40 #include "net/spdy/spdy_http_stream.h" | 40 #include "net/spdy/spdy_http_stream.h" |
41 #include "net/spdy/spdy_http_utils.h" | 41 #include "net/spdy/spdy_http_utils.h" |
42 #include "net/spdy/spdy_session.h" | 42 #include "net/spdy/spdy_session.h" |
43 #include "net/spdy/spdy_session_pool.h" | 43 #include "net/spdy/spdy_session_pool.h" |
44 #include "net/spdy/spdy_test_util_common.h" | 44 #include "net/spdy/spdy_test_util_common.h" |
45 #include "net/spdy/spdy_test_utils.h" | 45 #include "net/spdy/spdy_test_utils.h" |
46 #include "net/ssl/ssl_connection_status_flags.h" | 46 #include "net/ssl/ssl_connection_status_flags.h" |
47 #include "net/test/cert_test_util.h" | 47 #include "net/test/cert_test_util.h" |
| 48 #include "net/test/gtest_util.h" |
48 #include "net/test/test_data_directory.h" | 49 #include "net/test/test_data_directory.h" |
49 #include "net/url_request/url_request_test_util.h" | 50 #include "net/url_request/url_request_test_util.h" |
50 #include "testing/gmock/include/gmock/gmock.h" | 51 #include "testing/gmock/include/gmock/gmock.h" |
51 #include "testing/platform_test.h" | 52 #include "testing/platform_test.h" |
52 | 53 |
| 54 using net::test::IsError; |
| 55 using net::test::IsOk; |
| 56 |
53 //----------------------------------------------------------------------------- | 57 //----------------------------------------------------------------------------- |
54 | 58 |
55 namespace net { | 59 namespace net { |
56 | 60 |
57 namespace { | 61 namespace { |
58 | 62 |
59 using testing::Each; | 63 using testing::Each; |
60 using testing::Eq; | 64 using testing::Eq; |
61 | 65 |
62 const int32_t kBufferSize = SpdyHttpStream::kRequestBodyBufferSize; | 66 const int32_t kBufferSize = SpdyHttpStream::kRequestBodyBufferSize; |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 BoundNetLog(), GetParam(), NULL); | 533 BoundNetLog(), GetParam(), NULL); |
530 helper.RunPreTestSetup(); | 534 helper.RunPreTestSetup(); |
531 helper.AddData(data); | 535 helper.AddData(data); |
532 | 536 |
533 HttpNetworkTransaction* trans = helper.trans(); | 537 HttpNetworkTransaction* trans = helper.trans(); |
534 | 538 |
535 // Start the transaction with basic parameters. | 539 // Start the transaction with basic parameters. |
536 TestCompletionCallback callback; | 540 TestCompletionCallback callback; |
537 int rv = trans->Start( | 541 int rv = trans->Start( |
538 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 542 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
539 EXPECT_EQ(ERR_IO_PENDING, rv); | 543 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
540 rv = callback.WaitForResult(); | 544 rv = callback.WaitForResult(); |
541 | 545 |
542 // Request the pushed path. | 546 // Request the pushed path. |
543 std::unique_ptr<HttpNetworkTransaction> trans2( | 547 std::unique_ptr<HttpNetworkTransaction> trans2( |
544 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 548 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); |
545 rv = trans2->Start( | 549 rv = trans2->Start( |
546 &CreateGetPushRequest(), callback.callback(), BoundNetLog()); | 550 &CreateGetPushRequest(), callback.callback(), BoundNetLog()); |
547 EXPECT_EQ(ERR_IO_PENDING, rv); | 551 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
548 base::RunLoop().RunUntilIdle(); | 552 base::RunLoop().RunUntilIdle(); |
549 | 553 |
550 // The data for the pushed path may be coming in more than 1 frame. Compile | 554 // The data for the pushed path may be coming in more than 1 frame. Compile |
551 // the results into a single string. | 555 // the results into a single string. |
552 | 556 |
553 // Read the server push body. | 557 // Read the server push body. |
554 std::string result2; | 558 std::string result2; |
555 ReadResult(trans2.get(), &result2); | 559 ReadResult(trans2.get(), &result2); |
556 // Read the response body. | 560 // Read the response body. |
557 std::string result; | 561 std::string result; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 GURL url, | 598 GURL url, |
595 int result) { | 599 int result) { |
596 std::unique_ptr<HttpNetworkTransaction> trans( | 600 std::unique_ptr<HttpNetworkTransaction> trans( |
597 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 601 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); |
598 TestCompletionCallback callback; | 602 TestCompletionCallback callback; |
599 HttpRequestInfo request; | 603 HttpRequestInfo request; |
600 request.method = "GET"; | 604 request.method = "GET"; |
601 request.url = url; | 605 request.url = url; |
602 request.load_flags = 0; | 606 request.load_flags = 0; |
603 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 607 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
604 EXPECT_EQ(ERR_IO_PENDING, rv); | 608 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
605 callback.WaitForResult(); | 609 callback.WaitForResult(); |
606 } | 610 } |
607 | 611 |
608 ChunkedUploadDataStream* upload_chunked_data_stream() const { | 612 ChunkedUploadDataStream* upload_chunked_data_stream() const { |
609 return upload_chunked_data_stream_.get(); | 613 return upload_chunked_data_stream_.get(); |
610 } | 614 } |
611 | 615 |
612 std::string GetDefaultUrlWithPath(const char* path) { | 616 std::string GetDefaultUrlWithPath(const char* path) { |
613 return std::string(kDefaultUrl) + path; | 617 return std::string(kDefaultUrl) + path; |
614 } | 618 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 CreateMockRead(*resp, 1), | 672 CreateMockRead(*resp, 1), |
669 CreateMockRead(*body, 2), | 673 CreateMockRead(*body, 2), |
670 MockRead(ASYNC, 0, 3) // EOF | 674 MockRead(ASYNC, 0, 3) // EOF |
671 }; | 675 }; |
672 | 676 |
673 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 677 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
674 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 678 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
675 BoundNetLog(), GetParam(), NULL); | 679 BoundNetLog(), GetParam(), NULL); |
676 helper.RunToCompletion(&data); | 680 helper.RunToCompletion(&data); |
677 TransactionHelperResult out = helper.output(); | 681 TransactionHelperResult out = helper.output(); |
678 EXPECT_EQ(OK, out.rv); | 682 EXPECT_THAT(out.rv, IsOk()); |
679 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 683 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
680 EXPECT_EQ("hello!", out.response_data); | 684 EXPECT_EQ("hello!", out.response_data); |
681 } | 685 } |
682 | 686 |
683 TEST_P(SpdyNetworkTransactionTest, GetAtEachPriority) { | 687 TEST_P(SpdyNetworkTransactionTest, GetAtEachPriority) { |
684 for (RequestPriority p = MINIMUM_PRIORITY; p <= MAXIMUM_PRIORITY; | 688 for (RequestPriority p = MINIMUM_PRIORITY; p <= MAXIMUM_PRIORITY; |
685 p = RequestPriority(p + 1)) { | 689 p = RequestPriority(p + 1)) { |
686 SpdyTestUtil spdy_test_util(GetParam().protocol, | 690 SpdyTestUtil spdy_test_util(GetParam().protocol, |
687 GetParam().priority_to_dependency); | 691 GetParam().priority_to_dependency); |
688 | 692 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 }; | 732 }; |
729 | 733 |
730 SequencedSocketData data(reads, arraysize(reads), writes, | 734 SequencedSocketData data(reads, arraysize(reads), writes, |
731 arraysize(writes)); | 735 arraysize(writes)); |
732 HttpRequestInfo http_req = CreateGetRequest(); | 736 HttpRequestInfo http_req = CreateGetRequest(); |
733 | 737 |
734 NormalSpdyTransactionHelper helper(http_req, p, BoundNetLog(), | 738 NormalSpdyTransactionHelper helper(http_req, p, BoundNetLog(), |
735 GetParam(), NULL); | 739 GetParam(), NULL); |
736 helper.RunToCompletion(&data); | 740 helper.RunToCompletion(&data); |
737 TransactionHelperResult out = helper.output(); | 741 TransactionHelperResult out = helper.output(); |
738 EXPECT_EQ(OK, out.rv); | 742 EXPECT_THAT(out.rv, IsOk()); |
739 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 743 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
740 EXPECT_EQ("hello!", out.response_data); | 744 EXPECT_EQ("hello!", out.response_data); |
741 } | 745 } |
742 } | 746 } |
743 | 747 |
744 // Start three gets simultaniously; making sure that multiplexed | 748 // Start three gets simultaniously; making sure that multiplexed |
745 // streams work properly. | 749 // streams work properly. |
746 | 750 |
747 // This can't use the TransactionHelper method, since it only | 751 // This can't use the TransactionHelper method, since it only |
748 // handles a single transaction, and finishes them as soon | 752 // handles a single transaction, and finishes them as soon |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 | 826 |
823 TestCompletionCallback callback1; | 827 TestCompletionCallback callback1; |
824 TestCompletionCallback callback2; | 828 TestCompletionCallback callback2; |
825 TestCompletionCallback callback3; | 829 TestCompletionCallback callback3; |
826 | 830 |
827 HttpRequestInfo httpreq1 = CreateGetRequest(); | 831 HttpRequestInfo httpreq1 = CreateGetRequest(); |
828 HttpRequestInfo httpreq2 = CreateGetRequest(); | 832 HttpRequestInfo httpreq2 = CreateGetRequest(); |
829 HttpRequestInfo httpreq3 = CreateGetRequest(); | 833 HttpRequestInfo httpreq3 = CreateGetRequest(); |
830 | 834 |
831 out.rv = trans1->Start(&httpreq1, callback1.callback(), log); | 835 out.rv = trans1->Start(&httpreq1, callback1.callback(), log); |
832 ASSERT_EQ(ERR_IO_PENDING, out.rv); | 836 ASSERT_THAT(out.rv, IsError(ERR_IO_PENDING)); |
833 out.rv = trans2->Start(&httpreq2, callback2.callback(), log); | 837 out.rv = trans2->Start(&httpreq2, callback2.callback(), log); |
834 ASSERT_EQ(ERR_IO_PENDING, out.rv); | 838 ASSERT_THAT(out.rv, IsError(ERR_IO_PENDING)); |
835 out.rv = trans3->Start(&httpreq3, callback3.callback(), log); | 839 out.rv = trans3->Start(&httpreq3, callback3.callback(), log); |
836 ASSERT_EQ(ERR_IO_PENDING, out.rv); | 840 ASSERT_THAT(out.rv, IsError(ERR_IO_PENDING)); |
837 | 841 |
838 out.rv = callback1.WaitForResult(); | 842 out.rv = callback1.WaitForResult(); |
839 ASSERT_EQ(OK, out.rv); | 843 ASSERT_THAT(out.rv, IsOk()); |
840 out.rv = callback3.WaitForResult(); | 844 out.rv = callback3.WaitForResult(); |
841 ASSERT_EQ(OK, out.rv); | 845 ASSERT_THAT(out.rv, IsOk()); |
842 | 846 |
843 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); | 847 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); |
844 EXPECT_TRUE(response1->headers); | 848 EXPECT_TRUE(response1->headers); |
845 EXPECT_TRUE(response1->was_fetched_via_spdy); | 849 EXPECT_TRUE(response1->was_fetched_via_spdy); |
846 out.status_line = response1->headers->GetStatusLine(); | 850 out.status_line = response1->headers->GetStatusLine(); |
847 out.response_info = *response1; | 851 out.response_info = *response1; |
848 | 852 |
849 trans2->GetResponseInfo(); | 853 trans2->GetResponseInfo(); |
850 | 854 |
851 out.rv = ReadTransaction(trans1.get(), &out.response_data); | 855 out.rv = ReadTransaction(trans1.get(), &out.response_data); |
852 helper.VerifyDataConsumed(); | 856 helper.VerifyDataConsumed(); |
853 EXPECT_EQ(OK, out.rv); | 857 EXPECT_THAT(out.rv, IsOk()); |
854 | 858 |
855 EXPECT_EQ(OK, out.rv); | 859 EXPECT_THAT(out.rv, IsOk()); |
856 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 860 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
857 EXPECT_EQ("hello!hello!", out.response_data); | 861 EXPECT_EQ("hello!hello!", out.response_data); |
858 } | 862 } |
859 | 863 |
860 TEST_P(SpdyNetworkTransactionTest, TwoGetsLateBinding) { | 864 TEST_P(SpdyNetworkTransactionTest, TwoGetsLateBinding) { |
861 std::unique_ptr<SpdySerializedFrame> req( | 865 std::unique_ptr<SpdySerializedFrame> req( |
862 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 866 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
863 std::unique_ptr<SpdySerializedFrame> resp( | 867 std::unique_ptr<SpdySerializedFrame> resp( |
864 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 868 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
865 std::unique_ptr<SpdySerializedFrame> body( | 869 std::unique_ptr<SpdySerializedFrame> body( |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
909 std::unique_ptr<HttpNetworkTransaction> trans2( | 913 std::unique_ptr<HttpNetworkTransaction> trans2( |
910 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 914 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); |
911 | 915 |
912 TestCompletionCallback callback1; | 916 TestCompletionCallback callback1; |
913 TestCompletionCallback callback2; | 917 TestCompletionCallback callback2; |
914 | 918 |
915 HttpRequestInfo httpreq1 = CreateGetRequest(); | 919 HttpRequestInfo httpreq1 = CreateGetRequest(); |
916 HttpRequestInfo httpreq2 = CreateGetRequest(); | 920 HttpRequestInfo httpreq2 = CreateGetRequest(); |
917 | 921 |
918 out.rv = trans1->Start(&httpreq1, callback1.callback(), log); | 922 out.rv = trans1->Start(&httpreq1, callback1.callback(), log); |
919 ASSERT_EQ(ERR_IO_PENDING, out.rv); | 923 ASSERT_THAT(out.rv, IsError(ERR_IO_PENDING)); |
920 out.rv = trans2->Start(&httpreq2, callback2.callback(), log); | 924 out.rv = trans2->Start(&httpreq2, callback2.callback(), log); |
921 ASSERT_EQ(ERR_IO_PENDING, out.rv); | 925 ASSERT_THAT(out.rv, IsError(ERR_IO_PENDING)); |
922 | 926 |
923 out.rv = callback1.WaitForResult(); | 927 out.rv = callback1.WaitForResult(); |
924 ASSERT_EQ(OK, out.rv); | 928 ASSERT_THAT(out.rv, IsOk()); |
925 out.rv = callback2.WaitForResult(); | 929 out.rv = callback2.WaitForResult(); |
926 ASSERT_EQ(OK, out.rv); | 930 ASSERT_THAT(out.rv, IsOk()); |
927 | 931 |
928 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); | 932 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); |
929 EXPECT_TRUE(response1->headers); | 933 EXPECT_TRUE(response1->headers); |
930 EXPECT_TRUE(response1->was_fetched_via_spdy); | 934 EXPECT_TRUE(response1->was_fetched_via_spdy); |
931 out.status_line = response1->headers->GetStatusLine(); | 935 out.status_line = response1->headers->GetStatusLine(); |
932 out.response_info = *response1; | 936 out.response_info = *response1; |
933 out.rv = ReadTransaction(trans1.get(), &out.response_data); | 937 out.rv = ReadTransaction(trans1.get(), &out.response_data); |
934 EXPECT_EQ(OK, out.rv); | 938 EXPECT_THAT(out.rv, IsOk()); |
935 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 939 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
936 EXPECT_EQ("hello!hello!", out.response_data); | 940 EXPECT_EQ("hello!hello!", out.response_data); |
937 | 941 |
938 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); | 942 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); |
939 EXPECT_TRUE(response2->headers); | 943 EXPECT_TRUE(response2->headers); |
940 EXPECT_TRUE(response2->was_fetched_via_spdy); | 944 EXPECT_TRUE(response2->was_fetched_via_spdy); |
941 out.status_line = response2->headers->GetStatusLine(); | 945 out.status_line = response2->headers->GetStatusLine(); |
942 out.response_info = *response2; | 946 out.response_info = *response2; |
943 out.rv = ReadTransaction(trans2.get(), &out.response_data); | 947 out.rv = ReadTransaction(trans2.get(), &out.response_data); |
944 EXPECT_EQ(OK, out.rv); | 948 EXPECT_THAT(out.rv, IsOk()); |
945 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 949 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
946 EXPECT_EQ("hello!hello!", out.response_data); | 950 EXPECT_EQ("hello!hello!", out.response_data); |
947 | 951 |
948 helper.VerifyDataConsumed(); | 952 helper.VerifyDataConsumed(); |
949 } | 953 } |
950 | 954 |
951 TEST_P(SpdyNetworkTransactionTest, TwoGetsLateBindingFromPreconnect) { | 955 TEST_P(SpdyNetworkTransactionTest, TwoGetsLateBindingFromPreconnect) { |
952 std::unique_ptr<SpdySerializedFrame> req( | 956 std::unique_ptr<SpdySerializedFrame> req( |
953 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 957 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
954 std::unique_ptr<SpdySerializedFrame> resp( | 958 std::unique_ptr<SpdySerializedFrame> resp( |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1008 | 1012 |
1009 HttpRequestInfo httpreq = CreateGetRequest(); | 1013 HttpRequestInfo httpreq = CreateGetRequest(); |
1010 | 1014 |
1011 // Preconnect the first. | 1015 // Preconnect the first. |
1012 HttpStreamFactory* http_stream_factory = | 1016 HttpStreamFactory* http_stream_factory = |
1013 helper.session()->http_stream_factory(); | 1017 helper.session()->http_stream_factory(); |
1014 | 1018 |
1015 http_stream_factory->PreconnectStreams(1, httpreq); | 1019 http_stream_factory->PreconnectStreams(1, httpreq); |
1016 | 1020 |
1017 out.rv = trans1->Start(&httpreq, callback1.callback(), log); | 1021 out.rv = trans1->Start(&httpreq, callback1.callback(), log); |
1018 ASSERT_EQ(ERR_IO_PENDING, out.rv); | 1022 ASSERT_THAT(out.rv, IsError(ERR_IO_PENDING)); |
1019 out.rv = trans2->Start(&httpreq, callback2.callback(), log); | 1023 out.rv = trans2->Start(&httpreq, callback2.callback(), log); |
1020 ASSERT_EQ(ERR_IO_PENDING, out.rv); | 1024 ASSERT_THAT(out.rv, IsError(ERR_IO_PENDING)); |
1021 | 1025 |
1022 out.rv = callback1.WaitForResult(); | 1026 out.rv = callback1.WaitForResult(); |
1023 ASSERT_EQ(OK, out.rv); | 1027 ASSERT_THAT(out.rv, IsOk()); |
1024 out.rv = callback2.WaitForResult(); | 1028 out.rv = callback2.WaitForResult(); |
1025 ASSERT_EQ(OK, out.rv); | 1029 ASSERT_THAT(out.rv, IsOk()); |
1026 | 1030 |
1027 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); | 1031 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); |
1028 EXPECT_TRUE(response1->headers); | 1032 EXPECT_TRUE(response1->headers); |
1029 EXPECT_TRUE(response1->was_fetched_via_spdy); | 1033 EXPECT_TRUE(response1->was_fetched_via_spdy); |
1030 out.status_line = response1->headers->GetStatusLine(); | 1034 out.status_line = response1->headers->GetStatusLine(); |
1031 out.response_info = *response1; | 1035 out.response_info = *response1; |
1032 out.rv = ReadTransaction(trans1.get(), &out.response_data); | 1036 out.rv = ReadTransaction(trans1.get(), &out.response_data); |
1033 EXPECT_EQ(OK, out.rv); | 1037 EXPECT_THAT(out.rv, IsOk()); |
1034 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 1038 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
1035 EXPECT_EQ("hello!hello!", out.response_data); | 1039 EXPECT_EQ("hello!hello!", out.response_data); |
1036 | 1040 |
1037 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); | 1041 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); |
1038 EXPECT_TRUE(response2->headers); | 1042 EXPECT_TRUE(response2->headers); |
1039 EXPECT_TRUE(response2->was_fetched_via_spdy); | 1043 EXPECT_TRUE(response2->was_fetched_via_spdy); |
1040 out.status_line = response2->headers->GetStatusLine(); | 1044 out.status_line = response2->headers->GetStatusLine(); |
1041 out.response_info = *response2; | 1045 out.response_info = *response2; |
1042 out.rv = ReadTransaction(trans2.get(), &out.response_data); | 1046 out.rv = ReadTransaction(trans2.get(), &out.response_data); |
1043 EXPECT_EQ(OK, out.rv); | 1047 EXPECT_THAT(out.rv, IsOk()); |
1044 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 1048 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
1045 EXPECT_EQ("hello!hello!", out.response_data); | 1049 EXPECT_EQ("hello!hello!", out.response_data); |
1046 | 1050 |
1047 helper.VerifyDataConsumed(); | 1051 helper.VerifyDataConsumed(); |
1048 } | 1052 } |
1049 | 1053 |
1050 // Similar to ThreeGets above, however this test adds a SETTINGS | 1054 // Similar to ThreeGets above, however this test adds a SETTINGS |
1051 // frame. The SETTINGS frame is read during the IO loop waiting on | 1055 // frame. The SETTINGS frame is read during the IO loop waiting on |
1052 // the first transaction completion, and sets a maximum concurrent | 1056 // the first transaction completion, and sets a maximum concurrent |
1053 // stream limit of 1. This means that our IO loop exists after the | 1057 // stream limit of 1. This means that our IO loop exists after the |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1137 | 1141 |
1138 HttpRequestInfo httpreq1 = CreateGetRequest(); | 1142 HttpRequestInfo httpreq1 = CreateGetRequest(); |
1139 HttpRequestInfo httpreq2 = CreateGetRequest(); | 1143 HttpRequestInfo httpreq2 = CreateGetRequest(); |
1140 HttpRequestInfo httpreq3 = CreateGetRequest(); | 1144 HttpRequestInfo httpreq3 = CreateGetRequest(); |
1141 | 1145 |
1142 out.rv = trans1->Start(&httpreq1, callback1.callback(), log); | 1146 out.rv = trans1->Start(&httpreq1, callback1.callback(), log); |
1143 ASSERT_EQ(out.rv, ERR_IO_PENDING); | 1147 ASSERT_EQ(out.rv, ERR_IO_PENDING); |
1144 // Run transaction 1 through quickly to force a read of our SETTINGS | 1148 // Run transaction 1 through quickly to force a read of our SETTINGS |
1145 // frame. | 1149 // frame. |
1146 out.rv = callback1.WaitForResult(); | 1150 out.rv = callback1.WaitForResult(); |
1147 ASSERT_EQ(OK, out.rv); | 1151 ASSERT_THAT(out.rv, IsOk()); |
1148 | 1152 |
1149 out.rv = trans2->Start(&httpreq2, callback2.callback(), log); | 1153 out.rv = trans2->Start(&httpreq2, callback2.callback(), log); |
1150 ASSERT_EQ(out.rv, ERR_IO_PENDING); | 1154 ASSERT_EQ(out.rv, ERR_IO_PENDING); |
1151 out.rv = trans3->Start(&httpreq3, callback3.callback(), log); | 1155 out.rv = trans3->Start(&httpreq3, callback3.callback(), log); |
1152 ASSERT_EQ(out.rv, ERR_IO_PENDING); | 1156 ASSERT_EQ(out.rv, ERR_IO_PENDING); |
1153 out.rv = callback2.WaitForResult(); | 1157 out.rv = callback2.WaitForResult(); |
1154 ASSERT_EQ(OK, out.rv); | 1158 ASSERT_THAT(out.rv, IsOk()); |
1155 | 1159 |
1156 out.rv = callback3.WaitForResult(); | 1160 out.rv = callback3.WaitForResult(); |
1157 ASSERT_EQ(OK, out.rv); | 1161 ASSERT_THAT(out.rv, IsOk()); |
1158 | 1162 |
1159 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); | 1163 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); |
1160 ASSERT_TRUE(response1); | 1164 ASSERT_TRUE(response1); |
1161 EXPECT_TRUE(response1->headers); | 1165 EXPECT_TRUE(response1->headers); |
1162 EXPECT_TRUE(response1->was_fetched_via_spdy); | 1166 EXPECT_TRUE(response1->was_fetched_via_spdy); |
1163 out.status_line = response1->headers->GetStatusLine(); | 1167 out.status_line = response1->headers->GetStatusLine(); |
1164 out.response_info = *response1; | 1168 out.response_info = *response1; |
1165 out.rv = ReadTransaction(trans1.get(), &out.response_data); | 1169 out.rv = ReadTransaction(trans1.get(), &out.response_data); |
1166 EXPECT_EQ(OK, out.rv); | 1170 EXPECT_THAT(out.rv, IsOk()); |
1167 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 1171 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
1168 EXPECT_EQ("hello!hello!", out.response_data); | 1172 EXPECT_EQ("hello!hello!", out.response_data); |
1169 | 1173 |
1170 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); | 1174 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); |
1171 out.status_line = response2->headers->GetStatusLine(); | 1175 out.status_line = response2->headers->GetStatusLine(); |
1172 out.response_info = *response2; | 1176 out.response_info = *response2; |
1173 out.rv = ReadTransaction(trans2.get(), &out.response_data); | 1177 out.rv = ReadTransaction(trans2.get(), &out.response_data); |
1174 EXPECT_EQ(OK, out.rv); | 1178 EXPECT_THAT(out.rv, IsOk()); |
1175 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 1179 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
1176 EXPECT_EQ("hello!hello!", out.response_data); | 1180 EXPECT_EQ("hello!hello!", out.response_data); |
1177 | 1181 |
1178 const HttpResponseInfo* response3 = trans3->GetResponseInfo(); | 1182 const HttpResponseInfo* response3 = trans3->GetResponseInfo(); |
1179 out.status_line = response3->headers->GetStatusLine(); | 1183 out.status_line = response3->headers->GetStatusLine(); |
1180 out.response_info = *response3; | 1184 out.response_info = *response3; |
1181 out.rv = ReadTransaction(trans3.get(), &out.response_data); | 1185 out.rv = ReadTransaction(trans3.get(), &out.response_data); |
1182 EXPECT_EQ(OK, out.rv); | 1186 EXPECT_THAT(out.rv, IsOk()); |
1183 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 1187 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
1184 EXPECT_EQ("hello!hello!", out.response_data); | 1188 EXPECT_EQ("hello!hello!", out.response_data); |
1185 | 1189 |
1186 helper.VerifyDataConsumed(); | 1190 helper.VerifyDataConsumed(); |
1187 } | 1191 } |
1188 EXPECT_EQ(OK, out.rv); | 1192 EXPECT_THAT(out.rv, IsOk()); |
1189 } | 1193 } |
1190 | 1194 |
1191 // Similar to ThreeGetsWithMaxConcurrent above, however this test adds | 1195 // Similar to ThreeGetsWithMaxConcurrent above, however this test adds |
1192 // a fourth transaction. The third and fourth transactions have | 1196 // a fourth transaction. The third and fourth transactions have |
1193 // different data ("hello!" vs "hello!hello!") and because of the | 1197 // different data ("hello!" vs "hello!hello!") and because of the |
1194 // user specified priority, we expect to see them inverted in | 1198 // user specified priority, we expect to see them inverted in |
1195 // the response from the server. | 1199 // the response from the server. |
1196 TEST_P(SpdyNetworkTransactionTest, FourGetsWithMaxConcurrentPriority) { | 1200 TEST_P(SpdyNetworkTransactionTest, FourGetsWithMaxConcurrentPriority) { |
1197 // Construct the request. | 1201 // Construct the request. |
1198 std::unique_ptr<SpdySerializedFrame> req( | 1202 std::unique_ptr<SpdySerializedFrame> req( |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1287 TestCompletionCallback callback2; | 1291 TestCompletionCallback callback2; |
1288 TestCompletionCallback callback3; | 1292 TestCompletionCallback callback3; |
1289 TestCompletionCallback callback4; | 1293 TestCompletionCallback callback4; |
1290 | 1294 |
1291 HttpRequestInfo httpreq1 = CreateGetRequest(); | 1295 HttpRequestInfo httpreq1 = CreateGetRequest(); |
1292 HttpRequestInfo httpreq2 = CreateGetRequest(); | 1296 HttpRequestInfo httpreq2 = CreateGetRequest(); |
1293 HttpRequestInfo httpreq3 = CreateGetRequest(); | 1297 HttpRequestInfo httpreq3 = CreateGetRequest(); |
1294 HttpRequestInfo httpreq4 = CreateGetRequest(); | 1298 HttpRequestInfo httpreq4 = CreateGetRequest(); |
1295 | 1299 |
1296 out.rv = trans1->Start(&httpreq1, callback1.callback(), log); | 1300 out.rv = trans1->Start(&httpreq1, callback1.callback(), log); |
1297 ASSERT_EQ(ERR_IO_PENDING, out.rv); | 1301 ASSERT_THAT(out.rv, IsError(ERR_IO_PENDING)); |
1298 // Run transaction 1 through quickly to force a read of our SETTINGS frame. | 1302 // Run transaction 1 through quickly to force a read of our SETTINGS frame. |
1299 out.rv = callback1.WaitForResult(); | 1303 out.rv = callback1.WaitForResult(); |
1300 ASSERT_EQ(OK, out.rv); | 1304 ASSERT_THAT(out.rv, IsOk()); |
1301 | 1305 |
1302 out.rv = trans2->Start(&httpreq2, callback2.callback(), log); | 1306 out.rv = trans2->Start(&httpreq2, callback2.callback(), log); |
1303 ASSERT_EQ(ERR_IO_PENDING, out.rv); | 1307 ASSERT_THAT(out.rv, IsError(ERR_IO_PENDING)); |
1304 out.rv = trans3->Start(&httpreq3, callback3.callback(), log); | 1308 out.rv = trans3->Start(&httpreq3, callback3.callback(), log); |
1305 ASSERT_EQ(ERR_IO_PENDING, out.rv); | 1309 ASSERT_THAT(out.rv, IsError(ERR_IO_PENDING)); |
1306 out.rv = trans4->Start(&httpreq4, callback4.callback(), log); | 1310 out.rv = trans4->Start(&httpreq4, callback4.callback(), log); |
1307 ASSERT_EQ(ERR_IO_PENDING, out.rv); | 1311 ASSERT_THAT(out.rv, IsError(ERR_IO_PENDING)); |
1308 | 1312 |
1309 out.rv = callback2.WaitForResult(); | 1313 out.rv = callback2.WaitForResult(); |
1310 ASSERT_EQ(OK, out.rv); | 1314 ASSERT_THAT(out.rv, IsOk()); |
1311 | 1315 |
1312 out.rv = callback3.WaitForResult(); | 1316 out.rv = callback3.WaitForResult(); |
1313 ASSERT_EQ(OK, out.rv); | 1317 ASSERT_THAT(out.rv, IsOk()); |
1314 | 1318 |
1315 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); | 1319 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); |
1316 EXPECT_TRUE(response1->headers); | 1320 EXPECT_TRUE(response1->headers); |
1317 EXPECT_TRUE(response1->was_fetched_via_spdy); | 1321 EXPECT_TRUE(response1->was_fetched_via_spdy); |
1318 out.status_line = response1->headers->GetStatusLine(); | 1322 out.status_line = response1->headers->GetStatusLine(); |
1319 out.response_info = *response1; | 1323 out.response_info = *response1; |
1320 out.rv = ReadTransaction(trans1.get(), &out.response_data); | 1324 out.rv = ReadTransaction(trans1.get(), &out.response_data); |
1321 EXPECT_EQ(OK, out.rv); | 1325 EXPECT_THAT(out.rv, IsOk()); |
1322 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 1326 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
1323 EXPECT_EQ("hello!hello!", out.response_data); | 1327 EXPECT_EQ("hello!hello!", out.response_data); |
1324 | 1328 |
1325 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); | 1329 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); |
1326 out.status_line = response2->headers->GetStatusLine(); | 1330 out.status_line = response2->headers->GetStatusLine(); |
1327 out.response_info = *response2; | 1331 out.response_info = *response2; |
1328 out.rv = ReadTransaction(trans2.get(), &out.response_data); | 1332 out.rv = ReadTransaction(trans2.get(), &out.response_data); |
1329 EXPECT_EQ(OK, out.rv); | 1333 EXPECT_THAT(out.rv, IsOk()); |
1330 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 1334 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
1331 EXPECT_EQ("hello!hello!", out.response_data); | 1335 EXPECT_EQ("hello!hello!", out.response_data); |
1332 | 1336 |
1333 // notice: response3 gets two hellos, response4 gets one | 1337 // notice: response3 gets two hellos, response4 gets one |
1334 // hello, so we know dequeuing priority was respected. | 1338 // hello, so we know dequeuing priority was respected. |
1335 const HttpResponseInfo* response3 = trans3->GetResponseInfo(); | 1339 const HttpResponseInfo* response3 = trans3->GetResponseInfo(); |
1336 out.status_line = response3->headers->GetStatusLine(); | 1340 out.status_line = response3->headers->GetStatusLine(); |
1337 out.response_info = *response3; | 1341 out.response_info = *response3; |
1338 out.rv = ReadTransaction(trans3.get(), &out.response_data); | 1342 out.rv = ReadTransaction(trans3.get(), &out.response_data); |
1339 EXPECT_EQ(OK, out.rv); | 1343 EXPECT_THAT(out.rv, IsOk()); |
1340 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 1344 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
1341 EXPECT_EQ("hello!hello!", out.response_data); | 1345 EXPECT_EQ("hello!hello!", out.response_data); |
1342 | 1346 |
1343 out.rv = callback4.WaitForResult(); | 1347 out.rv = callback4.WaitForResult(); |
1344 EXPECT_EQ(OK, out.rv); | 1348 EXPECT_THAT(out.rv, IsOk()); |
1345 const HttpResponseInfo* response4 = trans4->GetResponseInfo(); | 1349 const HttpResponseInfo* response4 = trans4->GetResponseInfo(); |
1346 out.status_line = response4->headers->GetStatusLine(); | 1350 out.status_line = response4->headers->GetStatusLine(); |
1347 out.response_info = *response4; | 1351 out.response_info = *response4; |
1348 out.rv = ReadTransaction(trans4.get(), &out.response_data); | 1352 out.rv = ReadTransaction(trans4.get(), &out.response_data); |
1349 EXPECT_EQ(OK, out.rv); | 1353 EXPECT_THAT(out.rv, IsOk()); |
1350 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 1354 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
1351 EXPECT_EQ("hello!", out.response_data); | 1355 EXPECT_EQ("hello!", out.response_data); |
1352 helper.VerifyDataConsumed(); | 1356 helper.VerifyDataConsumed(); |
1353 EXPECT_EQ(OK, out.rv); | 1357 EXPECT_THAT(out.rv, IsOk()); |
1354 } | 1358 } |
1355 | 1359 |
1356 // Similar to ThreeGetsMaxConcurrrent above, however, this test | 1360 // Similar to ThreeGetsMaxConcurrrent above, however, this test |
1357 // deletes a session in the middle of the transaction to ensure | 1361 // deletes a session in the middle of the transaction to ensure |
1358 // that we properly remove pendingcreatestream objects from | 1362 // that we properly remove pendingcreatestream objects from |
1359 // the spdy_session | 1363 // the spdy_session |
1360 TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrentDelete) { | 1364 TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrentDelete) { |
1361 // Construct the request. | 1365 // Construct the request. |
1362 std::unique_ptr<SpdySerializedFrame> req( | 1366 std::unique_ptr<SpdySerializedFrame> req( |
1363 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 1367 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1423 TestCompletionCallback callback3; | 1427 TestCompletionCallback callback3; |
1424 | 1428 |
1425 HttpRequestInfo httpreq1 = CreateGetRequest(); | 1429 HttpRequestInfo httpreq1 = CreateGetRequest(); |
1426 HttpRequestInfo httpreq2 = CreateGetRequest(); | 1430 HttpRequestInfo httpreq2 = CreateGetRequest(); |
1427 HttpRequestInfo httpreq3 = CreateGetRequest(); | 1431 HttpRequestInfo httpreq3 = CreateGetRequest(); |
1428 | 1432 |
1429 out.rv = trans1->Start(&httpreq1, callback1.callback(), log); | 1433 out.rv = trans1->Start(&httpreq1, callback1.callback(), log); |
1430 ASSERT_EQ(out.rv, ERR_IO_PENDING); | 1434 ASSERT_EQ(out.rv, ERR_IO_PENDING); |
1431 // Run transaction 1 through quickly to force a read of our SETTINGS frame. | 1435 // Run transaction 1 through quickly to force a read of our SETTINGS frame. |
1432 out.rv = callback1.WaitForResult(); | 1436 out.rv = callback1.WaitForResult(); |
1433 ASSERT_EQ(OK, out.rv); | 1437 ASSERT_THAT(out.rv, IsOk()); |
1434 | 1438 |
1435 out.rv = trans2->Start(&httpreq2, callback2.callback(), log); | 1439 out.rv = trans2->Start(&httpreq2, callback2.callback(), log); |
1436 ASSERT_EQ(out.rv, ERR_IO_PENDING); | 1440 ASSERT_EQ(out.rv, ERR_IO_PENDING); |
1437 out.rv = trans3->Start(&httpreq3, callback3.callback(), log); | 1441 out.rv = trans3->Start(&httpreq3, callback3.callback(), log); |
1438 trans3.reset(); | 1442 trans3.reset(); |
1439 ASSERT_EQ(out.rv, ERR_IO_PENDING); | 1443 ASSERT_EQ(out.rv, ERR_IO_PENDING); |
1440 out.rv = callback2.WaitForResult(); | 1444 out.rv = callback2.WaitForResult(); |
1441 ASSERT_EQ(OK, out.rv); | 1445 ASSERT_THAT(out.rv, IsOk()); |
1442 | 1446 |
1443 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); | 1447 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); |
1444 ASSERT_TRUE(response1); | 1448 ASSERT_TRUE(response1); |
1445 EXPECT_TRUE(response1->headers); | 1449 EXPECT_TRUE(response1->headers); |
1446 EXPECT_TRUE(response1->was_fetched_via_spdy); | 1450 EXPECT_TRUE(response1->was_fetched_via_spdy); |
1447 out.status_line = response1->headers->GetStatusLine(); | 1451 out.status_line = response1->headers->GetStatusLine(); |
1448 out.response_info = *response1; | 1452 out.response_info = *response1; |
1449 out.rv = ReadTransaction(trans1.get(), &out.response_data); | 1453 out.rv = ReadTransaction(trans1.get(), &out.response_data); |
1450 EXPECT_EQ(OK, out.rv); | 1454 EXPECT_THAT(out.rv, IsOk()); |
1451 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 1455 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
1452 EXPECT_EQ("hello!hello!", out.response_data); | 1456 EXPECT_EQ("hello!hello!", out.response_data); |
1453 | 1457 |
1454 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); | 1458 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); |
1455 ASSERT_TRUE(response2); | 1459 ASSERT_TRUE(response2); |
1456 out.status_line = response2->headers->GetStatusLine(); | 1460 out.status_line = response2->headers->GetStatusLine(); |
1457 out.response_info = *response2; | 1461 out.response_info = *response2; |
1458 out.rv = ReadTransaction(trans2.get(), &out.response_data); | 1462 out.rv = ReadTransaction(trans2.get(), &out.response_data); |
1459 EXPECT_EQ(OK, out.rv); | 1463 EXPECT_THAT(out.rv, IsOk()); |
1460 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 1464 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
1461 EXPECT_EQ("hello!hello!", out.response_data); | 1465 EXPECT_EQ("hello!hello!", out.response_data); |
1462 helper.VerifyDataConsumed(); | 1466 helper.VerifyDataConsumed(); |
1463 EXPECT_EQ(OK, out.rv); | 1467 EXPECT_THAT(out.rv, IsOk()); |
1464 } | 1468 } |
1465 | 1469 |
1466 namespace { | 1470 namespace { |
1467 | 1471 |
1468 // The KillerCallback will delete the transaction on error as part of the | 1472 // The KillerCallback will delete the transaction on error as part of the |
1469 // callback. | 1473 // callback. |
1470 class KillerCallback : public TestCompletionCallbackBase { | 1474 class KillerCallback : public TestCompletionCallbackBase { |
1471 public: | 1475 public: |
1472 explicit KillerCallback(HttpNetworkTransaction* transaction) | 1476 explicit KillerCallback(HttpNetworkTransaction* transaction) |
1473 : transaction_(transaction), | 1477 : transaction_(transaction), |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1559 KillerCallback callback3(trans3); | 1563 KillerCallback callback3(trans3); |
1560 | 1564 |
1561 HttpRequestInfo httpreq1 = CreateGetRequest(); | 1565 HttpRequestInfo httpreq1 = CreateGetRequest(); |
1562 HttpRequestInfo httpreq2 = CreateGetRequest(); | 1566 HttpRequestInfo httpreq2 = CreateGetRequest(); |
1563 HttpRequestInfo httpreq3 = CreateGetRequest(); | 1567 HttpRequestInfo httpreq3 = CreateGetRequest(); |
1564 | 1568 |
1565 out.rv = trans1.Start(&httpreq1, callback1.callback(), log); | 1569 out.rv = trans1.Start(&httpreq1, callback1.callback(), log); |
1566 ASSERT_EQ(out.rv, ERR_IO_PENDING); | 1570 ASSERT_EQ(out.rv, ERR_IO_PENDING); |
1567 // Run transaction 1 through quickly to force a read of our SETTINGS frame. | 1571 // Run transaction 1 through quickly to force a read of our SETTINGS frame. |
1568 out.rv = callback1.WaitForResult(); | 1572 out.rv = callback1.WaitForResult(); |
1569 ASSERT_EQ(OK, out.rv); | 1573 ASSERT_THAT(out.rv, IsOk()); |
1570 | 1574 |
1571 out.rv = trans2.Start(&httpreq2, callback2.callback(), log); | 1575 out.rv = trans2.Start(&httpreq2, callback2.callback(), log); |
1572 ASSERT_EQ(out.rv, ERR_IO_PENDING); | 1576 ASSERT_EQ(out.rv, ERR_IO_PENDING); |
1573 out.rv = trans3->Start(&httpreq3, callback3.callback(), log); | 1577 out.rv = trans3->Start(&httpreq3, callback3.callback(), log); |
1574 ASSERT_EQ(out.rv, ERR_IO_PENDING); | 1578 ASSERT_EQ(out.rv, ERR_IO_PENDING); |
1575 out.rv = callback3.WaitForResult(); | 1579 out.rv = callback3.WaitForResult(); |
1576 ASSERT_EQ(ERR_ABORTED, out.rv); | 1580 ASSERT_THAT(out.rv, IsError(ERR_ABORTED)); |
1577 | 1581 |
1578 const HttpResponseInfo* response1 = trans1.GetResponseInfo(); | 1582 const HttpResponseInfo* response1 = trans1.GetResponseInfo(); |
1579 ASSERT_TRUE(response1); | 1583 ASSERT_TRUE(response1); |
1580 EXPECT_TRUE(response1->headers); | 1584 EXPECT_TRUE(response1->headers); |
1581 EXPECT_TRUE(response1->was_fetched_via_spdy); | 1585 EXPECT_TRUE(response1->was_fetched_via_spdy); |
1582 out.status_line = response1->headers->GetStatusLine(); | 1586 out.status_line = response1->headers->GetStatusLine(); |
1583 out.response_info = *response1; | 1587 out.response_info = *response1; |
1584 out.rv = ReadTransaction(&trans1, &out.response_data); | 1588 out.rv = ReadTransaction(&trans1, &out.response_data); |
1585 EXPECT_EQ(OK, out.rv); | 1589 EXPECT_THAT(out.rv, IsOk()); |
1586 | 1590 |
1587 const HttpResponseInfo* response2 = trans2.GetResponseInfo(); | 1591 const HttpResponseInfo* response2 = trans2.GetResponseInfo(); |
1588 ASSERT_TRUE(response2); | 1592 ASSERT_TRUE(response2); |
1589 out.status_line = response2->headers->GetStatusLine(); | 1593 out.status_line = response2->headers->GetStatusLine(); |
1590 out.response_info = *response2; | 1594 out.response_info = *response2; |
1591 out.rv = ReadTransaction(&trans2, &out.response_data); | 1595 out.rv = ReadTransaction(&trans2, &out.response_data); |
1592 EXPECT_EQ(ERR_CONNECTION_RESET, out.rv); | 1596 EXPECT_THAT(out.rv, IsError(ERR_CONNECTION_RESET)); |
1593 | 1597 |
1594 helper.VerifyDataConsumed(); | 1598 helper.VerifyDataConsumed(); |
1595 } | 1599 } |
1596 | 1600 |
1597 // Test that a simple PUT request works. | 1601 // Test that a simple PUT request works. |
1598 TEST_P(SpdyNetworkTransactionTest, Put) { | 1602 TEST_P(SpdyNetworkTransactionTest, Put) { |
1599 // Setup the request | 1603 // Setup the request |
1600 HttpRequestInfo request; | 1604 HttpRequestInfo request; |
1601 request.method = "PUT"; | 1605 request.method = "PUT"; |
1602 request.url = default_url_; | 1606 request.url = default_url_; |
(...skipping 15 matching lines...) Expand all Loading... |
1618 CreateMockRead(*body, 2), | 1622 CreateMockRead(*body, 2), |
1619 MockRead(ASYNC, 0, 3) // EOF | 1623 MockRead(ASYNC, 0, 3) // EOF |
1620 }; | 1624 }; |
1621 | 1625 |
1622 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 1626 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
1623 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, | 1627 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, |
1624 BoundNetLog(), GetParam(), NULL); | 1628 BoundNetLog(), GetParam(), NULL); |
1625 helper.RunToCompletion(&data); | 1629 helper.RunToCompletion(&data); |
1626 TransactionHelperResult out = helper.output(); | 1630 TransactionHelperResult out = helper.output(); |
1627 | 1631 |
1628 EXPECT_EQ(OK, out.rv); | 1632 EXPECT_THAT(out.rv, IsOk()); |
1629 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 1633 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
1630 } | 1634 } |
1631 | 1635 |
1632 // Test that a simple HEAD request works. | 1636 // Test that a simple HEAD request works. |
1633 TEST_P(SpdyNetworkTransactionTest, Head) { | 1637 TEST_P(SpdyNetworkTransactionTest, Head) { |
1634 // Setup the request | 1638 // Setup the request |
1635 HttpRequestInfo request; | 1639 HttpRequestInfo request; |
1636 request.method = "HEAD"; | 1640 request.method = "HEAD"; |
1637 request.url = default_url_; | 1641 request.url = default_url_; |
1638 | 1642 |
(...skipping 14 matching lines...) Expand all Loading... |
1653 CreateMockRead(*body, 2), | 1657 CreateMockRead(*body, 2), |
1654 MockRead(ASYNC, 0, 3) // EOF | 1658 MockRead(ASYNC, 0, 3) // EOF |
1655 }; | 1659 }; |
1656 | 1660 |
1657 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 1661 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
1658 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, | 1662 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, |
1659 BoundNetLog(), GetParam(), NULL); | 1663 BoundNetLog(), GetParam(), NULL); |
1660 helper.RunToCompletion(&data); | 1664 helper.RunToCompletion(&data); |
1661 TransactionHelperResult out = helper.output(); | 1665 TransactionHelperResult out = helper.output(); |
1662 | 1666 |
1663 EXPECT_EQ(OK, out.rv); | 1667 EXPECT_THAT(out.rv, IsOk()); |
1664 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 1668 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
1665 } | 1669 } |
1666 | 1670 |
1667 // Test that a simple POST works. | 1671 // Test that a simple POST works. |
1668 TEST_P(SpdyNetworkTransactionTest, Post) { | 1672 TEST_P(SpdyNetworkTransactionTest, Post) { |
1669 std::unique_ptr<SpdySerializedFrame> req(spdy_util_.ConstructSpdyPost( | 1673 std::unique_ptr<SpdySerializedFrame> req(spdy_util_.ConstructSpdyPost( |
1670 kDefaultUrl, 1, kUploadDataSize, LOWEST, NULL, 0)); | 1674 kDefaultUrl, 1, kUploadDataSize, LOWEST, NULL, 0)); |
1671 std::unique_ptr<SpdySerializedFrame> body( | 1675 std::unique_ptr<SpdySerializedFrame> body( |
1672 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 1676 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
1673 MockWrite writes[] = { | 1677 MockWrite writes[] = { |
1674 CreateMockWrite(*req, 0), CreateMockWrite(*body, 1), // POST upload frame | 1678 CreateMockWrite(*req, 0), CreateMockWrite(*body, 1), // POST upload frame |
1675 }; | 1679 }; |
1676 | 1680 |
1677 std::unique_ptr<SpdySerializedFrame> resp( | 1681 std::unique_ptr<SpdySerializedFrame> resp( |
1678 spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); | 1682 spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); |
1679 MockRead reads[] = { | 1683 MockRead reads[] = { |
1680 CreateMockRead(*resp, 2), | 1684 CreateMockRead(*resp, 2), |
1681 CreateMockRead(*body, 3), | 1685 CreateMockRead(*body, 3), |
1682 MockRead(ASYNC, 0, 4) // EOF | 1686 MockRead(ASYNC, 0, 4) // EOF |
1683 }; | 1687 }; |
1684 | 1688 |
1685 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 1689 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
1686 NormalSpdyTransactionHelper helper(CreatePostRequest(), DEFAULT_PRIORITY, | 1690 NormalSpdyTransactionHelper helper(CreatePostRequest(), DEFAULT_PRIORITY, |
1687 BoundNetLog(), GetParam(), NULL); | 1691 BoundNetLog(), GetParam(), NULL); |
1688 helper.RunToCompletion(&data); | 1692 helper.RunToCompletion(&data); |
1689 TransactionHelperResult out = helper.output(); | 1693 TransactionHelperResult out = helper.output(); |
1690 EXPECT_EQ(OK, out.rv); | 1694 EXPECT_THAT(out.rv, IsOk()); |
1691 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 1695 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
1692 EXPECT_EQ("hello!", out.response_data); | 1696 EXPECT_EQ("hello!", out.response_data); |
1693 } | 1697 } |
1694 | 1698 |
1695 // Test that a POST with a file works. | 1699 // Test that a POST with a file works. |
1696 TEST_P(SpdyNetworkTransactionTest, FilePost) { | 1700 TEST_P(SpdyNetworkTransactionTest, FilePost) { |
1697 std::unique_ptr<SpdySerializedFrame> req(spdy_util_.ConstructSpdyPost( | 1701 std::unique_ptr<SpdySerializedFrame> req(spdy_util_.ConstructSpdyPost( |
1698 kDefaultUrl, 1, kUploadDataSize, LOWEST, NULL, 0)); | 1702 kDefaultUrl, 1, kUploadDataSize, LOWEST, NULL, 0)); |
1699 std::unique_ptr<SpdySerializedFrame> body( | 1703 std::unique_ptr<SpdySerializedFrame> body( |
1700 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 1704 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
1701 MockWrite writes[] = { | 1705 MockWrite writes[] = { |
1702 CreateMockWrite(*req, 0), CreateMockWrite(*body, 1), // POST upload frame | 1706 CreateMockWrite(*req, 0), CreateMockWrite(*body, 1), // POST upload frame |
1703 }; | 1707 }; |
1704 | 1708 |
1705 std::unique_ptr<SpdySerializedFrame> resp( | 1709 std::unique_ptr<SpdySerializedFrame> resp( |
1706 spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); | 1710 spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); |
1707 MockRead reads[] = { | 1711 MockRead reads[] = { |
1708 CreateMockRead(*resp, 2), | 1712 CreateMockRead(*resp, 2), |
1709 CreateMockRead(*body, 3), | 1713 CreateMockRead(*body, 3), |
1710 MockRead(ASYNC, 0, 4) // EOF | 1714 MockRead(ASYNC, 0, 4) // EOF |
1711 }; | 1715 }; |
1712 | 1716 |
1713 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 1717 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
1714 NormalSpdyTransactionHelper helper(CreateFilePostRequest(), DEFAULT_PRIORITY, | 1718 NormalSpdyTransactionHelper helper(CreateFilePostRequest(), DEFAULT_PRIORITY, |
1715 BoundNetLog(), GetParam(), NULL); | 1719 BoundNetLog(), GetParam(), NULL); |
1716 helper.RunToCompletion(&data); | 1720 helper.RunToCompletion(&data); |
1717 TransactionHelperResult out = helper.output(); | 1721 TransactionHelperResult out = helper.output(); |
1718 EXPECT_EQ(OK, out.rv); | 1722 EXPECT_THAT(out.rv, IsOk()); |
1719 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 1723 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
1720 EXPECT_EQ("hello!", out.response_data); | 1724 EXPECT_EQ("hello!", out.response_data); |
1721 } | 1725 } |
1722 | 1726 |
1723 // Test that a POST with a unreadable file fails. | 1727 // Test that a POST with a unreadable file fails. |
1724 TEST_P(SpdyNetworkTransactionTest, UnreadableFilePost) { | 1728 TEST_P(SpdyNetworkTransactionTest, UnreadableFilePost) { |
1725 MockWrite writes[] = { | 1729 MockWrite writes[] = { |
1726 MockWrite(ASYNC, 0, 0) // EOF | 1730 MockWrite(ASYNC, 0, 0) // EOF |
1727 }; | 1731 }; |
1728 MockRead reads[] = { | 1732 MockRead reads[] = { |
1729 MockRead(ASYNC, 0, 1) // EOF | 1733 MockRead(ASYNC, 0, 1) // EOF |
1730 }; | 1734 }; |
1731 | 1735 |
1732 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 1736 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
1733 NormalSpdyTransactionHelper helper(CreateUnreadableFilePostRequest(), | 1737 NormalSpdyTransactionHelper helper(CreateUnreadableFilePostRequest(), |
1734 DEFAULT_PRIORITY, | 1738 DEFAULT_PRIORITY, |
1735 BoundNetLog(), GetParam(), NULL); | 1739 BoundNetLog(), GetParam(), NULL); |
1736 helper.RunPreTestSetup(); | 1740 helper.RunPreTestSetup(); |
1737 helper.AddData(&data); | 1741 helper.AddData(&data); |
1738 helper.RunDefaultTest(); | 1742 helper.RunDefaultTest(); |
1739 | 1743 |
1740 base::RunLoop().RunUntilIdle(); | 1744 base::RunLoop().RunUntilIdle(); |
1741 helper.VerifyDataNotConsumed(); | 1745 helper.VerifyDataNotConsumed(); |
1742 EXPECT_EQ(ERR_ACCESS_DENIED, helper.output().rv); | 1746 EXPECT_THAT(helper.output().rv, IsError(ERR_ACCESS_DENIED)); |
1743 } | 1747 } |
1744 | 1748 |
1745 // Test that a complex POST works. | 1749 // Test that a complex POST works. |
1746 TEST_P(SpdyNetworkTransactionTest, ComplexPost) { | 1750 TEST_P(SpdyNetworkTransactionTest, ComplexPost) { |
1747 std::unique_ptr<SpdySerializedFrame> req(spdy_util_.ConstructSpdyPost( | 1751 std::unique_ptr<SpdySerializedFrame> req(spdy_util_.ConstructSpdyPost( |
1748 kDefaultUrl, 1, kUploadDataSize, LOWEST, NULL, 0)); | 1752 kDefaultUrl, 1, kUploadDataSize, LOWEST, NULL, 0)); |
1749 std::unique_ptr<SpdySerializedFrame> body( | 1753 std::unique_ptr<SpdySerializedFrame> body( |
1750 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 1754 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
1751 MockWrite writes[] = { | 1755 MockWrite writes[] = { |
1752 CreateMockWrite(*req, 0), CreateMockWrite(*body, 1), // POST upload frame | 1756 CreateMockWrite(*req, 0), CreateMockWrite(*body, 1), // POST upload frame |
1753 }; | 1757 }; |
1754 | 1758 |
1755 std::unique_ptr<SpdySerializedFrame> resp( | 1759 std::unique_ptr<SpdySerializedFrame> resp( |
1756 spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); | 1760 spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); |
1757 MockRead reads[] = { | 1761 MockRead reads[] = { |
1758 CreateMockRead(*resp, 2), | 1762 CreateMockRead(*resp, 2), |
1759 CreateMockRead(*body, 3), | 1763 CreateMockRead(*body, 3), |
1760 MockRead(ASYNC, 0, 4) // EOF | 1764 MockRead(ASYNC, 0, 4) // EOF |
1761 }; | 1765 }; |
1762 | 1766 |
1763 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 1767 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
1764 NormalSpdyTransactionHelper helper(CreateComplexPostRequest(), | 1768 NormalSpdyTransactionHelper helper(CreateComplexPostRequest(), |
1765 DEFAULT_PRIORITY, | 1769 DEFAULT_PRIORITY, |
1766 BoundNetLog(), GetParam(), NULL); | 1770 BoundNetLog(), GetParam(), NULL); |
1767 helper.RunToCompletion(&data); | 1771 helper.RunToCompletion(&data); |
1768 TransactionHelperResult out = helper.output(); | 1772 TransactionHelperResult out = helper.output(); |
1769 EXPECT_EQ(OK, out.rv); | 1773 EXPECT_THAT(out.rv, IsOk()); |
1770 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 1774 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
1771 EXPECT_EQ("hello!", out.response_data); | 1775 EXPECT_EQ("hello!", out.response_data); |
1772 } | 1776 } |
1773 | 1777 |
1774 // Test that a chunked POST works. | 1778 // Test that a chunked POST works. |
1775 TEST_P(SpdyNetworkTransactionTest, ChunkedPost) { | 1779 TEST_P(SpdyNetworkTransactionTest, ChunkedPost) { |
1776 std::unique_ptr<SpdySerializedFrame> req( | 1780 std::unique_ptr<SpdySerializedFrame> req( |
1777 spdy_util_.ConstructChunkedSpdyPost(NULL, 0)); | 1781 spdy_util_.ConstructChunkedSpdyPost(NULL, 0)); |
1778 std::unique_ptr<SpdySerializedFrame> body( | 1782 std::unique_ptr<SpdySerializedFrame> body( |
1779 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 1783 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
(...skipping 15 matching lines...) Expand all Loading... |
1795 BoundNetLog(), GetParam(), NULL); | 1799 BoundNetLog(), GetParam(), NULL); |
1796 | 1800 |
1797 // These chunks get merged into a single frame when being sent. | 1801 // These chunks get merged into a single frame when being sent. |
1798 const int kFirstChunkSize = kUploadDataSize/2; | 1802 const int kFirstChunkSize = kUploadDataSize/2; |
1799 upload_chunked_data_stream()->AppendData(kUploadData, kFirstChunkSize, false); | 1803 upload_chunked_data_stream()->AppendData(kUploadData, kFirstChunkSize, false); |
1800 upload_chunked_data_stream()->AppendData( | 1804 upload_chunked_data_stream()->AppendData( |
1801 kUploadData + kFirstChunkSize, kUploadDataSize - kFirstChunkSize, true); | 1805 kUploadData + kFirstChunkSize, kUploadDataSize - kFirstChunkSize, true); |
1802 | 1806 |
1803 helper.RunToCompletion(&data); | 1807 helper.RunToCompletion(&data); |
1804 TransactionHelperResult out = helper.output(); | 1808 TransactionHelperResult out = helper.output(); |
1805 EXPECT_EQ(OK, out.rv); | 1809 EXPECT_THAT(out.rv, IsOk()); |
1806 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 1810 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
1807 EXPECT_EQ(kUploadData, out.response_data); | 1811 EXPECT_EQ(kUploadData, out.response_data); |
1808 } | 1812 } |
1809 | 1813 |
1810 // Test that a chunked POST works with chunks appended after transaction starts. | 1814 // Test that a chunked POST works with chunks appended after transaction starts. |
1811 TEST_P(SpdyNetworkTransactionTest, DelayedChunkedPost) { | 1815 TEST_P(SpdyNetworkTransactionTest, DelayedChunkedPost) { |
1812 std::unique_ptr<SpdySerializedFrame> req( | 1816 std::unique_ptr<SpdySerializedFrame> req( |
1813 spdy_util_.ConstructChunkedSpdyPost(NULL, 0)); | 1817 spdy_util_.ConstructChunkedSpdyPost(NULL, 0)); |
1814 std::unique_ptr<SpdySerializedFrame> chunk1( | 1818 std::unique_ptr<SpdySerializedFrame> chunk1( |
1815 spdy_util_.ConstructSpdyBodyFrame(1, false)); | 1819 spdy_util_.ConstructSpdyBodyFrame(1, false)); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1852 | 1856 |
1853 helper.FinishDefaultTest(); | 1857 helper.FinishDefaultTest(); |
1854 helper.VerifyDataConsumed(); | 1858 helper.VerifyDataConsumed(); |
1855 | 1859 |
1856 std::string expected_response; | 1860 std::string expected_response; |
1857 expected_response += kUploadData; | 1861 expected_response += kUploadData; |
1858 expected_response += kUploadData; | 1862 expected_response += kUploadData; |
1859 expected_response += kUploadData; | 1863 expected_response += kUploadData; |
1860 | 1864 |
1861 TransactionHelperResult out = helper.output(); | 1865 TransactionHelperResult out = helper.output(); |
1862 EXPECT_EQ(OK, out.rv); | 1866 EXPECT_THAT(out.rv, IsOk()); |
1863 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 1867 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
1864 EXPECT_EQ(expected_response, out.response_data); | 1868 EXPECT_EQ(expected_response, out.response_data); |
1865 } | 1869 } |
1866 | 1870 |
1867 // Test that a POST without any post data works. | 1871 // Test that a POST without any post data works. |
1868 TEST_P(SpdyNetworkTransactionTest, NullPost) { | 1872 TEST_P(SpdyNetworkTransactionTest, NullPost) { |
1869 BufferedSpdyFramer framer(spdy_util_.spdy_version()); | 1873 BufferedSpdyFramer framer(spdy_util_.spdy_version()); |
1870 // Setup the request | 1874 // Setup the request |
1871 HttpRequestInfo request; | 1875 HttpRequestInfo request; |
1872 request.method = "POST"; | 1876 request.method = "POST"; |
(...skipping 21 matching lines...) Expand all Loading... |
1894 CreateMockRead(*body, 2), | 1898 CreateMockRead(*body, 2), |
1895 MockRead(ASYNC, 0, 3) // EOF | 1899 MockRead(ASYNC, 0, 3) // EOF |
1896 }; | 1900 }; |
1897 | 1901 |
1898 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 1902 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
1899 | 1903 |
1900 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, | 1904 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, |
1901 BoundNetLog(), GetParam(), NULL); | 1905 BoundNetLog(), GetParam(), NULL); |
1902 helper.RunToCompletion(&data); | 1906 helper.RunToCompletion(&data); |
1903 TransactionHelperResult out = helper.output(); | 1907 TransactionHelperResult out = helper.output(); |
1904 EXPECT_EQ(OK, out.rv); | 1908 EXPECT_THAT(out.rv, IsOk()); |
1905 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 1909 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
1906 EXPECT_EQ("hello!", out.response_data); | 1910 EXPECT_EQ("hello!", out.response_data); |
1907 } | 1911 } |
1908 | 1912 |
1909 // Test that a simple POST works. | 1913 // Test that a simple POST works. |
1910 TEST_P(SpdyNetworkTransactionTest, EmptyPost) { | 1914 TEST_P(SpdyNetworkTransactionTest, EmptyPost) { |
1911 BufferedSpdyFramer framer(spdy_util_.spdy_version()); | 1915 BufferedSpdyFramer framer(spdy_util_.spdy_version()); |
1912 // Create an empty UploadDataStream. | 1916 // Create an empty UploadDataStream. |
1913 std::vector<std::unique_ptr<UploadElementReader>> element_readers; | 1917 std::vector<std::unique_ptr<UploadElementReader>> element_readers; |
1914 ElementsUploadDataStream stream(std::move(element_readers), 0); | 1918 ElementsUploadDataStream stream(std::move(element_readers), 0); |
(...skipping 24 matching lines...) Expand all Loading... |
1939 CreateMockRead(*body, 2), | 1943 CreateMockRead(*body, 2), |
1940 MockRead(ASYNC, 0, 3) // EOF | 1944 MockRead(ASYNC, 0, 3) // EOF |
1941 }; | 1945 }; |
1942 | 1946 |
1943 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 1947 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
1944 | 1948 |
1945 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, | 1949 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, |
1946 BoundNetLog(), GetParam(), NULL); | 1950 BoundNetLog(), GetParam(), NULL); |
1947 helper.RunToCompletion(&data); | 1951 helper.RunToCompletion(&data); |
1948 TransactionHelperResult out = helper.output(); | 1952 TransactionHelperResult out = helper.output(); |
1949 EXPECT_EQ(OK, out.rv); | 1953 EXPECT_THAT(out.rv, IsOk()); |
1950 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 1954 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
1951 EXPECT_EQ("hello!", out.response_data); | 1955 EXPECT_EQ("hello!", out.response_data); |
1952 } | 1956 } |
1953 | 1957 |
1954 // While we're doing a post, the server sends the reply before upload completes. | 1958 // While we're doing a post, the server sends the reply before upload completes. |
1955 TEST_P(SpdyNetworkTransactionTest, ResponseBeforePostCompletes) { | 1959 TEST_P(SpdyNetworkTransactionTest, ResponseBeforePostCompletes) { |
1956 std::unique_ptr<SpdySerializedFrame> req( | 1960 std::unique_ptr<SpdySerializedFrame> req( |
1957 spdy_util_.ConstructChunkedSpdyPost(NULL, 0)); | 1961 spdy_util_.ConstructChunkedSpdyPost(NULL, 0)); |
1958 std::unique_ptr<SpdySerializedFrame> body( | 1962 std::unique_ptr<SpdySerializedFrame> body( |
1959 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 1963 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
(...skipping 23 matching lines...) Expand all Loading... |
1983 base::RunLoop().RunUntilIdle(); | 1987 base::RunLoop().RunUntilIdle(); |
1984 | 1988 |
1985 // Process the request headers, SYN_REPLY, and response body. | 1989 // Process the request headers, SYN_REPLY, and response body. |
1986 // The request body is still in flight. | 1990 // The request body is still in flight. |
1987 const HttpResponseInfo* response = helper.trans()->GetResponseInfo(); | 1991 const HttpResponseInfo* response = helper.trans()->GetResponseInfo(); |
1988 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 1992 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
1989 | 1993 |
1990 // Finish sending the request body. | 1994 // Finish sending the request body. |
1991 upload_chunked_data_stream()->AppendData(kUploadData, kUploadDataSize, true); | 1995 upload_chunked_data_stream()->AppendData(kUploadData, kUploadDataSize, true); |
1992 helper.WaitForCallbackToComplete(); | 1996 helper.WaitForCallbackToComplete(); |
1993 EXPECT_EQ(OK, helper.output().rv); | 1997 EXPECT_THAT(helper.output().rv, IsOk()); |
1994 | 1998 |
1995 std::string response_body; | 1999 std::string response_body; |
1996 EXPECT_EQ(OK, ReadTransaction(helper.trans(), &response_body)); | 2000 EXPECT_THAT(ReadTransaction(helper.trans(), &response_body), IsOk()); |
1997 EXPECT_EQ(kUploadData, response_body); | 2001 EXPECT_EQ(kUploadData, response_body); |
1998 helper.VerifyDataConsumed(); | 2002 helper.VerifyDataConsumed(); |
1999 } | 2003 } |
2000 | 2004 |
2001 // The client upon cancellation tries to send a RST_STREAM frame. The mock | 2005 // The client upon cancellation tries to send a RST_STREAM frame. The mock |
2002 // socket causes the TCP write to return zero. This test checks that the client | 2006 // socket causes the TCP write to return zero. This test checks that the client |
2003 // tries to queue up the RST_STREAM frame again. | 2007 // tries to queue up the RST_STREAM frame again. |
2004 TEST_P(SpdyNetworkTransactionTest, SocketWriteReturnsZero) { | 2008 TEST_P(SpdyNetworkTransactionTest, SocketWriteReturnsZero) { |
2005 std::unique_ptr<SpdySerializedFrame> req( | 2009 std::unique_ptr<SpdySerializedFrame> req( |
2006 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 2010 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
(...skipping 15 matching lines...) Expand all Loading... |
2022 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 2026 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
2023 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 2027 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
2024 BoundNetLog(), GetParam(), NULL); | 2028 BoundNetLog(), GetParam(), NULL); |
2025 helper.RunPreTestSetup(); | 2029 helper.RunPreTestSetup(); |
2026 helper.AddData(&data); | 2030 helper.AddData(&data); |
2027 HttpNetworkTransaction* trans = helper.trans(); | 2031 HttpNetworkTransaction* trans = helper.trans(); |
2028 | 2032 |
2029 TestCompletionCallback callback; | 2033 TestCompletionCallback callback; |
2030 int rv = trans->Start( | 2034 int rv = trans->Start( |
2031 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 2035 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
2032 EXPECT_EQ(OK, callback.GetResult(rv)); | 2036 EXPECT_THAT(callback.GetResult(rv), IsOk()); |
2033 | 2037 |
2034 helper.ResetTrans(); | 2038 helper.ResetTrans(); |
2035 base::RunLoop().RunUntilIdle(); | 2039 base::RunLoop().RunUntilIdle(); |
2036 | 2040 |
2037 helper.VerifyDataConsumed(); | 2041 helper.VerifyDataConsumed(); |
2038 } | 2042 } |
2039 | 2043 |
2040 // Test that the transaction doesn't crash when we don't have a reply. | 2044 // Test that the transaction doesn't crash when we don't have a reply. |
2041 TEST_P(SpdyNetworkTransactionTest, ResponseWithoutSynReply) { | 2045 TEST_P(SpdyNetworkTransactionTest, ResponseWithoutSynReply) { |
2042 std::unique_ptr<SpdySerializedFrame> body( | 2046 std::unique_ptr<SpdySerializedFrame> body( |
2043 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 2047 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
2044 MockRead reads[] = { | 2048 MockRead reads[] = { |
2045 CreateMockRead(*body, 1), MockRead(ASYNC, 0, 3) // EOF | 2049 CreateMockRead(*body, 1), MockRead(ASYNC, 0, 3) // EOF |
2046 }; | 2050 }; |
2047 | 2051 |
2048 std::unique_ptr<SpdySerializedFrame> req( | 2052 std::unique_ptr<SpdySerializedFrame> req( |
2049 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 2053 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
2050 std::unique_ptr<SpdySerializedFrame> rst( | 2054 std::unique_ptr<SpdySerializedFrame> rst( |
2051 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); | 2055 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); |
2052 MockWrite writes[] = { | 2056 MockWrite writes[] = { |
2053 CreateMockWrite(*req, 0), CreateMockWrite(*rst, 2), | 2057 CreateMockWrite(*req, 0), CreateMockWrite(*rst, 2), |
2054 }; | 2058 }; |
2055 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 2059 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
2056 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 2060 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
2057 BoundNetLog(), GetParam(), NULL); | 2061 BoundNetLog(), GetParam(), NULL); |
2058 helper.RunToCompletion(&data); | 2062 helper.RunToCompletion(&data); |
2059 TransactionHelperResult out = helper.output(); | 2063 TransactionHelperResult out = helper.output(); |
2060 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); | 2064 EXPECT_THAT(out.rv, IsError(ERR_SPDY_PROTOCOL_ERROR)); |
2061 } | 2065 } |
2062 | 2066 |
2063 // Test that the transaction doesn't crash when we get two replies on the same | 2067 // Test that the transaction doesn't crash when we get two replies on the same |
2064 // stream ID. See http://crbug.com/45639. | 2068 // stream ID. See http://crbug.com/45639. |
2065 TEST_P(SpdyNetworkTransactionTest, ResponseWithTwoSynReplies) { | 2069 TEST_P(SpdyNetworkTransactionTest, ResponseWithTwoSynReplies) { |
2066 std::unique_ptr<SpdySerializedFrame> req( | 2070 std::unique_ptr<SpdySerializedFrame> req( |
2067 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 2071 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
2068 std::unique_ptr<SpdySerializedFrame> rst( | 2072 std::unique_ptr<SpdySerializedFrame> rst( |
2069 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); | 2073 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); |
2070 MockWrite writes[] = { | 2074 MockWrite writes[] = { |
(...skipping 15 matching lines...) Expand all Loading... |
2086 | 2090 |
2087 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 2091 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
2088 BoundNetLog(), GetParam(), NULL); | 2092 BoundNetLog(), GetParam(), NULL); |
2089 helper.RunPreTestSetup(); | 2093 helper.RunPreTestSetup(); |
2090 helper.AddData(&data); | 2094 helper.AddData(&data); |
2091 | 2095 |
2092 HttpNetworkTransaction* trans = helper.trans(); | 2096 HttpNetworkTransaction* trans = helper.trans(); |
2093 | 2097 |
2094 TestCompletionCallback callback; | 2098 TestCompletionCallback callback; |
2095 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); | 2099 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); |
2096 EXPECT_EQ(ERR_IO_PENDING, rv); | 2100 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
2097 rv = callback.WaitForResult(); | 2101 rv = callback.WaitForResult(); |
2098 EXPECT_EQ(OK, rv); | 2102 EXPECT_THAT(rv, IsOk()); |
2099 | 2103 |
2100 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2104 const HttpResponseInfo* response = trans->GetResponseInfo(); |
2101 ASSERT_TRUE(response); | 2105 ASSERT_TRUE(response); |
2102 EXPECT_TRUE(response->headers); | 2106 EXPECT_TRUE(response->headers); |
2103 EXPECT_TRUE(response->was_fetched_via_spdy); | 2107 EXPECT_TRUE(response->was_fetched_via_spdy); |
2104 std::string response_data; | 2108 std::string response_data; |
2105 rv = ReadTransaction(trans, &response_data); | 2109 rv = ReadTransaction(trans, &response_data); |
2106 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, rv); | 2110 EXPECT_THAT(rv, IsError(ERR_SPDY_PROTOCOL_ERROR)); |
2107 | 2111 |
2108 helper.VerifyDataConsumed(); | 2112 helper.VerifyDataConsumed(); |
2109 } | 2113 } |
2110 | 2114 |
2111 TEST_P(SpdyNetworkTransactionTest, ResetReplyWithTransferEncoding) { | 2115 TEST_P(SpdyNetworkTransactionTest, ResetReplyWithTransferEncoding) { |
2112 // Construct the request. | 2116 // Construct the request. |
2113 std::unique_ptr<SpdySerializedFrame> req( | 2117 std::unique_ptr<SpdySerializedFrame> req( |
2114 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 2118 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
2115 std::unique_ptr<SpdySerializedFrame> rst( | 2119 std::unique_ptr<SpdySerializedFrame> rst( |
2116 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); | 2120 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); |
(...skipping 12 matching lines...) Expand all Loading... |
2129 CreateMockRead(*resp, 1), | 2133 CreateMockRead(*resp, 1), |
2130 CreateMockRead(*body, 3), | 2134 CreateMockRead(*body, 3), |
2131 MockRead(ASYNC, 0, 4) // EOF | 2135 MockRead(ASYNC, 0, 4) // EOF |
2132 }; | 2136 }; |
2133 | 2137 |
2134 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 2138 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
2135 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 2139 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
2136 BoundNetLog(), GetParam(), NULL); | 2140 BoundNetLog(), GetParam(), NULL); |
2137 helper.RunToCompletion(&data); | 2141 helper.RunToCompletion(&data); |
2138 TransactionHelperResult out = helper.output(); | 2142 TransactionHelperResult out = helper.output(); |
2139 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); | 2143 EXPECT_THAT(out.rv, IsError(ERR_SPDY_PROTOCOL_ERROR)); |
2140 | 2144 |
2141 helper.session()->spdy_session_pool()->CloseAllSessions(); | 2145 helper.session()->spdy_session_pool()->CloseAllSessions(); |
2142 helper.VerifyDataConsumed(); | 2146 helper.VerifyDataConsumed(); |
2143 } | 2147 } |
2144 | 2148 |
2145 TEST_P(SpdyNetworkTransactionTest, ResetPushWithTransferEncoding) { | 2149 TEST_P(SpdyNetworkTransactionTest, ResetPushWithTransferEncoding) { |
2146 // Construct the request. | 2150 // Construct the request. |
2147 std::unique_ptr<SpdySerializedFrame> req( | 2151 std::unique_ptr<SpdySerializedFrame> req( |
2148 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 2152 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
2149 std::unique_ptr<SpdySerializedFrame> rst( | 2153 std::unique_ptr<SpdySerializedFrame> rst( |
(...skipping 17 matching lines...) Expand all Loading... |
2167 CreateMockRead(*push, 2), | 2171 CreateMockRead(*push, 2), |
2168 CreateMockRead(*body, 3), | 2172 CreateMockRead(*body, 3), |
2169 MockRead(ASYNC, 0, 5) // EOF | 2173 MockRead(ASYNC, 0, 5) // EOF |
2170 }; | 2174 }; |
2171 | 2175 |
2172 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 2176 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
2173 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 2177 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
2174 BoundNetLog(), GetParam(), NULL); | 2178 BoundNetLog(), GetParam(), NULL); |
2175 helper.RunToCompletion(&data); | 2179 helper.RunToCompletion(&data); |
2176 TransactionHelperResult out = helper.output(); | 2180 TransactionHelperResult out = helper.output(); |
2177 EXPECT_EQ(OK, out.rv); | 2181 EXPECT_THAT(out.rv, IsOk()); |
2178 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 2182 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
2179 EXPECT_EQ("hello!", out.response_data); | 2183 EXPECT_EQ("hello!", out.response_data); |
2180 | 2184 |
2181 helper.session()->spdy_session_pool()->CloseAllSessions(); | 2185 helper.session()->spdy_session_pool()->CloseAllSessions(); |
2182 helper.VerifyDataConsumed(); | 2186 helper.VerifyDataConsumed(); |
2183 } | 2187 } |
2184 | 2188 |
2185 TEST_P(SpdyNetworkTransactionTest, CancelledTransaction) { | 2189 TEST_P(SpdyNetworkTransactionTest, CancelledTransaction) { |
2186 // Construct the request. | 2190 // Construct the request. |
2187 std::unique_ptr<SpdySerializedFrame> req( | 2191 std::unique_ptr<SpdySerializedFrame> req( |
(...skipping 18 matching lines...) Expand all Loading... |
2206 | 2210 |
2207 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 2211 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
2208 BoundNetLog(), GetParam(), NULL); | 2212 BoundNetLog(), GetParam(), NULL); |
2209 helper.RunPreTestSetup(); | 2213 helper.RunPreTestSetup(); |
2210 helper.AddData(&data); | 2214 helper.AddData(&data); |
2211 HttpNetworkTransaction* trans = helper.trans(); | 2215 HttpNetworkTransaction* trans = helper.trans(); |
2212 | 2216 |
2213 TestCompletionCallback callback; | 2217 TestCompletionCallback callback; |
2214 int rv = trans->Start( | 2218 int rv = trans->Start( |
2215 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 2219 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
2216 EXPECT_EQ(ERR_IO_PENDING, rv); | 2220 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
2217 helper.ResetTrans(); // Cancel the transaction. | 2221 helper.ResetTrans(); // Cancel the transaction. |
2218 | 2222 |
2219 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the | 2223 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the |
2220 // MockClientSocketFactory) are still alive. | 2224 // MockClientSocketFactory) are still alive. |
2221 base::RunLoop().RunUntilIdle(); | 2225 base::RunLoop().RunUntilIdle(); |
2222 helper.VerifyDataNotConsumed(); | 2226 helper.VerifyDataNotConsumed(); |
2223 } | 2227 } |
2224 | 2228 |
2225 // Verify that the client sends a Rst Frame upon cancelling the stream. | 2229 // Verify that the client sends a Rst Frame upon cancelling the stream. |
2226 TEST_P(SpdyNetworkTransactionTest, CancelledTransactionSendRst) { | 2230 TEST_P(SpdyNetworkTransactionTest, CancelledTransactionSendRst) { |
(...skipping 19 matching lines...) Expand all Loading... |
2246 BoundNetLog(), | 2250 BoundNetLog(), |
2247 GetParam(), NULL); | 2251 GetParam(), NULL); |
2248 helper.RunPreTestSetup(); | 2252 helper.RunPreTestSetup(); |
2249 helper.AddData(&data); | 2253 helper.AddData(&data); |
2250 HttpNetworkTransaction* trans = helper.trans(); | 2254 HttpNetworkTransaction* trans = helper.trans(); |
2251 | 2255 |
2252 TestCompletionCallback callback; | 2256 TestCompletionCallback callback; |
2253 | 2257 |
2254 int rv = trans->Start( | 2258 int rv = trans->Start( |
2255 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 2259 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
2256 EXPECT_EQ(OK, callback.GetResult(rv)); | 2260 EXPECT_THAT(callback.GetResult(rv), IsOk()); |
2257 | 2261 |
2258 helper.ResetTrans(); | 2262 helper.ResetTrans(); |
2259 base::RunLoop().RunUntilIdle(); | 2263 base::RunLoop().RunUntilIdle(); |
2260 | 2264 |
2261 helper.VerifyDataConsumed(); | 2265 helper.VerifyDataConsumed(); |
2262 } | 2266 } |
2263 | 2267 |
2264 // Verify that the client can correctly deal with the user callback attempting | 2268 // Verify that the client can correctly deal with the user callback attempting |
2265 // to start another transaction on a session that is closing down. See | 2269 // to start another transaction on a session that is closing down. See |
2266 // http://crbug.com/47455 | 2270 // http://crbug.com/47455 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2299 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 2303 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
2300 BoundNetLog(), GetParam(), NULL); | 2304 BoundNetLog(), GetParam(), NULL); |
2301 helper.RunPreTestSetup(); | 2305 helper.RunPreTestSetup(); |
2302 helper.AddData(&data); | 2306 helper.AddData(&data); |
2303 helper.AddData(&data2); | 2307 helper.AddData(&data2); |
2304 HttpNetworkTransaction* trans = helper.trans(); | 2308 HttpNetworkTransaction* trans = helper.trans(); |
2305 | 2309 |
2306 // Start the transaction with basic parameters. | 2310 // Start the transaction with basic parameters. |
2307 TestCompletionCallback callback; | 2311 TestCompletionCallback callback; |
2308 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); | 2312 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); |
2309 EXPECT_EQ(ERR_IO_PENDING, rv); | 2313 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
2310 rv = callback.WaitForResult(); | 2314 rv = callback.WaitForResult(); |
2311 | 2315 |
2312 const int kSize = 3000; | 2316 const int kSize = 3000; |
2313 scoped_refptr<IOBuffer> buf(new IOBuffer(kSize)); | 2317 scoped_refptr<IOBuffer> buf(new IOBuffer(kSize)); |
2314 rv = trans->Read( | 2318 rv = trans->Read( |
2315 buf.get(), kSize, | 2319 buf.get(), kSize, |
2316 base::Bind(&SpdyNetworkTransactionTest::StartTransactionCallback, | 2320 base::Bind(&SpdyNetworkTransactionTest::StartTransactionCallback, |
2317 helper.session(), default_url_)); | 2321 helper.session(), default_url_)); |
2318 ASSERT_EQ(ERR_IO_PENDING, rv); | 2322 ASSERT_THAT(rv, IsError(ERR_IO_PENDING)); |
2319 // This forces an err_IO_pending, which sets the callback. | 2323 // This forces an err_IO_pending, which sets the callback. |
2320 data.Resume(); | 2324 data.Resume(); |
2321 data.RunUntilPaused(); | 2325 data.RunUntilPaused(); |
2322 | 2326 |
2323 // This finishes the read. | 2327 // This finishes the read. |
2324 data.Resume(); | 2328 data.Resume(); |
2325 base::RunLoop().RunUntilIdle(); | 2329 base::RunLoop().RunUntilIdle(); |
2326 helper.VerifyDataConsumed(); | 2330 helper.VerifyDataConsumed(); |
2327 } | 2331 } |
2328 | 2332 |
(...skipping 20 matching lines...) Expand all Loading... |
2349 | 2353 |
2350 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 2354 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
2351 BoundNetLog(), GetParam(), NULL); | 2355 BoundNetLog(), GetParam(), NULL); |
2352 helper.RunPreTestSetup(); | 2356 helper.RunPreTestSetup(); |
2353 helper.AddData(&data); | 2357 helper.AddData(&data); |
2354 HttpNetworkTransaction* trans = helper.trans(); | 2358 HttpNetworkTransaction* trans = helper.trans(); |
2355 | 2359 |
2356 // Start the transaction with basic parameters. | 2360 // Start the transaction with basic parameters. |
2357 TestCompletionCallback callback; | 2361 TestCompletionCallback callback; |
2358 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); | 2362 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); |
2359 EXPECT_EQ(ERR_IO_PENDING, rv); | 2363 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
2360 rv = callback.WaitForResult(); | 2364 rv = callback.WaitForResult(); |
2361 | 2365 |
2362 // Setup a user callback which will delete the session, and clear out the | 2366 // Setup a user callback which will delete the session, and clear out the |
2363 // memory holding the stream object. Note that the callback deletes trans. | 2367 // memory holding the stream object. Note that the callback deletes trans. |
2364 const int kSize = 3000; | 2368 const int kSize = 3000; |
2365 scoped_refptr<IOBuffer> buf(new IOBuffer(kSize)); | 2369 scoped_refptr<IOBuffer> buf(new IOBuffer(kSize)); |
2366 rv = trans->Read( | 2370 rv = trans->Read( |
2367 buf.get(), | 2371 buf.get(), |
2368 kSize, | 2372 kSize, |
2369 base::Bind(&SpdyNetworkTransactionTest::DeleteSessionCallback, | 2373 base::Bind(&SpdyNetworkTransactionTest::DeleteSessionCallback, |
2370 base::Unretained(&helper))); | 2374 base::Unretained(&helper))); |
2371 ASSERT_EQ(ERR_IO_PENDING, rv); | 2375 ASSERT_THAT(rv, IsError(ERR_IO_PENDING)); |
2372 data.Resume(); | 2376 data.Resume(); |
2373 | 2377 |
2374 // Finish running rest of tasks. | 2378 // Finish running rest of tasks. |
2375 base::RunLoop().RunUntilIdle(); | 2379 base::RunLoop().RunUntilIdle(); |
2376 helper.VerifyDataConsumed(); | 2380 helper.VerifyDataConsumed(); |
2377 } | 2381 } |
2378 | 2382 |
2379 // Send a spdy request to www.example.org that gets redirected to www.foo.com. | 2383 // Send a spdy request to www.example.org that gets redirected to www.foo.com. |
2380 TEST_P(SpdyNetworkTransactionTest, DISABLED_RedirectGetRequest) { | 2384 TEST_P(SpdyNetworkTransactionTest, DISABLED_RedirectGetRequest) { |
2381 SpdyHeaderBlock headers(spdy_util_.ConstructGetHeaderBlock(kDefaultUrl)); | 2385 SpdyHeaderBlock headers(spdy_util_.ConstructGetHeaderBlock(kDefaultUrl)); |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2704 | 2708 |
2705 helper.RunPreTestSetup(); | 2709 helper.RunPreTestSetup(); |
2706 helper.AddData(&data); | 2710 helper.AddData(&data); |
2707 | 2711 |
2708 HttpNetworkTransaction* trans = helper.trans(); | 2712 HttpNetworkTransaction* trans = helper.trans(); |
2709 | 2713 |
2710 // Start the transaction with basic parameters. | 2714 // Start the transaction with basic parameters. |
2711 TestCompletionCallback callback; | 2715 TestCompletionCallback callback; |
2712 int rv = trans->Start( | 2716 int rv = trans->Start( |
2713 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 2717 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
2714 EXPECT_EQ(ERR_IO_PENDING, rv); | 2718 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
2715 rv = callback.WaitForResult(); | 2719 rv = callback.WaitForResult(); |
2716 EXPECT_EQ(OK, rv); | 2720 EXPECT_THAT(rv, IsOk()); |
2717 | 2721 |
2718 // Verify that we consumed all test data. | 2722 // Verify that we consumed all test data. |
2719 EXPECT_TRUE(data.AllReadDataConsumed()); | 2723 EXPECT_TRUE(data.AllReadDataConsumed()); |
2720 EXPECT_TRUE(data.AllWriteDataConsumed()); | 2724 EXPECT_TRUE(data.AllWriteDataConsumed()); |
2721 | 2725 |
2722 // Verify the SYN_REPLY. | 2726 // Verify the SYN_REPLY. |
2723 HttpResponseInfo response = *trans->GetResponseInfo(); | 2727 HttpResponseInfo response = *trans->GetResponseInfo(); |
2724 EXPECT_TRUE(response.headers); | 2728 EXPECT_TRUE(response.headers); |
2725 EXPECT_EQ("HTTP/1.1 200", response.headers->GetStatusLine()); | 2729 EXPECT_EQ("HTTP/1.1 200", response.headers->GetStatusLine()); |
2726 } | 2730 } |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2910 | 2914 |
2911 helper.RunPreTestSetup(); | 2915 helper.RunPreTestSetup(); |
2912 helper.AddData(&data); | 2916 helper.AddData(&data); |
2913 | 2917 |
2914 HttpNetworkTransaction* trans = helper.trans(); | 2918 HttpNetworkTransaction* trans = helper.trans(); |
2915 | 2919 |
2916 // Start the transaction with basic parameters. | 2920 // Start the transaction with basic parameters. |
2917 TestCompletionCallback callback; | 2921 TestCompletionCallback callback; |
2918 int rv = trans->Start( | 2922 int rv = trans->Start( |
2919 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 2923 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
2920 EXPECT_EQ(ERR_IO_PENDING, rv); | 2924 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
2921 rv = callback.WaitForResult(); | 2925 rv = callback.WaitForResult(); |
2922 EXPECT_EQ(OK, rv); | 2926 EXPECT_THAT(rv, IsOk()); |
2923 | 2927 |
2924 // Verify that we consumed all test data. | 2928 // Verify that we consumed all test data. |
2925 EXPECT_TRUE(data.AllReadDataConsumed()); | 2929 EXPECT_TRUE(data.AllReadDataConsumed()); |
2926 EXPECT_TRUE(data.AllWriteDataConsumed()); | 2930 EXPECT_TRUE(data.AllWriteDataConsumed()); |
2927 | 2931 |
2928 // Verify the SYN_REPLY. | 2932 // Verify the SYN_REPLY. |
2929 HttpResponseInfo response = *trans->GetResponseInfo(); | 2933 HttpResponseInfo response = *trans->GetResponseInfo(); |
2930 EXPECT_TRUE(response.headers); | 2934 EXPECT_TRUE(response.headers); |
2931 EXPECT_EQ("HTTP/1.1 200", response.headers->GetStatusLine()); | 2935 EXPECT_EQ("HTTP/1.1 200", response.headers->GetStatusLine()); |
2932 } | 2936 } |
(...skipping 26 matching lines...) Expand all Loading... |
2959 | 2963 |
2960 helper.RunPreTestSetup(); | 2964 helper.RunPreTestSetup(); |
2961 helper.AddData(&data); | 2965 helper.AddData(&data); |
2962 | 2966 |
2963 HttpNetworkTransaction* trans = helper.trans(); | 2967 HttpNetworkTransaction* trans = helper.trans(); |
2964 | 2968 |
2965 // Start the transaction with basic parameters. | 2969 // Start the transaction with basic parameters. |
2966 TestCompletionCallback callback; | 2970 TestCompletionCallback callback; |
2967 int rv = trans->Start( | 2971 int rv = trans->Start( |
2968 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 2972 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
2969 EXPECT_EQ(ERR_IO_PENDING, rv); | 2973 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
2970 rv = callback.WaitForResult(); | 2974 rv = callback.WaitForResult(); |
2971 EXPECT_EQ(OK, rv); | 2975 EXPECT_THAT(rv, IsOk()); |
2972 | 2976 |
2973 // Verify that we consumed all test data. | 2977 // Verify that we consumed all test data. |
2974 EXPECT_TRUE(data.AllReadDataConsumed()); | 2978 EXPECT_TRUE(data.AllReadDataConsumed()); |
2975 EXPECT_TRUE(data.AllWriteDataConsumed()); | 2979 EXPECT_TRUE(data.AllWriteDataConsumed()); |
2976 | 2980 |
2977 // Verify the SYN_REPLY. | 2981 // Verify the SYN_REPLY. |
2978 HttpResponseInfo response = *trans->GetResponseInfo(); | 2982 HttpResponseInfo response = *trans->GetResponseInfo(); |
2979 EXPECT_TRUE(response.headers); | 2983 EXPECT_TRUE(response.headers); |
2980 EXPECT_EQ("HTTP/1.1 200", response.headers->GetStatusLine()); | 2984 EXPECT_EQ("HTTP/1.1 200", response.headers->GetStatusLine()); |
2981 } | 2985 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3013 | 3017 |
3014 helper.RunPreTestSetup(); | 3018 helper.RunPreTestSetup(); |
3015 helper.AddData(&data); | 3019 helper.AddData(&data); |
3016 | 3020 |
3017 HttpNetworkTransaction* trans = helper.trans(); | 3021 HttpNetworkTransaction* trans = helper.trans(); |
3018 | 3022 |
3019 // Start the transaction with basic parameters. | 3023 // Start the transaction with basic parameters. |
3020 TestCompletionCallback callback; | 3024 TestCompletionCallback callback; |
3021 int rv = trans->Start( | 3025 int rv = trans->Start( |
3022 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 3026 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
3023 EXPECT_EQ(ERR_IO_PENDING, rv); | 3027 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
3024 rv = callback.WaitForResult(); | 3028 rv = callback.WaitForResult(); |
3025 EXPECT_EQ(OK, rv); | 3029 EXPECT_THAT(rv, IsOk()); |
3026 | 3030 |
3027 // Verify that we consumed all test data. | 3031 // Verify that we consumed all test data. |
3028 EXPECT_TRUE(data.AllReadDataConsumed()); | 3032 EXPECT_TRUE(data.AllReadDataConsumed()); |
3029 EXPECT_TRUE(data.AllWriteDataConsumed()); | 3033 EXPECT_TRUE(data.AllWriteDataConsumed()); |
3030 | 3034 |
3031 // Verify the SYN_REPLY. | 3035 // Verify the SYN_REPLY. |
3032 HttpResponseInfo response = *trans->GetResponseInfo(); | 3036 HttpResponseInfo response = *trans->GetResponseInfo(); |
3033 EXPECT_TRUE(response.headers); | 3037 EXPECT_TRUE(response.headers); |
3034 EXPECT_EQ("HTTP/1.1 200", response.headers->GetStatusLine()); | 3038 EXPECT_EQ("HTTP/1.1 200", response.headers->GetStatusLine()); |
3035 } | 3039 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3087 BoundNetLog(), GetParam(), nullptr); | 3091 BoundNetLog(), GetParam(), nullptr); |
3088 helper.RunPreTestSetup(); | 3092 helper.RunPreTestSetup(); |
3089 helper.AddData(&data); | 3093 helper.AddData(&data); |
3090 | 3094 |
3091 HttpNetworkTransaction* trans = helper.trans(); | 3095 HttpNetworkTransaction* trans = helper.trans(); |
3092 | 3096 |
3093 TestCompletionCallback callback; | 3097 TestCompletionCallback callback; |
3094 int rv = | 3098 int rv = |
3095 trans->Start(&CreateGetRequest(), callback.callback(), BoundNetLog()); | 3099 trans->Start(&CreateGetRequest(), callback.callback(), BoundNetLog()); |
3096 rv = callback.GetResult(rv); | 3100 rv = callback.GetResult(rv); |
3097 EXPECT_EQ(OK, rv); | 3101 EXPECT_THAT(rv, IsOk()); |
3098 HttpResponseInfo response = *trans->GetResponseInfo(); | 3102 HttpResponseInfo response = *trans->GetResponseInfo(); |
3099 EXPECT_TRUE(response.headers); | 3103 EXPECT_TRUE(response.headers); |
3100 EXPECT_EQ("HTTP/1.1 200", response.headers->GetStatusLine()); | 3104 EXPECT_EQ("HTTP/1.1 200", response.headers->GetStatusLine()); |
3101 | 3105 |
3102 EXPECT_TRUE(data.AllReadDataConsumed()); | 3106 EXPECT_TRUE(data.AllReadDataConsumed()); |
3103 EXPECT_TRUE(data.AllWriteDataConsumed()); | 3107 EXPECT_TRUE(data.AllWriteDataConsumed()); |
3104 VerifyStreamsClosed(helper); | 3108 VerifyStreamsClosed(helper); |
3105 } | 3109 } |
3106 | 3110 |
3107 // PUSH_PROMISE on a server-initiated stream should trigger GOAWAY even if | 3111 // PUSH_PROMISE on a server-initiated stream should trigger GOAWAY even if |
(...skipping 30 matching lines...) Expand all Loading... |
3138 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3142 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
3139 BoundNetLog(), GetParam(), nullptr); | 3143 BoundNetLog(), GetParam(), nullptr); |
3140 helper.RunPreTestSetup(); | 3144 helper.RunPreTestSetup(); |
3141 helper.AddData(&data); | 3145 helper.AddData(&data); |
3142 | 3146 |
3143 HttpNetworkTransaction* trans1 = helper.trans(); | 3147 HttpNetworkTransaction* trans1 = helper.trans(); |
3144 TestCompletionCallback callback1; | 3148 TestCompletionCallback callback1; |
3145 int rv = | 3149 int rv = |
3146 trans1->Start(&CreateGetRequest(), callback1.callback(), BoundNetLog()); | 3150 trans1->Start(&CreateGetRequest(), callback1.callback(), BoundNetLog()); |
3147 rv = callback1.GetResult(rv); | 3151 rv = callback1.GetResult(rv); |
3148 EXPECT_EQ(OK, rv); | 3152 EXPECT_THAT(rv, IsOk()); |
3149 HttpResponseInfo response = *trans1->GetResponseInfo(); | 3153 HttpResponseInfo response = *trans1->GetResponseInfo(); |
3150 EXPECT_TRUE(response.headers); | 3154 EXPECT_TRUE(response.headers); |
3151 EXPECT_EQ("HTTP/1.1 200", response.headers->GetStatusLine()); | 3155 EXPECT_EQ("HTTP/1.1 200", response.headers->GetStatusLine()); |
3152 | 3156 |
3153 std::unique_ptr<HttpNetworkTransaction> trans2( | 3157 std::unique_ptr<HttpNetworkTransaction> trans2( |
3154 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 3158 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); |
3155 TestCompletionCallback callback2; | 3159 TestCompletionCallback callback2; |
3156 rv = trans2->Start(&CreateGetPushRequest(), callback2.callback(), | 3160 rv = trans2->Start(&CreateGetPushRequest(), callback2.callback(), |
3157 BoundNetLog()); | 3161 BoundNetLog()); |
3158 rv = callback2.GetResult(rv); | 3162 rv = callback2.GetResult(rv); |
3159 EXPECT_EQ(OK, rv); | 3163 EXPECT_THAT(rv, IsOk()); |
3160 response = *trans2->GetResponseInfo(); | 3164 response = *trans2->GetResponseInfo(); |
3161 EXPECT_TRUE(response.headers); | 3165 EXPECT_TRUE(response.headers); |
3162 EXPECT_EQ("HTTP/1.1 200", response.headers->GetStatusLine()); | 3166 EXPECT_EQ("HTTP/1.1 200", response.headers->GetStatusLine()); |
3163 std::string result; | 3167 std::string result; |
3164 ReadResult(trans2.get(), &result); | 3168 ReadResult(trans2.get(), &result); |
3165 EXPECT_EQ(kPushedData, result); | 3169 EXPECT_EQ(kPushedData, result); |
3166 | 3170 |
3167 data.Resume(); | 3171 data.Resume(); |
3168 base::RunLoop().RunUntilIdle(); | 3172 base::RunLoop().RunUntilIdle(); |
3169 | 3173 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3234 MockRead(ASYNC, 0, 3) // EOF | 3238 MockRead(ASYNC, 0, 3) // EOF |
3235 }; | 3239 }; |
3236 | 3240 |
3237 SequencedSocketData data(reads, arraysize(reads), writes, | 3241 SequencedSocketData data(reads, arraysize(reads), writes, |
3238 arraysize(writes)); | 3242 arraysize(writes)); |
3239 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3243 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
3240 BoundNetLog(), GetParam(), NULL); | 3244 BoundNetLog(), GetParam(), NULL); |
3241 helper.RunToCompletion(&data); | 3245 helper.RunToCompletion(&data); |
3242 TransactionHelperResult out = helper.output(); | 3246 TransactionHelperResult out = helper.output(); |
3243 | 3247 |
3244 EXPECT_EQ(OK, out.rv); | 3248 EXPECT_THAT(out.rv, IsOk()); |
3245 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 3249 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
3246 EXPECT_EQ("hello!", out.response_data); | 3250 EXPECT_EQ("hello!", out.response_data); |
3247 | 3251 |
3248 scoped_refptr<HttpResponseHeaders> headers = out.response_info.headers; | 3252 scoped_refptr<HttpResponseHeaders> headers = out.response_info.headers; |
3249 EXPECT_TRUE(headers); | 3253 EXPECT_TRUE(headers); |
3250 size_t iter = 0; | 3254 size_t iter = 0; |
3251 std::string name, value; | 3255 std::string name, value; |
3252 SpdyHeaderBlock header_block; | 3256 SpdyHeaderBlock header_block; |
3253 while (headers->EnumerateHeaderLines(&iter, &name, &value)) { | 3257 while (headers->EnumerateHeaderLines(&iter, &name, &value)) { |
3254 SpdyHeaderBlock::StringPieceProxy mutable_header_block_value = | 3258 SpdyHeaderBlock::StringPieceProxy mutable_header_block_value = |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3423 MockRead reads[] = { | 3427 MockRead reads[] = { |
3424 CreateMockRead(*resp, 1), MockRead(ASYNC, 0, 3) // EOF | 3428 CreateMockRead(*resp, 1), MockRead(ASYNC, 0, 3) // EOF |
3425 }; | 3429 }; |
3426 | 3430 |
3427 SequencedSocketData data(reads, arraysize(reads), writes, | 3431 SequencedSocketData data(reads, arraysize(reads), writes, |
3428 arraysize(writes)); | 3432 arraysize(writes)); |
3429 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3433 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
3430 BoundNetLog(), GetParam(), NULL); | 3434 BoundNetLog(), GetParam(), NULL); |
3431 helper.RunToCompletion(&data); | 3435 helper.RunToCompletion(&data); |
3432 TransactionHelperResult out = helper.output(); | 3436 TransactionHelperResult out = helper.output(); |
3433 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); | 3437 EXPECT_THAT(out.rv, IsError(ERR_SPDY_PROTOCOL_ERROR)); |
3434 } | 3438 } |
3435 } | 3439 } |
3436 | 3440 |
3437 TEST_P(SpdyNetworkTransactionTest, CorruptFrameSessionError) { | 3441 TEST_P(SpdyNetworkTransactionTest, CorruptFrameSessionError) { |
3438 if (spdy_util_.spdy_version() != SPDY3) { | 3442 if (spdy_util_.spdy_version() != SPDY3) { |
3439 return; | 3443 return; |
3440 } | 3444 } |
3441 | 3445 |
3442 std::unique_ptr<SpdySerializedFrame> req( | 3446 std::unique_ptr<SpdySerializedFrame> req( |
3443 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 3447 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
(...skipping 19 matching lines...) Expand all Loading... |
3463 MockRead(ASYNC, syn_reply_wrong_length->data(), | 3467 MockRead(ASYNC, syn_reply_wrong_length->data(), |
3464 syn_reply_wrong_length->size(), 1), | 3468 syn_reply_wrong_length->size(), 1), |
3465 CreateMockRead(*body, 2), | 3469 CreateMockRead(*body, 2), |
3466 }; | 3470 }; |
3467 | 3471 |
3468 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 3472 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
3469 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3473 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
3470 BoundNetLog(), GetParam(), nullptr); | 3474 BoundNetLog(), GetParam(), nullptr); |
3471 helper.RunToCompletion(&data); | 3475 helper.RunToCompletion(&data); |
3472 TransactionHelperResult out = helper.output(); | 3476 TransactionHelperResult out = helper.output(); |
3473 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); | 3477 EXPECT_THAT(out.rv, IsError(ERR_SPDY_PROTOCOL_ERROR)); |
3474 } | 3478 } |
3475 | 3479 |
3476 TEST_P(SpdyNetworkTransactionTest, CorruptFrameSessionErrorSpdy4) { | 3480 TEST_P(SpdyNetworkTransactionTest, CorruptFrameSessionErrorSpdy4) { |
3477 if (spdy_util_.spdy_version() != HTTP2) { | 3481 if (spdy_util_.spdy_version() != HTTP2) { |
3478 return; | 3482 return; |
3479 } | 3483 } |
3480 | 3484 |
3481 std::unique_ptr<SpdySerializedFrame> req( | 3485 std::unique_ptr<SpdySerializedFrame> req( |
3482 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 3486 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
3483 std::unique_ptr<SpdySerializedFrame> goaway(spdy_util_.ConstructSpdyGoAway( | 3487 std::unique_ptr<SpdySerializedFrame> goaway(spdy_util_.ConstructSpdyGoAway( |
(...skipping 14 matching lines...) Expand all Loading... |
3498 MockRead reads[] = { | 3502 MockRead reads[] = { |
3499 MockRead(ASYNC, syn_reply_wrong_length->data(), | 3503 MockRead(ASYNC, syn_reply_wrong_length->data(), |
3500 syn_reply_wrong_length->size() - 4, 1), | 3504 syn_reply_wrong_length->size() - 4, 1), |
3501 }; | 3505 }; |
3502 | 3506 |
3503 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 3507 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
3504 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3508 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
3505 BoundNetLog(), GetParam(), NULL); | 3509 BoundNetLog(), GetParam(), NULL); |
3506 helper.RunToCompletion(&data); | 3510 helper.RunToCompletion(&data); |
3507 TransactionHelperResult out = helper.output(); | 3511 TransactionHelperResult out = helper.output(); |
3508 EXPECT_EQ(ERR_SPDY_COMPRESSION_ERROR, out.rv); | 3512 EXPECT_THAT(out.rv, IsError(ERR_SPDY_COMPRESSION_ERROR)); |
3509 } | 3513 } |
3510 | 3514 |
3511 TEST_P(SpdyNetworkTransactionTest, GoAwayOnDecompressionFailure) { | 3515 TEST_P(SpdyNetworkTransactionTest, GoAwayOnDecompressionFailure) { |
3512 if (GetParam().protocol < kProtoHTTP2) { | 3516 if (GetParam().protocol < kProtoHTTP2) { |
3513 // Decompression failures are a stream error in SPDY3. | 3517 // Decompression failures are a stream error in SPDY3. |
3514 return; | 3518 return; |
3515 } | 3519 } |
3516 std::unique_ptr<SpdySerializedFrame> req( | 3520 std::unique_ptr<SpdySerializedFrame> req( |
3517 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 3521 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
3518 std::unique_ptr<SpdySerializedFrame> goaway(spdy_util_.ConstructSpdyGoAway( | 3522 std::unique_ptr<SpdySerializedFrame> goaway(spdy_util_.ConstructSpdyGoAway( |
3519 0, GOAWAY_COMPRESSION_ERROR, "Framer error: 6 (DECOMPRESS_FAILURE).")); | 3523 0, GOAWAY_COMPRESSION_ERROR, "Framer error: 6 (DECOMPRESS_FAILURE).")); |
3520 MockWrite writes[] = {CreateMockWrite(*req, 0), CreateMockWrite(*goaway, 2)}; | 3524 MockWrite writes[] = {CreateMockWrite(*req, 0), CreateMockWrite(*goaway, 2)}; |
3521 | 3525 |
3522 // Read HEADERS with corrupted payload. | 3526 // Read HEADERS with corrupted payload. |
3523 std::unique_ptr<SpdySerializedFrame> resp( | 3527 std::unique_ptr<SpdySerializedFrame> resp( |
3524 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 3528 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
3525 memset(resp->data() + 12, 0xcf, resp->size() - 12); | 3529 memset(resp->data() + 12, 0xcf, resp->size() - 12); |
3526 MockRead reads[] = {CreateMockRead(*resp, 1)}; | 3530 MockRead reads[] = {CreateMockRead(*resp, 1)}; |
3527 | 3531 |
3528 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 3532 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
3529 NormalSpdyTransactionHelper helper( | 3533 NormalSpdyTransactionHelper helper( |
3530 CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL); | 3534 CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL); |
3531 helper.RunToCompletion(&data); | 3535 helper.RunToCompletion(&data); |
3532 TransactionHelperResult out = helper.output(); | 3536 TransactionHelperResult out = helper.output(); |
3533 EXPECT_EQ(ERR_SPDY_COMPRESSION_ERROR, out.rv); | 3537 EXPECT_THAT(out.rv, IsError(ERR_SPDY_COMPRESSION_ERROR)); |
3534 } | 3538 } |
3535 | 3539 |
3536 TEST_P(SpdyNetworkTransactionTest, GoAwayOnFrameSizeError) { | 3540 TEST_P(SpdyNetworkTransactionTest, GoAwayOnFrameSizeError) { |
3537 std::unique_ptr<SpdySerializedFrame> req( | 3541 std::unique_ptr<SpdySerializedFrame> req( |
3538 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 3542 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
3539 std::unique_ptr<SpdySerializedFrame> goaway(spdy_util_.ConstructSpdyGoAway( | 3543 std::unique_ptr<SpdySerializedFrame> goaway(spdy_util_.ConstructSpdyGoAway( |
3540 0, GOAWAY_FRAME_SIZE_ERROR, | 3544 0, GOAWAY_FRAME_SIZE_ERROR, |
3541 "Framer error: 15 (INVALID_CONTROL_FRAME_SIZE).")); | 3545 "Framer error: 15 (INVALID_CONTROL_FRAME_SIZE).")); |
3542 MockWrite writes[] = {CreateMockWrite(*req, 0), CreateMockWrite(*goaway, 2)}; | 3546 MockWrite writes[] = {CreateMockWrite(*req, 0), CreateMockWrite(*goaway, 2)}; |
3543 | 3547 |
3544 // Read WINDOW_UPDATE with incorrectly-sized payload. | 3548 // Read WINDOW_UPDATE with incorrectly-sized payload. |
3545 std::unique_ptr<SpdySerializedFrame> bad_window_update( | 3549 std::unique_ptr<SpdySerializedFrame> bad_window_update( |
3546 spdy_util_.ConstructSpdyWindowUpdate(1, 1)); | 3550 spdy_util_.ConstructSpdyWindowUpdate(1, 1)); |
3547 test::SetFrameLength(bad_window_update.get(), | 3551 test::SetFrameLength(bad_window_update.get(), |
3548 bad_window_update->size() - 1, | 3552 bad_window_update->size() - 1, |
3549 spdy_util_.spdy_version()); | 3553 spdy_util_.spdy_version()); |
3550 MockRead reads[] = {CreateMockRead(*bad_window_update, 1)}; | 3554 MockRead reads[] = {CreateMockRead(*bad_window_update, 1)}; |
3551 | 3555 |
3552 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 3556 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
3553 NormalSpdyTransactionHelper helper( | 3557 NormalSpdyTransactionHelper helper( |
3554 CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL); | 3558 CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL); |
3555 helper.RunToCompletion(&data); | 3559 helper.RunToCompletion(&data); |
3556 TransactionHelperResult out = helper.output(); | 3560 TransactionHelperResult out = helper.output(); |
3557 EXPECT_EQ(ERR_SPDY_FRAME_SIZE_ERROR, out.rv); | 3561 EXPECT_THAT(out.rv, IsError(ERR_SPDY_FRAME_SIZE_ERROR)); |
3558 } | 3562 } |
3559 | 3563 |
3560 // Test that we shutdown correctly on write errors. | 3564 // Test that we shutdown correctly on write errors. |
3561 TEST_P(SpdyNetworkTransactionTest, WriteError) { | 3565 TEST_P(SpdyNetworkTransactionTest, WriteError) { |
3562 std::unique_ptr<SpdySerializedFrame> req( | 3566 std::unique_ptr<SpdySerializedFrame> req( |
3563 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 3567 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
3564 MockWrite writes[] = { | 3568 MockWrite writes[] = { |
3565 // We'll write 10 bytes successfully | 3569 // We'll write 10 bytes successfully |
3566 MockWrite(ASYNC, req->data(), 10, 1), | 3570 MockWrite(ASYNC, req->data(), 10, 1), |
3567 // Followed by ERROR! | 3571 // Followed by ERROR! |
3568 MockWrite(ASYNC, ERR_FAILED, 2), | 3572 MockWrite(ASYNC, ERR_FAILED, 2), |
3569 // Session drains and attempts to write a GOAWAY: Another ERROR! | 3573 // Session drains and attempts to write a GOAWAY: Another ERROR! |
3570 MockWrite(ASYNC, ERR_FAILED, 3), | 3574 MockWrite(ASYNC, ERR_FAILED, 3), |
3571 }; | 3575 }; |
3572 | 3576 |
3573 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; | 3577 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; |
3574 | 3578 |
3575 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 3579 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
3576 | 3580 |
3577 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3581 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
3578 BoundNetLog(), GetParam(), NULL); | 3582 BoundNetLog(), GetParam(), NULL); |
3579 helper.RunPreTestSetup(); | 3583 helper.RunPreTestSetup(); |
3580 helper.AddData(&data); | 3584 helper.AddData(&data); |
3581 EXPECT_TRUE(helper.StartDefaultTest()); | 3585 EXPECT_TRUE(helper.StartDefaultTest()); |
3582 helper.FinishDefaultTest(); | 3586 helper.FinishDefaultTest(); |
3583 EXPECT_TRUE(data.AllWriteDataConsumed()); | 3587 EXPECT_TRUE(data.AllWriteDataConsumed()); |
3584 EXPECT_TRUE(data.AllReadDataConsumed()); | 3588 EXPECT_TRUE(data.AllReadDataConsumed()); |
3585 TransactionHelperResult out = helper.output(); | 3589 TransactionHelperResult out = helper.output(); |
3586 EXPECT_EQ(ERR_FAILED, out.rv); | 3590 EXPECT_THAT(out.rv, IsError(ERR_FAILED)); |
3587 } | 3591 } |
3588 | 3592 |
3589 // Test that partial writes work. | 3593 // Test that partial writes work. |
3590 TEST_P(SpdyNetworkTransactionTest, PartialWrite) { | 3594 TEST_P(SpdyNetworkTransactionTest, PartialWrite) { |
3591 // Chop the SYN_STREAM frame into 5 chunks. | 3595 // Chop the SYN_STREAM frame into 5 chunks. |
3592 std::unique_ptr<SpdySerializedFrame> req( | 3596 std::unique_ptr<SpdySerializedFrame> req( |
3593 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 3597 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
3594 const int kChunks = 5; | 3598 const int kChunks = 5; |
3595 std::unique_ptr<MockWrite[]> writes(ChopWriteFrame(*req.get(), kChunks)); | 3599 std::unique_ptr<MockWrite[]> writes(ChopWriteFrame(*req.get(), kChunks)); |
3596 for (int i = 0; i < kChunks; ++i) { | 3600 for (int i = 0; i < kChunks; ++i) { |
3597 writes[i].sequence_number = i; | 3601 writes[i].sequence_number = i; |
3598 } | 3602 } |
3599 | 3603 |
3600 std::unique_ptr<SpdySerializedFrame> resp( | 3604 std::unique_ptr<SpdySerializedFrame> resp( |
3601 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 3605 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
3602 std::unique_ptr<SpdySerializedFrame> body( | 3606 std::unique_ptr<SpdySerializedFrame> body( |
3603 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 3607 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
3604 MockRead reads[] = { | 3608 MockRead reads[] = { |
3605 CreateMockRead(*resp, kChunks), | 3609 CreateMockRead(*resp, kChunks), |
3606 CreateMockRead(*body, kChunks + 1), | 3610 CreateMockRead(*body, kChunks + 1), |
3607 MockRead(ASYNC, 0, kChunks + 2) // EOF | 3611 MockRead(ASYNC, 0, kChunks + 2) // EOF |
3608 }; | 3612 }; |
3609 | 3613 |
3610 SequencedSocketData data(reads, arraysize(reads), writes.get(), kChunks); | 3614 SequencedSocketData data(reads, arraysize(reads), writes.get(), kChunks); |
3611 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3615 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
3612 BoundNetLog(), GetParam(), NULL); | 3616 BoundNetLog(), GetParam(), NULL); |
3613 helper.RunToCompletion(&data); | 3617 helper.RunToCompletion(&data); |
3614 TransactionHelperResult out = helper.output(); | 3618 TransactionHelperResult out = helper.output(); |
3615 EXPECT_EQ(OK, out.rv); | 3619 EXPECT_THAT(out.rv, IsOk()); |
3616 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 3620 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
3617 EXPECT_EQ("hello!", out.response_data); | 3621 EXPECT_EQ("hello!", out.response_data); |
3618 } | 3622 } |
3619 | 3623 |
3620 // Test that the NetLog contains good data for a simple GET request. | 3624 // Test that the NetLog contains good data for a simple GET request. |
3621 TEST_P(SpdyNetworkTransactionTest, NetLog) { | 3625 TEST_P(SpdyNetworkTransactionTest, NetLog) { |
3622 static const char* const kExtraHeaders[] = { | 3626 static const char* const kExtraHeaders[] = { |
3623 "user-agent", "Chrome", | 3627 "user-agent", "Chrome", |
3624 }; | 3628 }; |
3625 std::unique_ptr<SpdySerializedFrame> req( | 3629 std::unique_ptr<SpdySerializedFrame> req( |
(...skipping 11 matching lines...) Expand all Loading... |
3637 }; | 3641 }; |
3638 | 3642 |
3639 BoundTestNetLog log; | 3643 BoundTestNetLog log; |
3640 | 3644 |
3641 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 3645 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
3642 NormalSpdyTransactionHelper helper(CreateGetRequestWithUserAgent(), | 3646 NormalSpdyTransactionHelper helper(CreateGetRequestWithUserAgent(), |
3643 DEFAULT_PRIORITY, | 3647 DEFAULT_PRIORITY, |
3644 log.bound(), GetParam(), NULL); | 3648 log.bound(), GetParam(), NULL); |
3645 helper.RunToCompletion(&data); | 3649 helper.RunToCompletion(&data); |
3646 TransactionHelperResult out = helper.output(); | 3650 TransactionHelperResult out = helper.output(); |
3647 EXPECT_EQ(OK, out.rv); | 3651 EXPECT_THAT(out.rv, IsOk()); |
3648 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 3652 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
3649 EXPECT_EQ("hello!", out.response_data); | 3653 EXPECT_EQ("hello!", out.response_data); |
3650 | 3654 |
3651 // Check that the NetLog was filled reasonably. | 3655 // Check that the NetLog was filled reasonably. |
3652 // This test is intentionally non-specific about the exact ordering of the | 3656 // This test is intentionally non-specific about the exact ordering of the |
3653 // log; instead we just check to make sure that certain events exist, and that | 3657 // log; instead we just check to make sure that certain events exist, and that |
3654 // they are in the right order. | 3658 // they are in the right order. |
3655 TestNetLogEntry::List entries; | 3659 TestNetLogEntry::List entries; |
3656 log.GetEntries(&entries); | 3660 log.GetEntries(&entries); |
3657 | 3661 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3749 | 3753 |
3750 TestCompletionCallback callback; | 3754 TestCompletionCallback callback; |
3751 | 3755 |
3752 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3756 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
3753 BoundNetLog(), GetParam(), NULL); | 3757 BoundNetLog(), GetParam(), NULL); |
3754 helper.RunPreTestSetup(); | 3758 helper.RunPreTestSetup(); |
3755 helper.AddData(&data); | 3759 helper.AddData(&data); |
3756 HttpNetworkTransaction* trans = helper.trans(); | 3760 HttpNetworkTransaction* trans = helper.trans(); |
3757 int rv = trans->Start( | 3761 int rv = trans->Start( |
3758 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 3762 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
3759 EXPECT_EQ(ERR_IO_PENDING, rv); | 3763 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
3760 | 3764 |
3761 TransactionHelperResult out = helper.output(); | 3765 TransactionHelperResult out = helper.output(); |
3762 out.rv = callback.WaitForResult(); | 3766 out.rv = callback.WaitForResult(); |
3763 EXPECT_EQ(out.rv, OK); | 3767 EXPECT_EQ(out.rv, OK); |
3764 | 3768 |
3765 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3769 const HttpResponseInfo* response = trans->GetResponseInfo(); |
3766 EXPECT_TRUE(response->headers); | 3770 EXPECT_TRUE(response->headers); |
3767 EXPECT_TRUE(response->was_fetched_via_spdy); | 3771 EXPECT_TRUE(response->was_fetched_via_spdy); |
3768 out.status_line = response->headers->GetStatusLine(); | 3772 out.status_line = response->headers->GetStatusLine(); |
3769 out.response_info = *response; // Make a copy so we can verify. | 3773 out.response_info = *response; // Make a copy so we can verify. |
(...skipping 20 matching lines...) Expand all Loading... |
3790 | 3794 |
3791 out.response_data.swap(content); | 3795 out.response_data.swap(content); |
3792 | 3796 |
3793 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the | 3797 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the |
3794 // MockClientSocketFactory) are still alive. | 3798 // MockClientSocketFactory) are still alive. |
3795 base::RunLoop().RunUntilIdle(); | 3799 base::RunLoop().RunUntilIdle(); |
3796 | 3800 |
3797 // Verify that we consumed all test data. | 3801 // Verify that we consumed all test data. |
3798 helper.VerifyDataConsumed(); | 3802 helper.VerifyDataConsumed(); |
3799 | 3803 |
3800 EXPECT_EQ(OK, out.rv); | 3804 EXPECT_THAT(out.rv, IsOk()); |
3801 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 3805 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
3802 EXPECT_EQ("goodbye world", out.response_data); | 3806 EXPECT_EQ("goodbye world", out.response_data); |
3803 } | 3807 } |
3804 | 3808 |
3805 // Verify that basic buffering works; when multiple data frames arrive | 3809 // Verify that basic buffering works; when multiple data frames arrive |
3806 // at the same time, ensure that we don't notify a read completion for | 3810 // at the same time, ensure that we don't notify a read completion for |
3807 // each data frame individually. | 3811 // each data frame individually. |
3808 TEST_P(SpdyNetworkTransactionTest, Buffering) { | 3812 TEST_P(SpdyNetworkTransactionTest, Buffering) { |
3809 BufferedSpdyFramer framer(spdy_util_.spdy_version()); | 3813 BufferedSpdyFramer framer(spdy_util_.spdy_version()); |
3810 | 3814 |
(...skipping 27 matching lines...) Expand all Loading... |
3838 | 3842 |
3839 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3843 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
3840 BoundNetLog(), GetParam(), NULL); | 3844 BoundNetLog(), GetParam(), NULL); |
3841 helper.RunPreTestSetup(); | 3845 helper.RunPreTestSetup(); |
3842 helper.AddData(&data); | 3846 helper.AddData(&data); |
3843 HttpNetworkTransaction* trans = helper.trans(); | 3847 HttpNetworkTransaction* trans = helper.trans(); |
3844 | 3848 |
3845 TestCompletionCallback callback; | 3849 TestCompletionCallback callback; |
3846 int rv = trans->Start( | 3850 int rv = trans->Start( |
3847 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 3851 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
3848 EXPECT_EQ(ERR_IO_PENDING, rv); | 3852 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
3849 | 3853 |
3850 TransactionHelperResult out = helper.output(); | 3854 TransactionHelperResult out = helper.output(); |
3851 out.rv = callback.WaitForResult(); | 3855 out.rv = callback.WaitForResult(); |
3852 EXPECT_EQ(out.rv, OK); | 3856 EXPECT_EQ(out.rv, OK); |
3853 | 3857 |
3854 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3858 const HttpResponseInfo* response = trans->GetResponseInfo(); |
3855 EXPECT_TRUE(response->headers); | 3859 EXPECT_TRUE(response->headers); |
3856 EXPECT_TRUE(response->was_fetched_via_spdy); | 3860 EXPECT_TRUE(response->was_fetched_via_spdy); |
3857 out.status_line = response->headers->GetStatusLine(); | 3861 out.status_line = response->headers->GetStatusLine(); |
3858 out.response_info = *response; // Make a copy so we can verify. | 3862 out.response_info = *response; // Make a copy so we can verify. |
(...skipping 25 matching lines...) Expand all Loading... |
3884 | 3888 |
3885 out.response_data.swap(content); | 3889 out.response_data.swap(content); |
3886 | 3890 |
3887 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the | 3891 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the |
3888 // MockClientSocketFactory) are still alive. | 3892 // MockClientSocketFactory) are still alive. |
3889 base::RunLoop().RunUntilIdle(); | 3893 base::RunLoop().RunUntilIdle(); |
3890 | 3894 |
3891 // Verify that we consumed all test data. | 3895 // Verify that we consumed all test data. |
3892 helper.VerifyDataConsumed(); | 3896 helper.VerifyDataConsumed(); |
3893 | 3897 |
3894 EXPECT_EQ(OK, out.rv); | 3898 EXPECT_THAT(out.rv, IsOk()); |
3895 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 3899 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
3896 EXPECT_EQ("messagemessagemessagemessage", out.response_data); | 3900 EXPECT_EQ("messagemessagemessagemessage", out.response_data); |
3897 } | 3901 } |
3898 | 3902 |
3899 // Verify the case where we buffer data but read it after it has been buffered. | 3903 // Verify the case where we buffer data but read it after it has been buffered. |
3900 TEST_P(SpdyNetworkTransactionTest, BufferedAll) { | 3904 TEST_P(SpdyNetworkTransactionTest, BufferedAll) { |
3901 BufferedSpdyFramer framer(spdy_util_.spdy_version()); | 3905 BufferedSpdyFramer framer(spdy_util_.spdy_version()); |
3902 | 3906 |
3903 std::unique_ptr<SpdySerializedFrame> req( | 3907 std::unique_ptr<SpdySerializedFrame> req( |
3904 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 3908 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
(...skipping 23 matching lines...) Expand all Loading... |
3928 | 3932 |
3929 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3933 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
3930 BoundNetLog(), GetParam(), NULL); | 3934 BoundNetLog(), GetParam(), NULL); |
3931 helper.RunPreTestSetup(); | 3935 helper.RunPreTestSetup(); |
3932 helper.AddData(&data); | 3936 helper.AddData(&data); |
3933 HttpNetworkTransaction* trans = helper.trans(); | 3937 HttpNetworkTransaction* trans = helper.trans(); |
3934 | 3938 |
3935 TestCompletionCallback callback; | 3939 TestCompletionCallback callback; |
3936 int rv = trans->Start( | 3940 int rv = trans->Start( |
3937 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 3941 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
3938 EXPECT_EQ(ERR_IO_PENDING, rv); | 3942 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
3939 | 3943 |
3940 TransactionHelperResult out = helper.output(); | 3944 TransactionHelperResult out = helper.output(); |
3941 out.rv = callback.WaitForResult(); | 3945 out.rv = callback.WaitForResult(); |
3942 EXPECT_EQ(out.rv, OK); | 3946 EXPECT_EQ(out.rv, OK); |
3943 | 3947 |
3944 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3948 const HttpResponseInfo* response = trans->GetResponseInfo(); |
3945 EXPECT_TRUE(response->headers); | 3949 EXPECT_TRUE(response->headers); |
3946 EXPECT_TRUE(response->was_fetched_via_spdy); | 3950 EXPECT_TRUE(response->was_fetched_via_spdy); |
3947 out.status_line = response->headers->GetStatusLine(); | 3951 out.status_line = response->headers->GetStatusLine(); |
3948 out.response_info = *response; // Make a copy so we can verify. | 3952 out.response_info = *response; // Make a copy so we can verify. |
(...skipping 21 matching lines...) Expand all Loading... |
3970 | 3974 |
3971 out.response_data.swap(content); | 3975 out.response_data.swap(content); |
3972 | 3976 |
3973 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the | 3977 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the |
3974 // MockClientSocketFactory) are still alive. | 3978 // MockClientSocketFactory) are still alive. |
3975 base::RunLoop().RunUntilIdle(); | 3979 base::RunLoop().RunUntilIdle(); |
3976 | 3980 |
3977 // Verify that we consumed all test data. | 3981 // Verify that we consumed all test data. |
3978 helper.VerifyDataConsumed(); | 3982 helper.VerifyDataConsumed(); |
3979 | 3983 |
3980 EXPECT_EQ(OK, out.rv); | 3984 EXPECT_THAT(out.rv, IsOk()); |
3981 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 3985 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
3982 EXPECT_EQ("messagemessagemessagemessage", out.response_data); | 3986 EXPECT_EQ("messagemessagemessagemessage", out.response_data); |
3983 } | 3987 } |
3984 | 3988 |
3985 // Verify the case where we buffer data and close the connection. | 3989 // Verify the case where we buffer data and close the connection. |
3986 TEST_P(SpdyNetworkTransactionTest, BufferedClosed) { | 3990 TEST_P(SpdyNetworkTransactionTest, BufferedClosed) { |
3987 BufferedSpdyFramer framer(spdy_util_.spdy_version()); | 3991 BufferedSpdyFramer framer(spdy_util_.spdy_version()); |
3988 | 3992 |
3989 std::unique_ptr<SpdySerializedFrame> req( | 3993 std::unique_ptr<SpdySerializedFrame> req( |
3990 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 3994 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
(...skipping 23 matching lines...) Expand all Loading... |
4014 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 4018 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
4015 BoundNetLog(), GetParam(), NULL); | 4019 BoundNetLog(), GetParam(), NULL); |
4016 helper.RunPreTestSetup(); | 4020 helper.RunPreTestSetup(); |
4017 helper.AddData(&data); | 4021 helper.AddData(&data); |
4018 HttpNetworkTransaction* trans = helper.trans(); | 4022 HttpNetworkTransaction* trans = helper.trans(); |
4019 | 4023 |
4020 TestCompletionCallback callback; | 4024 TestCompletionCallback callback; |
4021 | 4025 |
4022 int rv = trans->Start( | 4026 int rv = trans->Start( |
4023 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 4027 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
4024 EXPECT_EQ(ERR_IO_PENDING, rv); | 4028 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
4025 | 4029 |
4026 TransactionHelperResult out = helper.output(); | 4030 TransactionHelperResult out = helper.output(); |
4027 out.rv = callback.WaitForResult(); | 4031 out.rv = callback.WaitForResult(); |
4028 EXPECT_EQ(out.rv, OK); | 4032 EXPECT_EQ(out.rv, OK); |
4029 | 4033 |
4030 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4034 const HttpResponseInfo* response = trans->GetResponseInfo(); |
4031 EXPECT_TRUE(response->headers); | 4035 EXPECT_TRUE(response->headers); |
4032 EXPECT_TRUE(response->was_fetched_via_spdy); | 4036 EXPECT_TRUE(response->was_fetched_via_spdy); |
4033 out.status_line = response->headers->GetStatusLine(); | 4037 out.status_line = response->headers->GetStatusLine(); |
4034 out.response_info = *response; // Make a copy so we can verify. | 4038 out.response_info = *response; // Make a copy so we can verify. |
4035 | 4039 |
4036 // Read Data | 4040 // Read Data |
4037 TestCompletionCallback read_callback; | 4041 TestCompletionCallback read_callback; |
4038 | 4042 |
4039 std::string content; | 4043 std::string content; |
4040 int reads_completed = 0; | 4044 int reads_completed = 0; |
4041 do { | 4045 do { |
4042 // Read small chunks at a time. | 4046 // Read small chunks at a time. |
4043 const int kSmallReadSize = 14; | 4047 const int kSmallReadSize = 14; |
4044 scoped_refptr<IOBuffer> buf(new IOBuffer(kSmallReadSize)); | 4048 scoped_refptr<IOBuffer> buf(new IOBuffer(kSmallReadSize)); |
4045 rv = trans->Read(buf.get(), kSmallReadSize, read_callback.callback()); | 4049 rv = trans->Read(buf.get(), kSmallReadSize, read_callback.callback()); |
4046 if (rv == ERR_IO_PENDING) { | 4050 if (rv == ERR_IO_PENDING) { |
4047 data.Resume(); | 4051 data.Resume(); |
4048 rv = read_callback.WaitForResult(); | 4052 rv = read_callback.WaitForResult(); |
4049 } | 4053 } |
4050 if (rv > 0) { | 4054 if (rv > 0) { |
4051 content.append(buf->data(), rv); | 4055 content.append(buf->data(), rv); |
4052 } else if (rv < 0) { | 4056 } else if (rv < 0) { |
4053 // This test intentionally closes the connection, and will get an error. | 4057 // This test intentionally closes the connection, and will get an error. |
4054 EXPECT_EQ(ERR_CONNECTION_CLOSED, rv); | 4058 EXPECT_THAT(rv, IsError(ERR_CONNECTION_CLOSED)); |
4055 break; | 4059 break; |
4056 } | 4060 } |
4057 reads_completed++; | 4061 reads_completed++; |
4058 } while (rv > 0); | 4062 } while (rv > 0); |
4059 | 4063 |
4060 EXPECT_EQ(0, reads_completed); | 4064 EXPECT_EQ(0, reads_completed); |
4061 | 4065 |
4062 out.response_data.swap(content); | 4066 out.response_data.swap(content); |
4063 | 4067 |
4064 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the | 4068 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4096 | 4100 |
4097 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 4101 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
4098 BoundNetLog(), GetParam(), NULL); | 4102 BoundNetLog(), GetParam(), NULL); |
4099 helper.RunPreTestSetup(); | 4103 helper.RunPreTestSetup(); |
4100 helper.AddData(&data); | 4104 helper.AddData(&data); |
4101 HttpNetworkTransaction* trans = helper.trans(); | 4105 HttpNetworkTransaction* trans = helper.trans(); |
4102 TestCompletionCallback callback; | 4106 TestCompletionCallback callback; |
4103 | 4107 |
4104 int rv = trans->Start( | 4108 int rv = trans->Start( |
4105 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 4109 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
4106 EXPECT_EQ(ERR_IO_PENDING, rv); | 4110 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
4107 | 4111 |
4108 TransactionHelperResult out = helper.output(); | 4112 TransactionHelperResult out = helper.output(); |
4109 out.rv = callback.WaitForResult(); | 4113 out.rv = callback.WaitForResult(); |
4110 EXPECT_EQ(out.rv, OK); | 4114 EXPECT_EQ(out.rv, OK); |
4111 | 4115 |
4112 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4116 const HttpResponseInfo* response = trans->GetResponseInfo(); |
4113 EXPECT_TRUE(response->headers); | 4117 EXPECT_TRUE(response->headers); |
4114 EXPECT_TRUE(response->was_fetched_via_spdy); | 4118 EXPECT_TRUE(response->was_fetched_via_spdy); |
4115 out.status_line = response->headers->GetStatusLine(); | 4119 out.status_line = response->headers->GetStatusLine(); |
4116 out.response_info = *response; // Make a copy so we can verify. | 4120 out.response_info = *response; // Make a copy so we can verify. |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4211 CreateMockRead(*body, 2), | 4215 CreateMockRead(*body, 2), |
4212 CreateMockRead(*settings_frame, 3), | 4216 CreateMockRead(*settings_frame, 3), |
4213 MockRead(ASYNC, 0, 4) // EOF | 4217 MockRead(ASYNC, 0, 4) // EOF |
4214 }; | 4218 }; |
4215 | 4219 |
4216 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 4220 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
4217 helper.AddData(&data); | 4221 helper.AddData(&data); |
4218 helper.RunDefaultTest(); | 4222 helper.RunDefaultTest(); |
4219 helper.VerifyDataConsumed(); | 4223 helper.VerifyDataConsumed(); |
4220 TransactionHelperResult out = helper.output(); | 4224 TransactionHelperResult out = helper.output(); |
4221 EXPECT_EQ(OK, out.rv); | 4225 EXPECT_THAT(out.rv, IsOk()); |
4222 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 4226 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
4223 EXPECT_EQ("hello!", out.response_data); | 4227 EXPECT_EQ("hello!", out.response_data); |
4224 | 4228 |
4225 { | 4229 { |
4226 // Verify we had two persisted settings. | 4230 // Verify we had two persisted settings. |
4227 const SettingsMap& settings_map = | 4231 const SettingsMap& settings_map = |
4228 spdy_session_pool->http_server_properties()->GetSpdySettings( | 4232 spdy_session_pool->http_server_properties()->GetSpdySettings( |
4229 spdy_server); | 4233 spdy_server); |
4230 ASSERT_EQ(2u, settings_map.size()); | 4234 ASSERT_EQ(2u, settings_map.size()); |
4231 | 4235 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4334 CreateMockRead(*reply, 3), | 4338 CreateMockRead(*reply, 3), |
4335 CreateMockRead(*body, 4), | 4339 CreateMockRead(*body, 4), |
4336 MockRead(ASYNC, 0, 5) // EOF | 4340 MockRead(ASYNC, 0, 5) // EOF |
4337 }; | 4341 }; |
4338 | 4342 |
4339 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 4343 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
4340 helper.AddData(&data); | 4344 helper.AddData(&data); |
4341 helper.RunDefaultTest(); | 4345 helper.RunDefaultTest(); |
4342 helper.VerifyDataConsumed(); | 4346 helper.VerifyDataConsumed(); |
4343 TransactionHelperResult out = helper.output(); | 4347 TransactionHelperResult out = helper.output(); |
4344 EXPECT_EQ(OK, out.rv); | 4348 EXPECT_THAT(out.rv, IsOk()); |
4345 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 4349 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
4346 EXPECT_EQ("hello!", out.response_data); | 4350 EXPECT_EQ("hello!", out.response_data); |
4347 | 4351 |
4348 { | 4352 { |
4349 // Verify we had two persisted settings. | 4353 // Verify we had two persisted settings. |
4350 const SettingsMap& settings_map = | 4354 const SettingsMap& settings_map = |
4351 spdy_session_pool->http_server_properties()->GetSpdySettings( | 4355 spdy_session_pool->http_server_properties()->GetSpdySettings( |
4352 spdy_server); | 4356 spdy_server); |
4353 ASSERT_EQ(2u, settings_map.size()); | 4357 ASSERT_EQ(2u, settings_map.size()); |
4354 | 4358 |
(...skipping 23 matching lines...) Expand all Loading... |
4378 MockRead reads[] = { | 4382 MockRead reads[] = { |
4379 CreateMockRead(*go_away, 1), | 4383 CreateMockRead(*go_away, 1), |
4380 }; | 4384 }; |
4381 | 4385 |
4382 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 4386 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
4383 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 4387 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
4384 BoundNetLog(), GetParam(), NULL); | 4388 BoundNetLog(), GetParam(), NULL); |
4385 helper.AddData(&data); | 4389 helper.AddData(&data); |
4386 helper.RunToCompletion(&data); | 4390 helper.RunToCompletion(&data); |
4387 TransactionHelperResult out = helper.output(); | 4391 TransactionHelperResult out = helper.output(); |
4388 EXPECT_EQ(ERR_ABORTED, out.rv); | 4392 EXPECT_THAT(out.rv, IsError(ERR_ABORTED)); |
4389 } | 4393 } |
4390 | 4394 |
4391 TEST_P(SpdyNetworkTransactionTest, CloseWithActiveStream) { | 4395 TEST_P(SpdyNetworkTransactionTest, CloseWithActiveStream) { |
4392 std::unique_ptr<SpdySerializedFrame> req( | 4396 std::unique_ptr<SpdySerializedFrame> req( |
4393 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 4397 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
4394 MockWrite writes[] = {CreateMockWrite(*req, 0)}; | 4398 MockWrite writes[] = {CreateMockWrite(*req, 0)}; |
4395 | 4399 |
4396 std::unique_ptr<SpdySerializedFrame> resp( | 4400 std::unique_ptr<SpdySerializedFrame> resp( |
4397 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 4401 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
4398 MockRead reads[] = { | 4402 MockRead reads[] = { |
(...skipping 13 matching lines...) Expand all Loading... |
4412 out.rv = trans->Start(&CreateGetRequest(), callback.callback(), log); | 4416 out.rv = trans->Start(&CreateGetRequest(), callback.callback(), log); |
4413 | 4417 |
4414 EXPECT_EQ(out.rv, ERR_IO_PENDING); | 4418 EXPECT_EQ(out.rv, ERR_IO_PENDING); |
4415 out.rv = callback.WaitForResult(); | 4419 out.rv = callback.WaitForResult(); |
4416 EXPECT_EQ(out.rv, OK); | 4420 EXPECT_EQ(out.rv, OK); |
4417 | 4421 |
4418 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4422 const HttpResponseInfo* response = trans->GetResponseInfo(); |
4419 EXPECT_TRUE(response->headers); | 4423 EXPECT_TRUE(response->headers); |
4420 EXPECT_TRUE(response->was_fetched_via_spdy); | 4424 EXPECT_TRUE(response->was_fetched_via_spdy); |
4421 out.rv = ReadTransaction(trans, &out.response_data); | 4425 out.rv = ReadTransaction(trans, &out.response_data); |
4422 EXPECT_EQ(ERR_CONNECTION_CLOSED, out.rv); | 4426 EXPECT_THAT(out.rv, IsError(ERR_CONNECTION_CLOSED)); |
4423 | 4427 |
4424 // Verify that we consumed all test data. | 4428 // Verify that we consumed all test data. |
4425 helper.VerifyDataConsumed(); | 4429 helper.VerifyDataConsumed(); |
4426 } | 4430 } |
4427 | 4431 |
4428 // HTTP_1_1_REQUIRED results in ERR_HTTP_1_1_REQUIRED. | 4432 // HTTP_1_1_REQUIRED results in ERR_HTTP_1_1_REQUIRED. |
4429 TEST_P(SpdyNetworkTransactionTest, HTTP11RequiredError) { | 4433 TEST_P(SpdyNetworkTransactionTest, HTTP11RequiredError) { |
4430 // HTTP_1_1_REQUIRED is only supported by HTTP/2. | 4434 // HTTP_1_1_REQUIRED is only supported by HTTP/2. |
4431 if (spdy_util_.spdy_version() < HTTP2) | 4435 if (spdy_util_.spdy_version() < HTTP2) |
4432 return; | 4436 return; |
4433 | 4437 |
4434 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 4438 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
4435 BoundNetLog(), GetParam(), nullptr); | 4439 BoundNetLog(), GetParam(), nullptr); |
4436 | 4440 |
4437 std::unique_ptr<SpdySerializedFrame> go_away(spdy_util_.ConstructSpdyGoAway( | 4441 std::unique_ptr<SpdySerializedFrame> go_away(spdy_util_.ConstructSpdyGoAway( |
4438 0, GOAWAY_HTTP_1_1_REQUIRED, "Try again using HTTP/1.1 please.")); | 4442 0, GOAWAY_HTTP_1_1_REQUIRED, "Try again using HTTP/1.1 please.")); |
4439 MockRead reads[] = { | 4443 MockRead reads[] = { |
4440 CreateMockRead(*go_away, 0), | 4444 CreateMockRead(*go_away, 0), |
4441 }; | 4445 }; |
4442 SequencedSocketData data(reads, arraysize(reads), nullptr, 0); | 4446 SequencedSocketData data(reads, arraysize(reads), nullptr, 0); |
4443 | 4447 |
4444 helper.RunToCompletion(&data); | 4448 helper.RunToCompletion(&data); |
4445 TransactionHelperResult out = helper.output(); | 4449 TransactionHelperResult out = helper.output(); |
4446 EXPECT_EQ(ERR_HTTP_1_1_REQUIRED, out.rv); | 4450 EXPECT_THAT(out.rv, IsError(ERR_HTTP_1_1_REQUIRED)); |
4447 } | 4451 } |
4448 | 4452 |
4449 // Retry with HTTP/1.1 when receiving HTTP_1_1_REQUIRED. Note that no actual | 4453 // Retry with HTTP/1.1 when receiving HTTP_1_1_REQUIRED. Note that no actual |
4450 // protocol negotiation happens, instead this test forces protocols for both | 4454 // protocol negotiation happens, instead this test forces protocols for both |
4451 // sockets. | 4455 // sockets. |
4452 TEST_P(SpdyNetworkTransactionTest, HTTP11RequiredRetry) { | 4456 TEST_P(SpdyNetworkTransactionTest, HTTP11RequiredRetry) { |
4453 // HTTP_1_1_REQUIRED is only supported by HTTP/2. | 4457 // HTTP_1_1_REQUIRED is only supported by HTTP/2. |
4454 if (spdy_util_.spdy_version() < HTTP2) | 4458 if (spdy_util_.spdy_version() < HTTP2) |
4455 return; | 4459 return; |
4456 | 4460 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4518 ASSERT_TRUE(response); | 4522 ASSERT_TRUE(response); |
4519 ASSERT_TRUE(response->headers); | 4523 ASSERT_TRUE(response->headers); |
4520 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 4524 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
4521 EXPECT_FALSE(response->was_fetched_via_spdy); | 4525 EXPECT_FALSE(response->was_fetched_via_spdy); |
4522 EXPECT_EQ(HttpResponseInfo::CONNECTION_INFO_HTTP1, response->connection_info); | 4526 EXPECT_EQ(HttpResponseInfo::CONNECTION_INFO_HTTP1, response->connection_info); |
4523 EXPECT_TRUE(response->was_npn_negotiated); | 4527 EXPECT_TRUE(response->was_npn_negotiated); |
4524 EXPECT_TRUE(request.url.SchemeIs("https")); | 4528 EXPECT_TRUE(request.url.SchemeIs("https")); |
4525 EXPECT_EQ("127.0.0.1", response->socket_address.host()); | 4529 EXPECT_EQ("127.0.0.1", response->socket_address.host()); |
4526 EXPECT_EQ(443, response->socket_address.port()); | 4530 EXPECT_EQ(443, response->socket_address.port()); |
4527 std::string response_data; | 4531 std::string response_data; |
4528 ASSERT_EQ(OK, ReadTransaction(helper.trans(), &response_data)); | 4532 ASSERT_THAT(ReadTransaction(helper.trans(), &response_data), IsOk()); |
4529 EXPECT_EQ("hello", response_data); | 4533 EXPECT_EQ("hello", response_data); |
4530 } | 4534 } |
4531 | 4535 |
4532 // Retry with HTTP/1.1 to the proxy when receiving HTTP_1_1_REQUIRED from the | 4536 // Retry with HTTP/1.1 to the proxy when receiving HTTP_1_1_REQUIRED from the |
4533 // proxy. Note that no actual protocol negotiation happens, instead this test | 4537 // proxy. Note that no actual protocol negotiation happens, instead this test |
4534 // forces protocols for both sockets. | 4538 // forces protocols for both sockets. |
4535 TEST_P(SpdyNetworkTransactionTest, HTTP11RequiredProxyRetry) { | 4539 TEST_P(SpdyNetworkTransactionTest, HTTP11RequiredProxyRetry) { |
4536 // HTTP_1_1_REQUIRED is only supported by HTTP/2. | 4540 // HTTP_1_1_REQUIRED is only supported by HTTP/2. |
4537 if (spdy_util_.spdy_version() < HTTP2) | 4541 if (spdy_util_.spdy_version() < HTTP2) |
4538 return; | 4542 return; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4619 ASSERT_TRUE(response); | 4623 ASSERT_TRUE(response); |
4620 ASSERT_TRUE(response->headers); | 4624 ASSERT_TRUE(response->headers); |
4621 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 4625 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
4622 EXPECT_FALSE(response->was_fetched_via_spdy); | 4626 EXPECT_FALSE(response->was_fetched_via_spdy); |
4623 EXPECT_EQ(HttpResponseInfo::CONNECTION_INFO_HTTP1, response->connection_info); | 4627 EXPECT_EQ(HttpResponseInfo::CONNECTION_INFO_HTTP1, response->connection_info); |
4624 EXPECT_FALSE(response->was_npn_negotiated); | 4628 EXPECT_FALSE(response->was_npn_negotiated); |
4625 EXPECT_TRUE(request.url.SchemeIs("https")); | 4629 EXPECT_TRUE(request.url.SchemeIs("https")); |
4626 EXPECT_EQ("127.0.0.1", response->socket_address.host()); | 4630 EXPECT_EQ("127.0.0.1", response->socket_address.host()); |
4627 EXPECT_EQ(70, response->socket_address.port()); | 4631 EXPECT_EQ(70, response->socket_address.port()); |
4628 std::string response_data; | 4632 std::string response_data; |
4629 ASSERT_EQ(OK, ReadTransaction(helper.trans(), &response_data)); | 4633 ASSERT_THAT(ReadTransaction(helper.trans(), &response_data), IsOk()); |
4630 EXPECT_EQ("hello", response_data); | 4634 EXPECT_EQ("hello", response_data); |
4631 } | 4635 } |
4632 | 4636 |
4633 // Test to make sure we can correctly connect through a proxy. | 4637 // Test to make sure we can correctly connect through a proxy. |
4634 TEST_P(SpdyNetworkTransactionTest, ProxyConnect) { | 4638 TEST_P(SpdyNetworkTransactionTest, ProxyConnect) { |
4635 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 4639 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
4636 BoundNetLog(), GetParam(), NULL); | 4640 BoundNetLog(), GetParam(), NULL); |
4637 helper.session_deps() = CreateSpdySessionDependencies( | 4641 helper.session_deps() = CreateSpdySessionDependencies( |
4638 GetParam(), ProxyService::CreateFixedFromPacResult("PROXY myproxy:70")); | 4642 GetParam(), ProxyService::CreateFixedFromPacResult("PROXY myproxy:70")); |
4639 helper.SetSession( | 4643 helper.SetSession( |
(...skipping 24 matching lines...) Expand all Loading... |
4664 MockRead(ASYNC, 0, 0, 5), | 4668 MockRead(ASYNC, 0, 0, 5), |
4665 }; | 4669 }; |
4666 std::unique_ptr<SequencedSocketData> data(new SequencedSocketData( | 4670 std::unique_ptr<SequencedSocketData> data(new SequencedSocketData( |
4667 reads, arraysize(reads), writes, arraysize(writes))); | 4671 reads, arraysize(reads), writes, arraysize(writes))); |
4668 | 4672 |
4669 helper.AddData(data.get()); | 4673 helper.AddData(data.get()); |
4670 TestCompletionCallback callback; | 4674 TestCompletionCallback callback; |
4671 | 4675 |
4672 int rv = trans->Start( | 4676 int rv = trans->Start( |
4673 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 4677 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
4674 EXPECT_EQ(ERR_IO_PENDING, rv); | 4678 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
4675 | 4679 |
4676 rv = callback.WaitForResult(); | 4680 rv = callback.WaitForResult(); |
4677 EXPECT_EQ(0, rv); | 4681 EXPECT_EQ(0, rv); |
4678 | 4682 |
4679 // Verify the SYN_REPLY. | 4683 // Verify the SYN_REPLY. |
4680 HttpResponseInfo response = *trans->GetResponseInfo(); | 4684 HttpResponseInfo response = *trans->GetResponseInfo(); |
4681 ASSERT_TRUE(response.headers); | 4685 ASSERT_TRUE(response.headers); |
4682 EXPECT_EQ("HTTP/1.1 200", response.headers->GetStatusLine()); | 4686 EXPECT_EQ("HTTP/1.1 200", response.headers->GetStatusLine()); |
4683 | 4687 |
4684 std::string response_data; | 4688 std::string response_data; |
4685 ASSERT_EQ(OK, ReadTransaction(trans, &response_data)); | 4689 ASSERT_THAT(ReadTransaction(trans, &response_data), IsOk()); |
4686 EXPECT_EQ("hello!", response_data); | 4690 EXPECT_EQ("hello!", response_data); |
4687 helper.VerifyDataConsumed(); | 4691 helper.VerifyDataConsumed(); |
4688 } | 4692 } |
4689 | 4693 |
4690 // Test to make sure we can correctly connect through a proxy to | 4694 // Test to make sure we can correctly connect through a proxy to |
4691 // www.example.org, if there already exists a direct spdy connection to | 4695 // www.example.org, if there already exists a direct spdy connection to |
4692 // www.example.org. See https://crbug.com/49874. | 4696 // www.example.org. See https://crbug.com/49874. |
4693 TEST_P(SpdyNetworkTransactionTest, DirectConnectProxyReconnect) { | 4697 TEST_P(SpdyNetworkTransactionTest, DirectConnectProxyReconnect) { |
4694 // When setting up the first transaction, we store the SpdySessionPool so that | 4698 // When setting up the first transaction, we store the SpdySessionPool so that |
4695 // we can use the same pool in the second transaction. | 4699 // we can use the same pool in the second transaction. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4735 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 4739 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
4736 | 4740 |
4737 EXPECT_EQ(out.rv, ERR_IO_PENDING); | 4741 EXPECT_EQ(out.rv, ERR_IO_PENDING); |
4738 out.rv = callback.WaitForResult(); | 4742 out.rv = callback.WaitForResult(); |
4739 EXPECT_EQ(out.rv, OK); | 4743 EXPECT_EQ(out.rv, OK); |
4740 | 4744 |
4741 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4745 const HttpResponseInfo* response = trans->GetResponseInfo(); |
4742 EXPECT_TRUE(response->headers); | 4746 EXPECT_TRUE(response->headers); |
4743 EXPECT_TRUE(response->was_fetched_via_spdy); | 4747 EXPECT_TRUE(response->was_fetched_via_spdy); |
4744 out.rv = ReadTransaction(trans, &out.response_data); | 4748 out.rv = ReadTransaction(trans, &out.response_data); |
4745 EXPECT_EQ(OK, out.rv); | 4749 EXPECT_THAT(out.rv, IsOk()); |
4746 out.status_line = response->headers->GetStatusLine(); | 4750 out.status_line = response->headers->GetStatusLine(); |
4747 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 4751 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
4748 EXPECT_EQ("hello!", out.response_data); | 4752 EXPECT_EQ("hello!", out.response_data); |
4749 | 4753 |
4750 // Check that the SpdySession is still in the SpdySessionPool. | 4754 // Check that the SpdySession is still in the SpdySessionPool. |
4751 SpdySessionKey session_pool_key_direct(host_port_pair_, ProxyServer::Direct(), | 4755 SpdySessionKey session_pool_key_direct(host_port_pair_, ProxyServer::Direct(), |
4752 PRIVACY_MODE_DISABLED); | 4756 PRIVACY_MODE_DISABLED); |
4753 EXPECT_TRUE(HasSpdySession(spdy_session_pool, session_pool_key_direct)); | 4757 EXPECT_TRUE(HasSpdySession(spdy_session_pool, session_pool_key_direct)); |
4754 SpdySessionKey session_pool_key_proxy( | 4758 SpdySessionKey session_pool_key_proxy( |
4755 host_port_pair_, | 4759 host_port_pair_, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4807 session_peer.SetProxyService(proxy_service.get()); | 4811 session_peer.SetProxyService(proxy_service.get()); |
4808 helper_proxy.session_deps().swap(ssd_proxy); | 4812 helper_proxy.session_deps().swap(ssd_proxy); |
4809 helper_proxy.SetSession(std::move(session_proxy)); | 4813 helper_proxy.SetSession(std::move(session_proxy)); |
4810 helper_proxy.RunPreTestSetup(); | 4814 helper_proxy.RunPreTestSetup(); |
4811 helper_proxy.AddData(data_proxy.get()); | 4815 helper_proxy.AddData(data_proxy.get()); |
4812 | 4816 |
4813 HttpNetworkTransaction* trans_proxy = helper_proxy.trans(); | 4817 HttpNetworkTransaction* trans_proxy = helper_proxy.trans(); |
4814 TestCompletionCallback callback_proxy; | 4818 TestCompletionCallback callback_proxy; |
4815 int rv = trans_proxy->Start( | 4819 int rv = trans_proxy->Start( |
4816 &request_proxy, callback_proxy.callback(), BoundNetLog()); | 4820 &request_proxy, callback_proxy.callback(), BoundNetLog()); |
4817 EXPECT_EQ(ERR_IO_PENDING, rv); | 4821 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
4818 rv = callback_proxy.WaitForResult(); | 4822 rv = callback_proxy.WaitForResult(); |
4819 EXPECT_EQ(0, rv); | 4823 EXPECT_EQ(0, rv); |
4820 | 4824 |
4821 HttpResponseInfo response_proxy = *trans_proxy->GetResponseInfo(); | 4825 HttpResponseInfo response_proxy = *trans_proxy->GetResponseInfo(); |
4822 ASSERT_TRUE(response_proxy.headers); | 4826 ASSERT_TRUE(response_proxy.headers); |
4823 EXPECT_EQ("HTTP/1.1 200", response_proxy.headers->GetStatusLine()); | 4827 EXPECT_EQ("HTTP/1.1 200", response_proxy.headers->GetStatusLine()); |
4824 | 4828 |
4825 std::string response_data; | 4829 std::string response_data; |
4826 ASSERT_EQ(OK, ReadTransaction(trans_proxy, &response_data)); | 4830 ASSERT_THAT(ReadTransaction(trans_proxy, &response_data), IsOk()); |
4827 EXPECT_EQ("hello!", response_data); | 4831 EXPECT_EQ("hello!", response_data); |
4828 | 4832 |
4829 helper_proxy.VerifyDataConsumed(); | 4833 helper_proxy.VerifyDataConsumed(); |
4830 } | 4834 } |
4831 | 4835 |
4832 // When we get a TCP-level RST, we need to retry a HttpNetworkTransaction | 4836 // When we get a TCP-level RST, we need to retry a HttpNetworkTransaction |
4833 // on a new connection, if the connection was previously known to be good. | 4837 // on a new connection, if the connection was previously known to be good. |
4834 // This can happen when a server reboots without saying goodbye, or when | 4838 // This can happen when a server reboots without saying goodbye, or when |
4835 // we're behind a NAT that masked the RST. | 4839 // we're behind a NAT that masked the RST. |
4836 TEST_P(SpdyNetworkTransactionTest, VerifyRetryOnConnectionReset) { | 4840 TEST_P(SpdyNetworkTransactionTest, VerifyRetryOnConnectionReset) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4884 helper.AddData(&data2); | 4888 helper.AddData(&data2); |
4885 helper.RunPreTestSetup(); | 4889 helper.RunPreTestSetup(); |
4886 | 4890 |
4887 for (int i = 0; i < 2; ++i) { | 4891 for (int i = 0; i < 2; ++i) { |
4888 std::unique_ptr<HttpNetworkTransaction> trans( | 4892 std::unique_ptr<HttpNetworkTransaction> trans( |
4889 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 4893 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); |
4890 | 4894 |
4891 TestCompletionCallback callback; | 4895 TestCompletionCallback callback; |
4892 int rv = trans->Start( | 4896 int rv = trans->Start( |
4893 &helper.request(), callback.callback(), BoundNetLog()); | 4897 &helper.request(), callback.callback(), BoundNetLog()); |
4894 EXPECT_EQ(ERR_IO_PENDING, rv); | 4898 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
4895 // On the second transaction, we trigger the RST. | 4899 // On the second transaction, we trigger the RST. |
4896 if (i == 1) { | 4900 if (i == 1) { |
4897 if (variant == VARIANT_RST_DURING_READ_COMPLETION) { | 4901 if (variant == VARIANT_RST_DURING_READ_COMPLETION) { |
4898 // Writes to the socket complete asynchronously on SPDY by running | 4902 // Writes to the socket complete asynchronously on SPDY by running |
4899 // through the message loop. Complete the write here. | 4903 // through the message loop. Complete the write here. |
4900 base::RunLoop().RunUntilIdle(); | 4904 base::RunLoop().RunUntilIdle(); |
4901 } | 4905 } |
4902 | 4906 |
4903 // Now schedule the ERR_CONNECTION_RESET. | 4907 // Now schedule the ERR_CONNECTION_RESET. |
4904 data1.Resume(); | 4908 data1.Resume(); |
4905 } | 4909 } |
4906 rv = callback.WaitForResult(); | 4910 rv = callback.WaitForResult(); |
4907 EXPECT_EQ(OK, rv); | 4911 EXPECT_THAT(rv, IsOk()); |
4908 | 4912 |
4909 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4913 const HttpResponseInfo* response = trans->GetResponseInfo(); |
4910 ASSERT_TRUE(response); | 4914 ASSERT_TRUE(response); |
4911 EXPECT_TRUE(response->headers); | 4915 EXPECT_TRUE(response->headers); |
4912 EXPECT_TRUE(response->was_fetched_via_spdy); | 4916 EXPECT_TRUE(response->was_fetched_via_spdy); |
4913 std::string response_data; | 4917 std::string response_data; |
4914 rv = ReadTransaction(trans.get(), &response_data); | 4918 rv = ReadTransaction(trans.get(), &response_data); |
4915 EXPECT_EQ(OK, rv); | 4919 EXPECT_THAT(rv, IsOk()); |
4916 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 4920 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
4917 EXPECT_EQ("hello!", response_data); | 4921 EXPECT_EQ("hello!", response_data); |
4918 base::RunLoop().RunUntilIdle(); | 4922 base::RunLoop().RunUntilIdle(); |
4919 } | 4923 } |
4920 | 4924 |
4921 helper.VerifyDataConsumed(); | 4925 helper.VerifyDataConsumed(); |
4922 base::RunLoop().RunUntilIdle(); | 4926 base::RunLoop().RunUntilIdle(); |
4923 } | 4927 } |
4924 } | 4928 } |
4925 | 4929 |
(...skipping 13 matching lines...) Expand all Loading... |
4939 CreateMockRead(*body, 2), | 4943 CreateMockRead(*body, 2), |
4940 MockRead(ASYNC, 0, 3) // EOF | 4944 MockRead(ASYNC, 0, 3) // EOF |
4941 }; | 4945 }; |
4942 | 4946 |
4943 SequencedSocketData data(spdy_reads, arraysize(spdy_reads), spdy_writes, | 4947 SequencedSocketData data(spdy_reads, arraysize(spdy_reads), spdy_writes, |
4944 arraysize(spdy_writes)); | 4948 arraysize(spdy_writes)); |
4945 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 4949 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
4946 BoundNetLog(), GetParam(), NULL); | 4950 BoundNetLog(), GetParam(), NULL); |
4947 helper.RunToCompletion(&data); | 4951 helper.RunToCompletion(&data); |
4948 TransactionHelperResult out = helper.output(); | 4952 TransactionHelperResult out = helper.output(); |
4949 EXPECT_EQ(OK, out.rv); | 4953 EXPECT_THAT(out.rv, IsOk()); |
4950 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 4954 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
4951 EXPECT_EQ("hello!", out.response_data); | 4955 EXPECT_EQ("hello!", out.response_data); |
4952 | 4956 |
4953 HttpStreamFactory::set_spdy_enabled(false); | 4957 HttpStreamFactory::set_spdy_enabled(false); |
4954 MockWrite http_writes[] = { | 4958 MockWrite http_writes[] = { |
4955 MockWrite(SYNCHRONOUS, 0, | 4959 MockWrite(SYNCHRONOUS, 0, |
4956 "GET / HTTP/1.1\r\n" | 4960 "GET / HTTP/1.1\r\n" |
4957 "Host: www.example.org\r\n" | 4961 "Host: www.example.org\r\n" |
4958 "Connection: keep-alive\r\n\r\n"), | 4962 "Connection: keep-alive\r\n\r\n"), |
4959 }; | 4963 }; |
4960 | 4964 |
4961 MockRead http_reads[] = { | 4965 MockRead http_reads[] = { |
4962 MockRead(SYNCHRONOUS, 1, "HTTP/1.1 200 OK\r\n\r\n"), | 4966 MockRead(SYNCHRONOUS, 1, "HTTP/1.1 200 OK\r\n\r\n"), |
4963 MockRead(SYNCHRONOUS, 2, "hello from http"), | 4967 MockRead(SYNCHRONOUS, 2, "hello from http"), |
4964 MockRead(SYNCHRONOUS, OK, 3), | 4968 MockRead(SYNCHRONOUS, OK, 3), |
4965 }; | 4969 }; |
4966 SequencedSocketData data2(http_reads, arraysize(http_reads), http_writes, | 4970 SequencedSocketData data2(http_reads, arraysize(http_reads), http_writes, |
4967 arraysize(http_writes)); | 4971 arraysize(http_writes)); |
4968 NormalSpdyTransactionHelper helper2(CreateGetRequest(), DEFAULT_PRIORITY, | 4972 NormalSpdyTransactionHelper helper2(CreateGetRequest(), DEFAULT_PRIORITY, |
4969 BoundNetLog(), GetParam(), NULL); | 4973 BoundNetLog(), GetParam(), NULL); |
4970 helper2.SetSpdyDisabled(); | 4974 helper2.SetSpdyDisabled(); |
4971 helper2.RunToCompletion(&data2); | 4975 helper2.RunToCompletion(&data2); |
4972 TransactionHelperResult out2 = helper2.output(); | 4976 TransactionHelperResult out2 = helper2.output(); |
4973 EXPECT_EQ(OK, out2.rv); | 4977 EXPECT_THAT(out2.rv, IsOk()); |
4974 EXPECT_EQ("HTTP/1.1 200 OK", out2.status_line); | 4978 EXPECT_EQ("HTTP/1.1 200 OK", out2.status_line); |
4975 EXPECT_EQ("hello from http", out2.response_data); | 4979 EXPECT_EQ("hello from http", out2.response_data); |
4976 | 4980 |
4977 HttpStreamFactory::set_spdy_enabled(true); | 4981 HttpStreamFactory::set_spdy_enabled(true); |
4978 } | 4982 } |
4979 | 4983 |
4980 // Tests that Basic authentication works over SPDY | 4984 // Tests that Basic authentication works over SPDY |
4981 TEST_P(SpdyNetworkTransactionTest, SpdyBasicAuth) { | 4985 TEST_P(SpdyNetworkTransactionTest, SpdyBasicAuth) { |
4982 HttpStreamFactory::set_spdy_enabled(true); | 4986 HttpStreamFactory::set_spdy_enabled(true); |
4983 | 4987 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5028 HttpRequestInfo request(CreateGetRequest()); | 5032 HttpRequestInfo request(CreateGetRequest()); |
5029 BoundNetLog net_log; | 5033 BoundNetLog net_log; |
5030 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, | 5034 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, |
5031 net_log, GetParam(), NULL); | 5035 net_log, GetParam(), NULL); |
5032 | 5036 |
5033 helper.RunPreTestSetup(); | 5037 helper.RunPreTestSetup(); |
5034 helper.AddData(&data); | 5038 helper.AddData(&data); |
5035 HttpNetworkTransaction* trans = helper.trans(); | 5039 HttpNetworkTransaction* trans = helper.trans(); |
5036 TestCompletionCallback callback; | 5040 TestCompletionCallback callback; |
5037 const int rv_start = trans->Start(&request, callback.callback(), net_log); | 5041 const int rv_start = trans->Start(&request, callback.callback(), net_log); |
5038 EXPECT_EQ(ERR_IO_PENDING, rv_start); | 5042 EXPECT_THAT(rv_start, IsError(ERR_IO_PENDING)); |
5039 const int rv_start_complete = callback.WaitForResult(); | 5043 const int rv_start_complete = callback.WaitForResult(); |
5040 EXPECT_EQ(OK, rv_start_complete); | 5044 EXPECT_THAT(rv_start_complete, IsOk()); |
5041 | 5045 |
5042 // Make sure the response has an auth challenge. | 5046 // Make sure the response has an auth challenge. |
5043 const HttpResponseInfo* const response_start = trans->GetResponseInfo(); | 5047 const HttpResponseInfo* const response_start = trans->GetResponseInfo(); |
5044 ASSERT_TRUE(response_start); | 5048 ASSERT_TRUE(response_start); |
5045 ASSERT_TRUE(response_start->headers); | 5049 ASSERT_TRUE(response_start->headers); |
5046 EXPECT_EQ(401, response_start->headers->response_code()); | 5050 EXPECT_EQ(401, response_start->headers->response_code()); |
5047 EXPECT_TRUE(response_start->was_fetched_via_spdy); | 5051 EXPECT_TRUE(response_start->was_fetched_via_spdy); |
5048 AuthChallengeInfo* auth_challenge = response_start->auth_challenge.get(); | 5052 AuthChallengeInfo* auth_challenge = response_start->auth_challenge.get(); |
5049 ASSERT_TRUE(auth_challenge); | 5053 ASSERT_TRUE(auth_challenge); |
5050 EXPECT_FALSE(auth_challenge->is_proxy); | 5054 EXPECT_FALSE(auth_challenge->is_proxy); |
5051 EXPECT_EQ(kBasicAuthScheme, auth_challenge->scheme); | 5055 EXPECT_EQ(kBasicAuthScheme, auth_challenge->scheme); |
5052 EXPECT_EQ("MyRealm", auth_challenge->realm); | 5056 EXPECT_EQ("MyRealm", auth_challenge->realm); |
5053 | 5057 |
5054 // Restart with a username/password. | 5058 // Restart with a username/password. |
5055 AuthCredentials credentials(base::ASCIIToUTF16("foo"), | 5059 AuthCredentials credentials(base::ASCIIToUTF16("foo"), |
5056 base::ASCIIToUTF16("bar")); | 5060 base::ASCIIToUTF16("bar")); |
5057 TestCompletionCallback callback_restart; | 5061 TestCompletionCallback callback_restart; |
5058 const int rv_restart = trans->RestartWithAuth( | 5062 const int rv_restart = trans->RestartWithAuth( |
5059 credentials, callback_restart.callback()); | 5063 credentials, callback_restart.callback()); |
5060 EXPECT_EQ(ERR_IO_PENDING, rv_restart); | 5064 EXPECT_THAT(rv_restart, IsError(ERR_IO_PENDING)); |
5061 const int rv_restart_complete = callback_restart.WaitForResult(); | 5065 const int rv_restart_complete = callback_restart.WaitForResult(); |
5062 EXPECT_EQ(OK, rv_restart_complete); | 5066 EXPECT_THAT(rv_restart_complete, IsOk()); |
5063 // TODO(cbentzel): This is actually the same response object as before, but | 5067 // TODO(cbentzel): This is actually the same response object as before, but |
5064 // data has changed. | 5068 // data has changed. |
5065 const HttpResponseInfo* const response_restart = trans->GetResponseInfo(); | 5069 const HttpResponseInfo* const response_restart = trans->GetResponseInfo(); |
5066 ASSERT_TRUE(response_restart); | 5070 ASSERT_TRUE(response_restart); |
5067 ASSERT_TRUE(response_restart->headers); | 5071 ASSERT_TRUE(response_restart->headers); |
5068 EXPECT_EQ(200, response_restart->headers->response_code()); | 5072 EXPECT_EQ(200, response_restart->headers->response_code()); |
5069 EXPECT_TRUE(response_restart->auth_challenge.get() == NULL); | 5073 EXPECT_TRUE(response_restart->auth_challenge.get() == NULL); |
5070 } | 5074 } |
5071 | 5075 |
5072 TEST_P(SpdyNetworkTransactionTest, ServerPushWithHeaders) { | 5076 TEST_P(SpdyNetworkTransactionTest, ServerPushWithHeaders) { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5174 BoundNetLog(), GetParam(), NULL); | 5178 BoundNetLog(), GetParam(), NULL); |
5175 helper.AddData(&data); | 5179 helper.AddData(&data); |
5176 helper.RunPreTestSetup(); | 5180 helper.RunPreTestSetup(); |
5177 | 5181 |
5178 HttpNetworkTransaction* trans = helper.trans(); | 5182 HttpNetworkTransaction* trans = helper.trans(); |
5179 | 5183 |
5180 // Start the transaction. | 5184 // Start the transaction. |
5181 TestCompletionCallback callback; | 5185 TestCompletionCallback callback; |
5182 int rv = trans->Start( | 5186 int rv = trans->Start( |
5183 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 5187 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
5184 EXPECT_EQ(ERR_IO_PENDING, rv); | 5188 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
5185 // Run until we've received the primary SYN_STREAM, the pushed SYN_STREAM, | 5189 // Run until we've received the primary SYN_STREAM, the pushed SYN_STREAM, |
5186 // and the body of the primary stream, but before we've received the HEADERS | 5190 // and the body of the primary stream, but before we've received the HEADERS |
5187 // for the pushed stream. | 5191 // for the pushed stream. |
5188 data.RunUntilPaused(); | 5192 data.RunUntilPaused(); |
5189 EXPECT_EQ(OK, callback.WaitForResult()); | 5193 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
5190 | 5194 |
5191 // Request the pushed path. At this point, we've received the push, but the | 5195 // Request the pushed path. At this point, we've received the push, but the |
5192 // headers are not yet complete. | 5196 // headers are not yet complete. |
5193 std::unique_ptr<HttpNetworkTransaction> trans2( | 5197 std::unique_ptr<HttpNetworkTransaction> trans2( |
5194 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 5198 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); |
5195 rv = trans2->Start( | 5199 rv = trans2->Start( |
5196 &CreateGetPushRequest(), callback.callback(), BoundNetLog()); | 5200 &CreateGetPushRequest(), callback.callback(), BoundNetLog()); |
5197 EXPECT_EQ(ERR_IO_PENDING, rv); | 5201 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
5198 data.Resume(); | 5202 data.Resume(); |
5199 data.RunUntilPaused(); | 5203 data.RunUntilPaused(); |
5200 base::RunLoop().RunUntilIdle(); | 5204 base::RunLoop().RunUntilIdle(); |
5201 | 5205 |
5202 // Read the server push body. | 5206 // Read the server push body. |
5203 std::string result2; | 5207 std::string result2; |
5204 ReadResult(trans2.get(), &result2); | 5208 ReadResult(trans2.get(), &result2); |
5205 // Read the response body. | 5209 // Read the response body. |
5206 std::string result; | 5210 std::string result; |
5207 ReadResult(trans, &result); | 5211 ReadResult(trans, &result); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5303 BoundNetLog(), GetParam(), NULL); | 5307 BoundNetLog(), GetParam(), NULL); |
5304 helper.AddData(&data); | 5308 helper.AddData(&data); |
5305 helper.RunPreTestSetup(); | 5309 helper.RunPreTestSetup(); |
5306 | 5310 |
5307 HttpNetworkTransaction* trans = helper.trans(); | 5311 HttpNetworkTransaction* trans = helper.trans(); |
5308 | 5312 |
5309 // Start the transaction. | 5313 // Start the transaction. |
5310 TestCompletionCallback callback; | 5314 TestCompletionCallback callback; |
5311 int rv = trans->Start( | 5315 int rv = trans->Start( |
5312 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 5316 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
5313 EXPECT_EQ(ERR_IO_PENDING, rv); | 5317 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
5314 // Run until we've received the primary SYN_STREAM, the pushed SYN_STREAM, | 5318 // Run until we've received the primary SYN_STREAM, the pushed SYN_STREAM, |
5315 // the first HEADERS frame, and the body of the primary stream, but before | 5319 // the first HEADERS frame, and the body of the primary stream, but before |
5316 // we've received the final HEADERS for the pushed stream. | 5320 // we've received the final HEADERS for the pushed stream. |
5317 data.RunUntilPaused(); | 5321 data.RunUntilPaused(); |
5318 EXPECT_EQ(0, callback.WaitForResult()); | 5322 EXPECT_EQ(0, callback.WaitForResult()); |
5319 | 5323 |
5320 // Request the pushed path. At this point, we've received the push, but the | 5324 // Request the pushed path. At this point, we've received the push, but the |
5321 // headers are not yet complete. | 5325 // headers are not yet complete. |
5322 std::unique_ptr<HttpNetworkTransaction> trans2( | 5326 std::unique_ptr<HttpNetworkTransaction> trans2( |
5323 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 5327 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); |
5324 rv = trans2->Start( | 5328 rv = trans2->Start( |
5325 &CreateGetPushRequest(), callback.callback(), BoundNetLog()); | 5329 &CreateGetPushRequest(), callback.callback(), BoundNetLog()); |
5326 EXPECT_EQ(ERR_IO_PENDING, rv); | 5330 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
5327 data.Resume(); | 5331 data.Resume(); |
5328 data.RunUntilPaused(); | 5332 data.RunUntilPaused(); |
5329 base::RunLoop().RunUntilIdle(); | 5333 base::RunLoop().RunUntilIdle(); |
5330 // This is needed to work around https://crbug.com/571102. | 5334 // This is needed to work around https://crbug.com/571102. |
5331 data.Resume(); | 5335 data.Resume(); |
5332 data.RunUntilPaused(); | 5336 data.RunUntilPaused(); |
5333 base::RunLoop().RunUntilIdle(); | 5337 base::RunLoop().RunUntilIdle(); |
5334 | 5338 |
5335 // Read the server push body. | 5339 // Read the server push body. |
5336 std::string result2; | 5340 std::string result2; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5417 BoundNetLog(), GetParam(), NULL); | 5421 BoundNetLog(), GetParam(), NULL); |
5418 helper.AddData(&data); | 5422 helper.AddData(&data); |
5419 helper.RunPreTestSetup(); | 5423 helper.RunPreTestSetup(); |
5420 | 5424 |
5421 HttpNetworkTransaction* trans = helper.trans(); | 5425 HttpNetworkTransaction* trans = helper.trans(); |
5422 | 5426 |
5423 // Start the transaction. | 5427 // Start the transaction. |
5424 TestCompletionCallback callback; | 5428 TestCompletionCallback callback; |
5425 int rv = trans->Start( | 5429 int rv = trans->Start( |
5426 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 5430 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
5427 EXPECT_EQ(ERR_IO_PENDING, rv); | 5431 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
5428 // Run until we've received the primary SYN_STREAM, the pushed SYN_STREAM, | 5432 // Run until we've received the primary SYN_STREAM, the pushed SYN_STREAM, |
5429 // the first HEADERS frame, and the body of the primary stream, but before | 5433 // the first HEADERS frame, and the body of the primary stream, but before |
5430 // we've received the final HEADERS for the pushed stream. | 5434 // we've received the final HEADERS for the pushed stream. |
5431 data.RunUntilPaused(); | 5435 data.RunUntilPaused(); |
5432 EXPECT_EQ(0, callback.WaitForResult()); | 5436 EXPECT_EQ(0, callback.WaitForResult()); |
5433 | 5437 |
5434 // Request the pushed path. At this point, we've received the push, but the | 5438 // Request the pushed path. At this point, we've received the push, but the |
5435 // headers are not yet complete. | 5439 // headers are not yet complete. |
5436 std::unique_ptr<HttpNetworkTransaction> trans2( | 5440 std::unique_ptr<HttpNetworkTransaction> trans2( |
5437 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 5441 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); |
5438 rv = trans2->Start( | 5442 rv = trans2->Start( |
5439 &CreateGetPushRequest(), callback.callback(), BoundNetLog()); | 5443 &CreateGetPushRequest(), callback.callback(), BoundNetLog()); |
5440 EXPECT_EQ(ERR_IO_PENDING, rv); | 5444 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
5441 data.Resume(); | 5445 data.Resume(); |
5442 data.RunUntilPaused(); | 5446 data.RunUntilPaused(); |
5443 base::RunLoop().RunUntilIdle(); | 5447 base::RunLoop().RunUntilIdle(); |
5444 | 5448 |
5445 // Read the server push body. | 5449 // Read the server push body. |
5446 std::string result2; | 5450 std::string result2; |
5447 ReadResult(trans2.get(), &result2); | 5451 ReadResult(trans2.get(), &result2); |
5448 // Read the response body. | 5452 // Read the response body. |
5449 std::string result; | 5453 std::string result; |
5450 ReadResult(trans, &result); | 5454 ReadResult(trans, &result); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5496 CreateMockRead(*stream1_headers, 2), | 5500 CreateMockRead(*stream1_headers, 2), |
5497 CreateMockRead(*stream1_body, 3), | 5501 CreateMockRead(*stream1_body, 3), |
5498 MockRead(ASYNC, 0, 5) // EOF | 5502 MockRead(ASYNC, 0, 5) // EOF |
5499 }; | 5503 }; |
5500 | 5504 |
5501 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 5505 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
5502 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 5506 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
5503 BoundNetLog(), GetParam(), NULL); | 5507 BoundNetLog(), GetParam(), NULL); |
5504 helper.RunToCompletion(&data); | 5508 helper.RunToCompletion(&data); |
5505 TransactionHelperResult out = helper.output(); | 5509 TransactionHelperResult out = helper.output(); |
5506 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); | 5510 EXPECT_THAT(out.rv, IsError(ERR_SPDY_PROTOCOL_ERROR)); |
5507 } | 5511 } |
5508 | 5512 |
5509 // Tests that receiving HEADERS, DATA, HEADERS, and DATA in that sequence will | 5513 // Tests that receiving HEADERS, DATA, HEADERS, and DATA in that sequence will |
5510 // trigger a ERR_SPDY_PROTOCOL_ERROR because trailing HEADERS must not be | 5514 // trigger a ERR_SPDY_PROTOCOL_ERROR because trailing HEADERS must not be |
5511 // followed by any DATA frames. | 5515 // followed by any DATA frames. |
5512 TEST_P(SpdyNetworkTransactionTest, SyncReplyDataAfterTrailers) { | 5516 TEST_P(SpdyNetworkTransactionTest, SyncReplyDataAfterTrailers) { |
5513 std::unique_ptr<SpdySerializedFrame> req( | 5517 std::unique_ptr<SpdySerializedFrame> req( |
5514 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 5518 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
5515 std::unique_ptr<SpdySerializedFrame> rst( | 5519 std::unique_ptr<SpdySerializedFrame> rst( |
5516 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); | 5520 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); |
(...skipping 17 matching lines...) Expand all Loading... |
5534 CreateMockRead(*stream1_reply, 1), CreateMockRead(*stream1_body, 2), | 5538 CreateMockRead(*stream1_reply, 1), CreateMockRead(*stream1_body, 2), |
5535 CreateMockRead(*stream1_headers, 3), CreateMockRead(*stream1_body2, 4), | 5539 CreateMockRead(*stream1_headers, 3), CreateMockRead(*stream1_body2, 4), |
5536 MockRead(ASYNC, 0, 6) // EOF | 5540 MockRead(ASYNC, 0, 6) // EOF |
5537 }; | 5541 }; |
5538 | 5542 |
5539 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 5543 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
5540 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 5544 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
5541 BoundNetLog(), GetParam(), NULL); | 5545 BoundNetLog(), GetParam(), NULL); |
5542 helper.RunToCompletion(&data); | 5546 helper.RunToCompletion(&data); |
5543 TransactionHelperResult out = helper.output(); | 5547 TransactionHelperResult out = helper.output(); |
5544 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); | 5548 EXPECT_THAT(out.rv, IsError(ERR_SPDY_PROTOCOL_ERROR)); |
5545 } | 5549 } |
5546 | 5550 |
5547 TEST_P(SpdyNetworkTransactionTest, ServerPushCrossOriginCorrectness) { | 5551 TEST_P(SpdyNetworkTransactionTest, ServerPushCrossOriginCorrectness) { |
5548 // In this test we want to verify that we can't accidentally push content | 5552 // In this test we want to verify that we can't accidentally push content |
5549 // which can't be pushed by this content server. | 5553 // which can't be pushed by this content server. |
5550 // This test assumes that: | 5554 // This test assumes that: |
5551 // - if we're requesting http://www.foo.com/barbaz | 5555 // - if we're requesting http://www.foo.com/barbaz |
5552 // - the browser has made a connection to "www.foo.com". | 5556 // - the browser has made a connection to "www.foo.com". |
5553 | 5557 |
5554 // A list of the URL to fetch, followed by the URL being pushed. | 5558 // A list of the URL to fetch, followed by the URL being pushed. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5622 GetParam(), std::move(session_deps)); | 5626 GetParam(), std::move(session_deps)); |
5623 helper.RunPreTestSetup(); | 5627 helper.RunPreTestSetup(); |
5624 helper.AddData(&data); | 5628 helper.AddData(&data); |
5625 | 5629 |
5626 HttpNetworkTransaction* trans = helper.trans(); | 5630 HttpNetworkTransaction* trans = helper.trans(); |
5627 | 5631 |
5628 // Start the transaction with basic parameters. | 5632 // Start the transaction with basic parameters. |
5629 TestCompletionCallback callback; | 5633 TestCompletionCallback callback; |
5630 | 5634 |
5631 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 5635 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
5632 EXPECT_EQ(ERR_IO_PENDING, rv); | 5636 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
5633 rv = callback.WaitForResult(); | 5637 rv = callback.WaitForResult(); |
5634 | 5638 |
5635 // Read the response body. | 5639 // Read the response body. |
5636 std::string result; | 5640 std::string result; |
5637 ReadResult(trans, &result); | 5641 ReadResult(trans, &result); |
5638 | 5642 |
5639 // Verify that we consumed all test data. | 5643 // Verify that we consumed all test data. |
5640 EXPECT_TRUE(data.AllReadDataConsumed()); | 5644 EXPECT_TRUE(data.AllReadDataConsumed()); |
5641 EXPECT_TRUE(data.AllWriteDataConsumed()); | 5645 EXPECT_TRUE(data.AllWriteDataConsumed()); |
5642 | 5646 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5693 BoundNetLog log; | 5697 BoundNetLog log; |
5694 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, log, GetParam(), | 5698 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, log, GetParam(), |
5695 nullptr); | 5699 nullptr); |
5696 helper.RunPreTestSetup(); | 5700 helper.RunPreTestSetup(); |
5697 helper.AddData(&data); | 5701 helper.AddData(&data); |
5698 | 5702 |
5699 HttpNetworkTransaction* trans0 = helper.trans(); | 5703 HttpNetworkTransaction* trans0 = helper.trans(); |
5700 TestCompletionCallback callback0; | 5704 TestCompletionCallback callback0; |
5701 int rv = trans0->Start(&request, callback0.callback(), log); | 5705 int rv = trans0->Start(&request, callback0.callback(), log); |
5702 rv = callback0.GetResult(rv); | 5706 rv = callback0.GetResult(rv); |
5703 EXPECT_EQ(OK, rv); | 5707 EXPECT_THAT(rv, IsOk()); |
5704 | 5708 |
5705 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); | 5709 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); |
5706 SpdySessionKey key(host_port_pair_, ProxyServer::Direct(), | 5710 SpdySessionKey key(host_port_pair_, ProxyServer::Direct(), |
5707 PRIVACY_MODE_DISABLED); | 5711 PRIVACY_MODE_DISABLED); |
5708 base::WeakPtr<SpdySession> spdy_session = | 5712 base::WeakPtr<SpdySession> spdy_session = |
5709 spdy_session_pool->FindAvailableSession(key, GURL(), log); | 5713 spdy_session_pool->FindAvailableSession(key, GURL(), log); |
5710 | 5714 |
5711 EXPECT_FALSE(spdy_session->unclaimed_pushed_streams_.empty()); | 5715 EXPECT_FALSE(spdy_session->unclaimed_pushed_streams_.empty()); |
5712 EXPECT_EQ(1u, spdy_session->unclaimed_pushed_streams_.size()); | 5716 EXPECT_EQ(1u, spdy_session->unclaimed_pushed_streams_.size()); |
5713 EXPECT_EQ(1u, | 5717 EXPECT_EQ(1u, |
5714 spdy_session->unclaimed_pushed_streams_.count(GURL(url_to_push))); | 5718 spdy_session->unclaimed_pushed_streams_.count(GURL(url_to_push))); |
5715 | 5719 |
5716 std::unique_ptr<HttpNetworkTransaction> trans1( | 5720 std::unique_ptr<HttpNetworkTransaction> trans1( |
5717 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 5721 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); |
5718 HttpRequestInfo push_request; | 5722 HttpRequestInfo push_request; |
5719 push_request.method = "GET"; | 5723 push_request.method = "GET"; |
5720 push_request.url = GURL(url_to_push); | 5724 push_request.url = GURL(url_to_push); |
5721 push_request.load_flags = 0; | 5725 push_request.load_flags = 0; |
5722 TestCompletionCallback callback1; | 5726 TestCompletionCallback callback1; |
5723 rv = trans1->Start(&push_request, callback1.callback(), log); | 5727 rv = trans1->Start(&push_request, callback1.callback(), log); |
5724 rv = callback1.GetResult(rv); | 5728 rv = callback1.GetResult(rv); |
5725 EXPECT_EQ(OK, rv); | 5729 EXPECT_THAT(rv, IsOk()); |
5726 | 5730 |
5727 EXPECT_TRUE(spdy_session->unclaimed_pushed_streams_.empty()); | 5731 EXPECT_TRUE(spdy_session->unclaimed_pushed_streams_.empty()); |
5728 EXPECT_EQ(0u, spdy_session->unclaimed_pushed_streams_.size()); | 5732 EXPECT_EQ(0u, spdy_session->unclaimed_pushed_streams_.size()); |
5729 | 5733 |
5730 helper.VerifyDataConsumed(); | 5734 helper.VerifyDataConsumed(); |
5731 VerifyStreamsClosed(helper); | 5735 VerifyStreamsClosed(helper); |
5732 | 5736 |
5733 HttpResponseInfo response = *trans0->GetResponseInfo(); | 5737 HttpResponseInfo response = *trans0->GetResponseInfo(); |
5734 EXPECT_TRUE(response.headers); | 5738 EXPECT_TRUE(response.headers); |
5735 EXPECT_EQ("HTTP/1.1 200", response.headers->GetStatusLine()); | 5739 EXPECT_EQ("HTTP/1.1 200", response.headers->GetStatusLine()); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5832 std::unique_ptr<SSLSocketDataProvider> ssl_provider1( | 5836 std::unique_ptr<SSLSocketDataProvider> ssl_provider1( |
5833 new SSLSocketDataProvider(ASYNC, OK)); | 5837 new SSLSocketDataProvider(ASYNC, OK)); |
5834 ssl_provider1->cert = | 5838 ssl_provider1->cert = |
5835 ImportCertFromFile(GetTestCertsDirectory(), "wildcard.pem"); | 5839 ImportCertFromFile(GetTestCertsDirectory(), "wildcard.pem"); |
5836 helper.AddDataWithSSLSocketDataProvider(&data1, std::move(ssl_provider1)); | 5840 helper.AddDataWithSSLSocketDataProvider(&data1, std::move(ssl_provider1)); |
5837 | 5841 |
5838 HttpNetworkTransaction* trans0 = helper.trans(); | 5842 HttpNetworkTransaction* trans0 = helper.trans(); |
5839 TestCompletionCallback callback0; | 5843 TestCompletionCallback callback0; |
5840 int rv = trans0->Start(&request0, callback0.callback(), log); | 5844 int rv = trans0->Start(&request0, callback0.callback(), log); |
5841 rv = callback0.GetResult(rv); | 5845 rv = callback0.GetResult(rv); |
5842 EXPECT_EQ(OK, rv); | 5846 EXPECT_THAT(rv, IsOk()); |
5843 | 5847 |
5844 // Request |url_to_fetch1|, during which docs.example.org pushes | 5848 // Request |url_to_fetch1|, during which docs.example.org pushes |
5845 // |url_to_push|, which happens to be for www.example.org, to which there is | 5849 // |url_to_push|, which happens to be for www.example.org, to which there is |
5846 // already an open connection. | 5850 // already an open connection. |
5847 std::unique_ptr<HttpNetworkTransaction> trans1( | 5851 std::unique_ptr<HttpNetworkTransaction> trans1( |
5848 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 5852 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); |
5849 HttpRequestInfo request1; | 5853 HttpRequestInfo request1; |
5850 request1.method = "GET"; | 5854 request1.method = "GET"; |
5851 request1.url = GURL(url_to_fetch1); | 5855 request1.url = GURL(url_to_fetch1); |
5852 request1.load_flags = 0; | 5856 request1.load_flags = 0; |
5853 TestCompletionCallback callback1; | 5857 TestCompletionCallback callback1; |
5854 rv = trans1->Start(&request1, callback1.callback(), log); | 5858 rv = trans1->Start(&request1, callback1.callback(), log); |
5855 rv = callback1.GetResult(rv); | 5859 rv = callback1.GetResult(rv); |
5856 EXPECT_EQ(OK, rv); | 5860 EXPECT_THAT(rv, IsOk()); |
5857 | 5861 |
5858 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); | 5862 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); |
5859 HostPortPair host_port_pair0("mail.example.org", 443); | 5863 HostPortPair host_port_pair0("mail.example.org", 443); |
5860 SpdySessionKey key0(host_port_pair0, ProxyServer::Direct(), | 5864 SpdySessionKey key0(host_port_pair0, ProxyServer::Direct(), |
5861 PRIVACY_MODE_DISABLED); | 5865 PRIVACY_MODE_DISABLED); |
5862 base::WeakPtr<SpdySession> spdy_session0 = | 5866 base::WeakPtr<SpdySession> spdy_session0 = |
5863 spdy_session_pool->FindAvailableSession(key0, GURL(), log); | 5867 spdy_session_pool->FindAvailableSession(key0, GURL(), log); |
5864 | 5868 |
5865 EXPECT_TRUE(spdy_session0->unclaimed_pushed_streams_.empty()); | 5869 EXPECT_TRUE(spdy_session0->unclaimed_pushed_streams_.empty()); |
5866 EXPECT_EQ(0u, spdy_session0->unclaimed_pushed_streams_.size()); | 5870 EXPECT_EQ(0u, spdy_session0->unclaimed_pushed_streams_.size()); |
(...skipping 12 matching lines...) Expand all Loading... |
5879 // Request |url_to_push|, which should be served from the pushed resource. | 5883 // Request |url_to_push|, which should be served from the pushed resource. |
5880 std::unique_ptr<HttpNetworkTransaction> trans2( | 5884 std::unique_ptr<HttpNetworkTransaction> trans2( |
5881 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); | 5885 new HttpNetworkTransaction(DEFAULT_PRIORITY, helper.session())); |
5882 HttpRequestInfo push_request; | 5886 HttpRequestInfo push_request; |
5883 push_request.method = "GET"; | 5887 push_request.method = "GET"; |
5884 push_request.url = GURL(url_to_push); | 5888 push_request.url = GURL(url_to_push); |
5885 push_request.load_flags = 0; | 5889 push_request.load_flags = 0; |
5886 TestCompletionCallback callback2; | 5890 TestCompletionCallback callback2; |
5887 rv = trans2->Start(&push_request, callback2.callback(), log); | 5891 rv = trans2->Start(&push_request, callback2.callback(), log); |
5888 rv = callback2.GetResult(rv); | 5892 rv = callback2.GetResult(rv); |
5889 EXPECT_EQ(OK, rv); | 5893 EXPECT_THAT(rv, IsOk()); |
5890 | 5894 |
5891 EXPECT_TRUE(spdy_session0->unclaimed_pushed_streams_.empty()); | 5895 EXPECT_TRUE(spdy_session0->unclaimed_pushed_streams_.empty()); |
5892 EXPECT_EQ(0u, spdy_session0->unclaimed_pushed_streams_.size()); | 5896 EXPECT_EQ(0u, spdy_session0->unclaimed_pushed_streams_.size()); |
5893 | 5897 |
5894 EXPECT_TRUE(spdy_session1->unclaimed_pushed_streams_.empty()); | 5898 EXPECT_TRUE(spdy_session1->unclaimed_pushed_streams_.empty()); |
5895 EXPECT_EQ(0u, spdy_session1->unclaimed_pushed_streams_.size()); | 5899 EXPECT_EQ(0u, spdy_session1->unclaimed_pushed_streams_.size()); |
5896 | 5900 |
5897 helper.VerifyDataConsumed(); | 5901 helper.VerifyDataConsumed(); |
5898 VerifyStreamsClosed(helper); | 5902 VerifyStreamsClosed(helper); |
5899 | 5903 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6001 | 6005 |
6002 helper.RunPreTestSetup(); | 6006 helper.RunPreTestSetup(); |
6003 helper.AddData(&data); | 6007 helper.AddData(&data); |
6004 | 6008 |
6005 HttpNetworkTransaction* trans = helper.trans(); | 6009 HttpNetworkTransaction* trans = helper.trans(); |
6006 | 6010 |
6007 // Start the transaction with basic parameters. | 6011 // Start the transaction with basic parameters. |
6008 TestCompletionCallback callback; | 6012 TestCompletionCallback callback; |
6009 int rv = trans->Start( | 6013 int rv = trans->Start( |
6010 &CreateGetRequest(), callback.callback(), BoundNetLog()); | 6014 &CreateGetRequest(), callback.callback(), BoundNetLog()); |
6011 EXPECT_EQ(ERR_IO_PENDING, rv); | 6015 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
6012 rv = callback.WaitForResult(); | 6016 rv = callback.WaitForResult(); |
6013 EXPECT_EQ(OK, rv); | 6017 EXPECT_THAT(rv, IsOk()); |
6014 | 6018 |
6015 // Verify that we consumed all test data. | 6019 // Verify that we consumed all test data. |
6016 EXPECT_TRUE(data.AllReadDataConsumed()); | 6020 EXPECT_TRUE(data.AllReadDataConsumed()); |
6017 EXPECT_TRUE(data.AllWriteDataConsumed()); | 6021 EXPECT_TRUE(data.AllWriteDataConsumed()); |
6018 | 6022 |
6019 // Verify the SYN_REPLY. | 6023 // Verify the SYN_REPLY. |
6020 HttpResponseInfo response = *trans->GetResponseInfo(); | 6024 HttpResponseInfo response = *trans->GetResponseInfo(); |
6021 EXPECT_TRUE(response.headers); | 6025 EXPECT_TRUE(response.headers); |
6022 EXPECT_EQ("HTTP/1.1 200", response.headers->GetStatusLine()); | 6026 EXPECT_EQ("HTTP/1.1 200", response.headers->GetStatusLine()); |
6023 } | 6027 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6074 NormalSpdyTransactionHelper helper(CreateGetRequest(), LOWEST, | 6078 NormalSpdyTransactionHelper helper(CreateGetRequest(), LOWEST, |
6075 BoundNetLog(), GetParam(), NULL); | 6079 BoundNetLog(), GetParam(), NULL); |
6076 helper.RunPreTestSetup(); | 6080 helper.RunPreTestSetup(); |
6077 helper.AddData(&data); | 6081 helper.AddData(&data); |
6078 | 6082 |
6079 // Start the first transaction to set up the SpdySession | 6083 // Start the first transaction to set up the SpdySession |
6080 HttpNetworkTransaction* trans = helper.trans(); | 6084 HttpNetworkTransaction* trans = helper.trans(); |
6081 TestCompletionCallback callback; | 6085 TestCompletionCallback callback; |
6082 HttpRequestInfo info1 = CreateGetRequest(); | 6086 HttpRequestInfo info1 = CreateGetRequest(); |
6083 int rv = trans->Start(&info1, callback.callback(), BoundNetLog()); | 6087 int rv = trans->Start(&info1, callback.callback(), BoundNetLog()); |
6084 EXPECT_EQ(ERR_IO_PENDING, rv); | 6088 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
6085 | 6089 |
6086 // Run the message loop, but do not allow the write to complete. | 6090 // Run the message loop, but do not allow the write to complete. |
6087 // This leaves the SpdySession with a write pending, which prevents | 6091 // This leaves the SpdySession with a write pending, which prevents |
6088 // SpdySession from attempting subsequent writes until this write completes. | 6092 // SpdySession from attempting subsequent writes until this write completes. |
6089 base::RunLoop().RunUntilIdle(); | 6093 base::RunLoop().RunUntilIdle(); |
6090 | 6094 |
6091 // Now, start both new transactions | 6095 // Now, start both new transactions |
6092 HttpRequestInfo info2 = CreateGetRequest(); | 6096 HttpRequestInfo info2 = CreateGetRequest(); |
6093 TestCompletionCallback callback2; | 6097 TestCompletionCallback callback2; |
6094 std::unique_ptr<HttpNetworkTransaction> trans2( | 6098 std::unique_ptr<HttpNetworkTransaction> trans2( |
6095 new HttpNetworkTransaction(MEDIUM, helper.session())); | 6099 new HttpNetworkTransaction(MEDIUM, helper.session())); |
6096 rv = trans2->Start(&info2, callback2.callback(), BoundNetLog()); | 6100 rv = trans2->Start(&info2, callback2.callback(), BoundNetLog()); |
6097 EXPECT_EQ(ERR_IO_PENDING, rv); | 6101 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
6098 base::RunLoop().RunUntilIdle(); | 6102 base::RunLoop().RunUntilIdle(); |
6099 | 6103 |
6100 HttpRequestInfo info3 = CreateGetRequest(); | 6104 HttpRequestInfo info3 = CreateGetRequest(); |
6101 TestCompletionCallback callback3; | 6105 TestCompletionCallback callback3; |
6102 std::unique_ptr<HttpNetworkTransaction> trans3( | 6106 std::unique_ptr<HttpNetworkTransaction> trans3( |
6103 new HttpNetworkTransaction(HIGHEST, helper.session())); | 6107 new HttpNetworkTransaction(HIGHEST, helper.session())); |
6104 rv = trans3->Start(&info3, callback3.callback(), BoundNetLog()); | 6108 rv = trans3->Start(&info3, callback3.callback(), BoundNetLog()); |
6105 EXPECT_EQ(ERR_IO_PENDING, rv); | 6109 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
6106 base::RunLoop().RunUntilIdle(); | 6110 base::RunLoop().RunUntilIdle(); |
6107 | 6111 |
6108 // We now have two SYN_STREAM frames queued up which will be | 6112 // We now have two SYN_STREAM frames queued up which will be |
6109 // dequeued only once the first write completes, which we | 6113 // dequeued only once the first write completes, which we |
6110 // now allow to happen. | 6114 // now allow to happen. |
6111 ASSERT_TRUE(data.IsPaused()); | 6115 ASSERT_TRUE(data.IsPaused()); |
6112 data.Resume(); | 6116 data.Resume(); |
6113 EXPECT_EQ(OK, callback.WaitForResult()); | 6117 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
6114 | 6118 |
6115 // And now we can allow everything else to run to completion. | 6119 // And now we can allow everything else to run to completion. |
6116 data.Resume(); | 6120 data.Resume(); |
6117 base::RunLoop().RunUntilIdle(); | 6121 base::RunLoop().RunUntilIdle(); |
6118 EXPECT_EQ(OK, callback2.WaitForResult()); | 6122 EXPECT_THAT(callback2.WaitForResult(), IsOk()); |
6119 EXPECT_EQ(OK, callback3.WaitForResult()); | 6123 EXPECT_THAT(callback3.WaitForResult(), IsOk()); |
6120 | 6124 |
6121 helper.VerifyDataConsumed(); | 6125 helper.VerifyDataConsumed(); |
6122 } | 6126 } |
6123 | 6127 |
6124 // The tests below are only for SPDY/3 and above. | 6128 // The tests below are only for SPDY/3 and above. |
6125 | 6129 |
6126 // Test that sent data frames and received WINDOW_UPDATE frames change | 6130 // Test that sent data frames and received WINDOW_UPDATE frames change |
6127 // the send_window_size_ correctly. | 6131 // the send_window_size_ correctly. |
6128 | 6132 |
6129 // WINDOW_UPDATE is different than most other frames in that it can arrive | 6133 // WINDOW_UPDATE is different than most other frames in that it can arrive |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6200 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, | 6204 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, |
6201 BoundNetLog(), GetParam(), NULL); | 6205 BoundNetLog(), GetParam(), NULL); |
6202 helper.AddData(&data); | 6206 helper.AddData(&data); |
6203 helper.RunPreTestSetup(); | 6207 helper.RunPreTestSetup(); |
6204 | 6208 |
6205 HttpNetworkTransaction* trans = helper.trans(); | 6209 HttpNetworkTransaction* trans = helper.trans(); |
6206 | 6210 |
6207 TestCompletionCallback callback; | 6211 TestCompletionCallback callback; |
6208 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); | 6212 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); |
6209 | 6213 |
6210 EXPECT_EQ(ERR_IO_PENDING, rv); | 6214 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
6211 | 6215 |
6212 data.RunUntilPaused(); | 6216 data.RunUntilPaused(); |
6213 base::RunLoop().RunUntilIdle(); | 6217 base::RunLoop().RunUntilIdle(); |
6214 | 6218 |
6215 SpdyHttpStream* stream = static_cast<SpdyHttpStream*>(trans->stream_.get()); | 6219 SpdyHttpStream* stream = static_cast<SpdyHttpStream*>(trans->stream_.get()); |
6216 ASSERT_TRUE(stream); | 6220 ASSERT_TRUE(stream); |
6217 ASSERT_TRUE(stream->stream()); | 6221 ASSERT_TRUE(stream->stream()); |
6218 EXPECT_EQ(static_cast<int>( | 6222 EXPECT_EQ(static_cast<int>( |
6219 SpdySession::GetDefaultInitialWindowSize(GetParam().protocol)) + | 6223 SpdySession::GetDefaultInitialWindowSize(GetParam().protocol)) + |
6220 kDeltaWindowSize * kDeltaCount - | 6224 kDeltaWindowSize * kDeltaCount - |
6221 kMaxSpdyFrameChunkSize * kFrameCount, | 6225 kMaxSpdyFrameChunkSize * kFrameCount, |
6222 stream->stream()->send_window_size()); | 6226 stream->stream()->send_window_size()); |
6223 | 6227 |
6224 data.Resume(); | 6228 data.Resume(); |
6225 base::RunLoop().RunUntilIdle(); | 6229 base::RunLoop().RunUntilIdle(); |
6226 | 6230 |
6227 rv = callback.WaitForResult(); | 6231 rv = callback.WaitForResult(); |
6228 EXPECT_EQ(OK, rv); | 6232 EXPECT_THAT(rv, IsOk()); |
6229 | 6233 |
6230 helper.VerifyDataConsumed(); | 6234 helper.VerifyDataConsumed(); |
6231 } | 6235 } |
6232 | 6236 |
6233 // Test that received data frames and sent WINDOW_UPDATE frames change | 6237 // Test that received data frames and sent WINDOW_UPDATE frames change |
6234 // the recv_window_size_ correctly. | 6238 // the recv_window_size_ correctly. |
6235 TEST_P(SpdyNetworkTransactionTest, WindowUpdateSent) { | 6239 TEST_P(SpdyNetworkTransactionTest, WindowUpdateSent) { |
6236 const int32_t default_initial_window_size = | 6240 const int32_t default_initial_window_size = |
6237 SpdySession::GetDefaultInitialWindowSize(GetParam().protocol); | 6241 SpdySession::GetDefaultInitialWindowSize(GetParam().protocol); |
6238 // Session level maximum window size that is more than twice the default | 6242 // Session level maximum window size that is more than twice the default |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6324 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); | 6328 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); |
6325 SpdySessionPoolPeer pool_peer(spdy_session_pool); | 6329 SpdySessionPoolPeer pool_peer(spdy_session_pool); |
6326 pool_peer.SetEnableSendingInitialData(true); | 6330 pool_peer.SetEnableSendingInitialData(true); |
6327 pool_peer.SetSessionMaxRecvWindowSize(session_max_recv_window_size); | 6331 pool_peer.SetSessionMaxRecvWindowSize(session_max_recv_window_size); |
6328 pool_peer.SetStreamInitialRecvWindowSize(stream_max_recv_window_size); | 6332 pool_peer.SetStreamInitialRecvWindowSize(stream_max_recv_window_size); |
6329 | 6333 |
6330 HttpNetworkTransaction* trans = helper.trans(); | 6334 HttpNetworkTransaction* trans = helper.trans(); |
6331 TestCompletionCallback callback; | 6335 TestCompletionCallback callback; |
6332 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); | 6336 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); |
6333 | 6337 |
6334 EXPECT_EQ(ERR_IO_PENDING, rv); | 6338 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
6335 rv = callback.WaitForResult(); | 6339 rv = callback.WaitForResult(); |
6336 EXPECT_EQ(OK, rv); | 6340 EXPECT_THAT(rv, IsOk()); |
6337 | 6341 |
6338 SpdyHttpStream* stream = | 6342 SpdyHttpStream* stream = |
6339 static_cast<SpdyHttpStream*>(trans->stream_.get()); | 6343 static_cast<SpdyHttpStream*>(trans->stream_.get()); |
6340 ASSERT_TRUE(stream); | 6344 ASSERT_TRUE(stream); |
6341 ASSERT_TRUE(stream->stream()); | 6345 ASSERT_TRUE(stream->stream()); |
6342 | 6346 |
6343 // All data has been read, but not consumed. The window reflects this. | 6347 // All data has been read, but not consumed. The window reflects this. |
6344 EXPECT_EQ(static_cast<int>(stream_max_recv_window_size - kTargetSize), | 6348 EXPECT_EQ(static_cast<int>(stream_max_recv_window_size - kTargetSize), |
6345 stream->stream()->recv_window_size()); | 6349 stream->stream()->recv_window_size()); |
6346 | 6350 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6411 request.upload_data_stream = &upload_data_stream; | 6415 request.upload_data_stream = &upload_data_stream; |
6412 | 6416 |
6413 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, | 6417 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, |
6414 BoundNetLog(), GetParam(), NULL); | 6418 BoundNetLog(), GetParam(), NULL); |
6415 helper.RunPreTestSetup(); | 6419 helper.RunPreTestSetup(); |
6416 helper.AddData(&data); | 6420 helper.AddData(&data); |
6417 HttpNetworkTransaction* trans = helper.trans(); | 6421 HttpNetworkTransaction* trans = helper.trans(); |
6418 | 6422 |
6419 TestCompletionCallback callback; | 6423 TestCompletionCallback callback; |
6420 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); | 6424 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); |
6421 ASSERT_EQ(ERR_IO_PENDING, rv); | 6425 ASSERT_THAT(rv, IsError(ERR_IO_PENDING)); |
6422 | 6426 |
6423 base::RunLoop().RunUntilIdle(); | 6427 base::RunLoop().RunUntilIdle(); |
6424 ASSERT_TRUE(callback.have_result()); | 6428 ASSERT_TRUE(callback.have_result()); |
6425 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, callback.WaitForResult()); | 6429 EXPECT_THAT(callback.WaitForResult(), IsError(ERR_SPDY_PROTOCOL_ERROR)); |
6426 helper.VerifyDataConsumed(); | 6430 helper.VerifyDataConsumed(); |
6427 } | 6431 } |
6428 | 6432 |
6429 // Test that after hitting a send window size of 0, the write process | 6433 // Test that after hitting a send window size of 0, the write process |
6430 // stalls and upon receiving WINDOW_UPDATE frame write resumes. | 6434 // stalls and upon receiving WINDOW_UPDATE frame write resumes. |
6431 | 6435 |
6432 // This test constructs a POST request followed by enough data frames | 6436 // This test constructs a POST request followed by enough data frames |
6433 // containing 'a' that would make the window size 0, followed by another | 6437 // containing 'a' that would make the window size 0, followed by another |
6434 // data frame containing default content (which is "hello!") and this frame | 6438 // data frame containing default content (which is "hello!") and this frame |
6435 // also contains a FIN flag. SequencedSocketData is used to enforce all | 6439 // also contains a FIN flag. SequencedSocketData is used to enforce all |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6553 request.upload_data_stream = &upload_data_stream; | 6557 request.upload_data_stream = &upload_data_stream; |
6554 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, BoundNetLog(), | 6558 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, BoundNetLog(), |
6555 GetParam(), NULL); | 6559 GetParam(), NULL); |
6556 helper.AddData(&data); | 6560 helper.AddData(&data); |
6557 helper.RunPreTestSetup(); | 6561 helper.RunPreTestSetup(); |
6558 | 6562 |
6559 HttpNetworkTransaction* trans = helper.trans(); | 6563 HttpNetworkTransaction* trans = helper.trans(); |
6560 | 6564 |
6561 TestCompletionCallback callback; | 6565 TestCompletionCallback callback; |
6562 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); | 6566 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); |
6563 EXPECT_EQ(ERR_IO_PENDING, rv); | 6567 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
6564 | 6568 |
6565 base::RunLoop().RunUntilIdle(); // Write as much as we can. | 6569 base::RunLoop().RunUntilIdle(); // Write as much as we can. |
6566 | 6570 |
6567 SpdyHttpStream* stream = static_cast<SpdyHttpStream*>(trans->stream_.get()); | 6571 SpdyHttpStream* stream = static_cast<SpdyHttpStream*>(trans->stream_.get()); |
6568 ASSERT_TRUE(stream); | 6572 ASSERT_TRUE(stream); |
6569 ASSERT_TRUE(stream->stream()); | 6573 ASSERT_TRUE(stream->stream()); |
6570 EXPECT_EQ(0, stream->stream()->send_window_size()); | 6574 EXPECT_EQ(0, stream->stream()->send_window_size()); |
6571 if (initial_window_size % kBufferSize != 0) { | 6575 if (initial_window_size % kBufferSize != 0) { |
6572 // If it does not take whole number of full upload buffer to zero out | 6576 // If it does not take whole number of full upload buffer to zero out |
6573 // initial window size, then the upload data is not at EOF, because the | 6577 // initial window size, then the upload data is not at EOF, because the |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6712 request.upload_data_stream = &upload_data_stream; | 6716 request.upload_data_stream = &upload_data_stream; |
6713 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, | 6717 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, |
6714 BoundNetLog(), GetParam(), NULL); | 6718 BoundNetLog(), GetParam(), NULL); |
6715 helper.RunPreTestSetup(); | 6719 helper.RunPreTestSetup(); |
6716 helper.AddData(&data); | 6720 helper.AddData(&data); |
6717 | 6721 |
6718 HttpNetworkTransaction* trans = helper.trans(); | 6722 HttpNetworkTransaction* trans = helper.trans(); |
6719 | 6723 |
6720 TestCompletionCallback callback; | 6724 TestCompletionCallback callback; |
6721 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); | 6725 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); |
6722 EXPECT_EQ(ERR_IO_PENDING, rv); | 6726 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
6723 | 6727 |
6724 data.RunUntilPaused(); // Write as much as we can. | 6728 data.RunUntilPaused(); // Write as much as we can. |
6725 base::RunLoop().RunUntilIdle(); | 6729 base::RunLoop().RunUntilIdle(); |
6726 | 6730 |
6727 SpdyHttpStream* stream = static_cast<SpdyHttpStream*>(trans->stream_.get()); | 6731 SpdyHttpStream* stream = static_cast<SpdyHttpStream*>(trans->stream_.get()); |
6728 ASSERT_TRUE(stream); | 6732 ASSERT_TRUE(stream); |
6729 ASSERT_TRUE(stream->stream()); | 6733 ASSERT_TRUE(stream->stream()); |
6730 EXPECT_EQ(0, stream->stream()->send_window_size()); | 6734 EXPECT_EQ(0, stream->stream()->send_window_size()); |
6731 | 6735 |
6732 if (initial_window_size % kBufferSize != 0) { | 6736 if (initial_window_size % kBufferSize != 0) { |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6880 request.upload_data_stream = &upload_data_stream; | 6884 request.upload_data_stream = &upload_data_stream; |
6881 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, | 6885 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, |
6882 BoundNetLog(), GetParam(), NULL); | 6886 BoundNetLog(), GetParam(), NULL); |
6883 helper.RunPreTestSetup(); | 6887 helper.RunPreTestSetup(); |
6884 helper.AddData(&data); | 6888 helper.AddData(&data); |
6885 | 6889 |
6886 HttpNetworkTransaction* trans = helper.trans(); | 6890 HttpNetworkTransaction* trans = helper.trans(); |
6887 | 6891 |
6888 TestCompletionCallback callback; | 6892 TestCompletionCallback callback; |
6889 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); | 6893 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); |
6890 EXPECT_EQ(ERR_IO_PENDING, rv); | 6894 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
6891 | 6895 |
6892 data.RunUntilPaused(); // Write as much as we can. | 6896 data.RunUntilPaused(); // Write as much as we can. |
6893 base::RunLoop().RunUntilIdle(); | 6897 base::RunLoop().RunUntilIdle(); |
6894 | 6898 |
6895 SpdyHttpStream* stream = static_cast<SpdyHttpStream*>(trans->stream_.get()); | 6899 SpdyHttpStream* stream = static_cast<SpdyHttpStream*>(trans->stream_.get()); |
6896 ASSERT_TRUE(stream); | 6900 ASSERT_TRUE(stream); |
6897 ASSERT_TRUE(stream->stream()); | 6901 ASSERT_TRUE(stream->stream()); |
6898 EXPECT_EQ(0, stream->stream()->send_window_size()); | 6902 EXPECT_EQ(0, stream->stream()->send_window_size()); |
6899 | 6903 |
6900 if (initial_window_size % kBufferSize != 0) { | 6904 if (initial_window_size % kBufferSize != 0) { |
(...skipping 28 matching lines...) Expand all Loading... |
6929 0, GOAWAY_PROTOCOL_ERROR, "Odd push stream id.")); | 6933 0, GOAWAY_PROTOCOL_ERROR, "Odd push stream id.")); |
6930 MockWrite writes[] = { | 6934 MockWrite writes[] = { |
6931 CreateMockWrite(*req, 0), CreateMockWrite(*goaway, 2), | 6935 CreateMockWrite(*req, 0), CreateMockWrite(*goaway, 2), |
6932 }; | 6936 }; |
6933 | 6937 |
6934 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 6938 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
6935 NormalSpdyTransactionHelper helper( | 6939 NormalSpdyTransactionHelper helper( |
6936 CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL); | 6940 CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL); |
6937 helper.RunToCompletion(&data); | 6941 helper.RunToCompletion(&data); |
6938 TransactionHelperResult out = helper.output(); | 6942 TransactionHelperResult out = helper.output(); |
6939 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); | 6943 EXPECT_THAT(out.rv, IsError(ERR_SPDY_PROTOCOL_ERROR)); |
6940 } | 6944 } |
6941 | 6945 |
6942 TEST_P(SpdyNetworkTransactionTest, | 6946 TEST_P(SpdyNetworkTransactionTest, |
6943 GoAwayOnPushStreamIdLesserOrEqualThanLastAccepted) { | 6947 GoAwayOnPushStreamIdLesserOrEqualThanLastAccepted) { |
6944 std::unique_ptr<SpdySerializedFrame> push_a(spdy_util_.ConstructSpdyPush( | 6948 std::unique_ptr<SpdySerializedFrame> push_a(spdy_util_.ConstructSpdyPush( |
6945 NULL, 0, 4, 1, GetDefaultUrlWithPath("/a.dat").c_str())); | 6949 NULL, 0, 4, 1, GetDefaultUrlWithPath("/a.dat").c_str())); |
6946 SpdyHeaderBlock push_b_headers; | 6950 SpdyHeaderBlock push_b_headers; |
6947 spdy_util_.AddUrlToHeaderBlock(GetDefaultUrlWithPath("/b.dat"), | 6951 spdy_util_.AddUrlToHeaderBlock(GetDefaultUrlWithPath("/b.dat"), |
6948 &push_b_headers); | 6952 &push_b_headers); |
6949 std::unique_ptr<SpdySerializedFrame> push_b( | 6953 std::unique_ptr<SpdySerializedFrame> push_b( |
(...skipping 10 matching lines...) Expand all Loading... |
6960 "New push stream id must be greater than the last accepted.")); | 6964 "New push stream id must be greater than the last accepted.")); |
6961 MockWrite writes[] = { | 6965 MockWrite writes[] = { |
6962 CreateMockWrite(*req, 0), CreateMockWrite(*goaway, 3), | 6966 CreateMockWrite(*req, 0), CreateMockWrite(*goaway, 3), |
6963 }; | 6967 }; |
6964 | 6968 |
6965 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 6969 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
6966 NormalSpdyTransactionHelper helper( | 6970 NormalSpdyTransactionHelper helper( |
6967 CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL); | 6971 CreateGetRequest(), DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL); |
6968 helper.RunToCompletion(&data); | 6972 helper.RunToCompletion(&data); |
6969 TransactionHelperResult out = helper.output(); | 6973 TransactionHelperResult out = helper.output(); |
6970 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); | 6974 EXPECT_THAT(out.rv, IsError(ERR_SPDY_PROTOCOL_ERROR)); |
6971 } | 6975 } |
6972 | 6976 |
6973 // Regression test for https://crbug.com/493348: request header exceeds 16 kB | 6977 // Regression test for https://crbug.com/493348: request header exceeds 16 kB |
6974 // and thus sent in multiple frames when using HTTP/2. | 6978 // and thus sent in multiple frames when using HTTP/2. |
6975 TEST_P(SpdyNetworkTransactionTest, LargeRequest) { | 6979 TEST_P(SpdyNetworkTransactionTest, LargeRequest) { |
6976 const std::string kKey("foo"); | 6980 const std::string kKey("foo"); |
6977 const std::string kValue(1 << 15, 'z'); | 6981 const std::string kValue(1 << 15, 'z'); |
6978 | 6982 |
6979 HttpRequestInfo request; | 6983 HttpRequestInfo request; |
6980 request.method = "GET"; | 6984 request.method = "GET"; |
(...skipping 17 matching lines...) Expand all Loading... |
6998 CreateMockRead(*body, 2), | 7002 CreateMockRead(*body, 2), |
6999 MockRead(ASYNC, 0, 3) // EOF | 7003 MockRead(ASYNC, 0, 3) // EOF |
7000 }; | 7004 }; |
7001 | 7005 |
7002 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 7006 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
7003 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, BoundNetLog(), | 7007 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, BoundNetLog(), |
7004 GetParam(), nullptr); | 7008 GetParam(), nullptr); |
7005 helper.RunToCompletion(&data); | 7009 helper.RunToCompletion(&data); |
7006 TransactionHelperResult out = helper.output(); | 7010 TransactionHelperResult out = helper.output(); |
7007 | 7011 |
7008 EXPECT_EQ(OK, out.rv); | 7012 EXPECT_THAT(out.rv, IsOk()); |
7009 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 7013 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
7010 EXPECT_EQ("hello!", out.response_data); | 7014 EXPECT_EQ("hello!", out.response_data); |
7011 } | 7015 } |
7012 | 7016 |
7013 // Regression test for https://crbug.com/535629: response header exceeds 16 kB. | 7017 // Regression test for https://crbug.com/535629: response header exceeds 16 kB. |
7014 TEST_P(SpdyNetworkTransactionTest, LargeResponseHeader) { | 7018 TEST_P(SpdyNetworkTransactionTest, LargeResponseHeader) { |
7015 SpdyHeaderBlock headers(spdy_util_.ConstructGetHeaderBlock(kDefaultUrl)); | 7019 SpdyHeaderBlock headers(spdy_util_.ConstructGetHeaderBlock(kDefaultUrl)); |
7016 std::unique_ptr<SpdySerializedFrame> req( | 7020 std::unique_ptr<SpdySerializedFrame> req( |
7017 spdy_util_.ConstructSpdySyn(1, std::move(headers), LOWEST, true)); | 7021 spdy_util_.ConstructSpdySyn(1, std::move(headers), LOWEST, true)); |
7018 MockWrite writes[] = { | 7022 MockWrite writes[] = { |
(...skipping 19 matching lines...) Expand all Loading... |
7038 HttpRequestInfo request; | 7042 HttpRequestInfo request; |
7039 request.method = "GET"; | 7043 request.method = "GET"; |
7040 request.url = default_url_; | 7044 request.url = default_url_; |
7041 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, BoundNetLog(), | 7045 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, BoundNetLog(), |
7042 GetParam(), nullptr); | 7046 GetParam(), nullptr); |
7043 | 7047 |
7044 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 7048 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
7045 helper.RunToCompletion(&data); | 7049 helper.RunToCompletion(&data); |
7046 TransactionHelperResult out = helper.output(); | 7050 TransactionHelperResult out = helper.output(); |
7047 | 7051 |
7048 EXPECT_EQ(OK, out.rv); | 7052 EXPECT_THAT(out.rv, IsOk()); |
7049 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 7053 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
7050 EXPECT_EQ("hello!", out.response_data); | 7054 EXPECT_EQ("hello!", out.response_data); |
7051 ASSERT_TRUE(out.response_info.headers->HasHeaderValue(kKey, kValue)); | 7055 ASSERT_TRUE(out.response_info.headers->HasHeaderValue(kKey, kValue)); |
7052 } | 7056 } |
7053 | 7057 |
7054 class SpdyNetworkTransactionNoTLSUsageCheckTest | 7058 class SpdyNetworkTransactionNoTLSUsageCheckTest |
7055 : public SpdyNetworkTransactionTest { | 7059 : public SpdyNetworkTransactionTest { |
7056 protected: | 7060 protected: |
7057 void RunNoTLSUsageCheckTest( | 7061 void RunNoTLSUsageCheckTest( |
7058 std::unique_ptr<SSLSocketDataProvider> ssl_provider) { | 7062 std::unique_ptr<SSLSocketDataProvider> ssl_provider) { |
(...skipping 14 matching lines...) Expand all Loading... |
7073 | 7077 |
7074 SequencedSocketData data(reads, arraysize(reads), writes, | 7078 SequencedSocketData data(reads, arraysize(reads), writes, |
7075 arraysize(writes)); | 7079 arraysize(writes)); |
7076 HttpRequestInfo request; | 7080 HttpRequestInfo request; |
7077 request.method = "GET"; | 7081 request.method = "GET"; |
7078 request.url = default_url_; | 7082 request.url = default_url_; |
7079 NormalSpdyTransactionHelper helper( | 7083 NormalSpdyTransactionHelper helper( |
7080 request, DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL); | 7084 request, DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL); |
7081 helper.RunToCompletionWithSSLData(&data, std::move(ssl_provider)); | 7085 helper.RunToCompletionWithSSLData(&data, std::move(ssl_provider)); |
7082 TransactionHelperResult out = helper.output(); | 7086 TransactionHelperResult out = helper.output(); |
7083 EXPECT_EQ(OK, out.rv); | 7087 EXPECT_THAT(out.rv, IsOk()); |
7084 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 7088 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
7085 EXPECT_EQ("hello!", out.response_data); | 7089 EXPECT_EQ("hello!", out.response_data); |
7086 } | 7090 } |
7087 }; | 7091 }; |
7088 | 7092 |
7089 INSTANTIATE_TEST_CASE_P( | 7093 INSTANTIATE_TEST_CASE_P( |
7090 Spdy, | 7094 Spdy, |
7091 SpdyNetworkTransactionNoTLSUsageCheckTest, | 7095 SpdyNetworkTransactionNoTLSUsageCheckTest, |
7092 ::testing::Values(SpdyNetworkTransactionTestParams(kProtoSPDY31, | 7096 ::testing::Values(SpdyNetworkTransactionTestParams(kProtoSPDY31, |
7093 false))); | 7097 false))); |
(...skipping 26 matching lines...) Expand all Loading... |
7120 MockWrite writes[] = {CreateMockWrite(*goaway)}; | 7124 MockWrite writes[] = {CreateMockWrite(*goaway)}; |
7121 | 7125 |
7122 StaticSocketDataProvider data(NULL, 0, writes, arraysize(writes)); | 7126 StaticSocketDataProvider data(NULL, 0, writes, arraysize(writes)); |
7123 HttpRequestInfo request; | 7127 HttpRequestInfo request; |
7124 request.method = "GET"; | 7128 request.method = "GET"; |
7125 request.url = default_url_; | 7129 request.url = default_url_; |
7126 NormalSpdyTransactionHelper helper( | 7130 NormalSpdyTransactionHelper helper( |
7127 request, DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL); | 7131 request, DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL); |
7128 helper.RunToCompletionWithSSLData(&data, std::move(ssl_provider)); | 7132 helper.RunToCompletionWithSSLData(&data, std::move(ssl_provider)); |
7129 TransactionHelperResult out = helper.output(); | 7133 TransactionHelperResult out = helper.output(); |
7130 EXPECT_EQ(ERR_SPDY_INADEQUATE_TRANSPORT_SECURITY, out.rv); | 7134 EXPECT_THAT(out.rv, IsError(ERR_SPDY_INADEQUATE_TRANSPORT_SECURITY)); |
7131 } | 7135 } |
7132 }; | 7136 }; |
7133 | 7137 |
7134 INSTANTIATE_TEST_CASE_P( | 7138 INSTANTIATE_TEST_CASE_P( |
7135 Spdy, | 7139 Spdy, |
7136 SpdyNetworkTransactionTLSUsageCheckTest, | 7140 SpdyNetworkTransactionTLSUsageCheckTest, |
7137 ::testing::Values(SpdyNetworkTransactionTestParams(kProtoHTTP2, false), | 7141 ::testing::Values(SpdyNetworkTransactionTestParams(kProtoHTTP2, false), |
7138 SpdyNetworkTransactionTestParams(kProtoHTTP2, true))); | 7142 SpdyNetworkTransactionTestParams(kProtoHTTP2, true))); |
7139 | 7143 |
7140 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSVersionTooOld) { | 7144 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSVersionTooOld) { |
7141 std::unique_ptr<SSLSocketDataProvider> ssl_provider( | 7145 std::unique_ptr<SSLSocketDataProvider> ssl_provider( |
7142 new SSLSocketDataProvider(ASYNC, OK)); | 7146 new SSLSocketDataProvider(ASYNC, OK)); |
7143 SSLConnectionStatusSetVersion(SSL_CONNECTION_VERSION_SSL3, | 7147 SSLConnectionStatusSetVersion(SSL_CONNECTION_VERSION_SSL3, |
7144 &ssl_provider->connection_status); | 7148 &ssl_provider->connection_status); |
7145 | 7149 |
7146 RunTLSUsageCheckTest(std::move(ssl_provider)); | 7150 RunTLSUsageCheckTest(std::move(ssl_provider)); |
7147 } | 7151 } |
7148 | 7152 |
7149 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { | 7153 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { |
7150 std::unique_ptr<SSLSocketDataProvider> ssl_provider( | 7154 std::unique_ptr<SSLSocketDataProvider> ssl_provider( |
7151 new SSLSocketDataProvider(ASYNC, OK)); | 7155 new SSLSocketDataProvider(ASYNC, OK)); |
7152 // Set to TLS_RSA_WITH_NULL_MD5 | 7156 // Set to TLS_RSA_WITH_NULL_MD5 |
7153 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); | 7157 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); |
7154 | 7158 |
7155 RunTLSUsageCheckTest(std::move(ssl_provider)); | 7159 RunTLSUsageCheckTest(std::move(ssl_provider)); |
7156 } | 7160 } |
7157 | 7161 |
7158 } // namespace net | 7162 } // namespace net |
OLD | NEW |