OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/quic/quic_http_stream.h" | 5 #include "net/quic/quic_http_stream.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "net/quic/test_tools/quic_test_packet_maker.h" | 44 #include "net/quic/test_tools/quic_test_packet_maker.h" |
45 #include "net/quic/test_tools/quic_test_utils.h" | 45 #include "net/quic/test_tools/quic_test_utils.h" |
46 #include "net/quic/test_tools/test_task_runner.h" | 46 #include "net/quic/test_tools/test_task_runner.h" |
47 #include "net/socket/socket_performance_watcher.h" | 47 #include "net/socket/socket_performance_watcher.h" |
48 #include "net/socket/socket_test_util.h" | 48 #include "net/socket/socket_test_util.h" |
49 #include "net/spdy/spdy_frame_builder.h" | 49 #include "net/spdy/spdy_frame_builder.h" |
50 #include "net/spdy/spdy_framer.h" | 50 #include "net/spdy/spdy_framer.h" |
51 #include "net/spdy/spdy_http_utils.h" | 51 #include "net/spdy/spdy_http_utils.h" |
52 #include "net/spdy/spdy_protocol.h" | 52 #include "net/spdy/spdy_protocol.h" |
53 #include "net/test/cert_test_util.h" | 53 #include "net/test/cert_test_util.h" |
| 54 #include "net/test/gtest_util.h" |
54 #include "net/test/test_data_directory.h" | 55 #include "net/test/test_data_directory.h" |
55 #include "testing/gmock/include/gmock/gmock.h" | 56 #include "testing/gmock/include/gmock/gmock.h" |
56 #include "testing/gtest/include/gtest/gtest.h" | 57 #include "testing/gtest/include/gtest/gtest.h" |
57 | 58 |
| 59 using net::test::IsError; |
| 60 using net::test::IsOk; |
| 61 |
58 using std::string; | 62 using std::string; |
59 using testing::_; | 63 using testing::_; |
60 using testing::AnyNumber; | 64 using testing::AnyNumber; |
61 using testing::Return; | 65 using testing::Return; |
62 | 66 |
63 namespace net { | 67 namespace net { |
64 namespace test { | 68 namespace test { |
65 namespace { | 69 namespace { |
66 | 70 |
67 const char kUploadData[] = "Really nifty data!"; | 71 const char kUploadData[] = "Really nifty data!"; |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 | 589 |
586 EXPECT_EQ(OK, | 590 EXPECT_EQ(OK, |
587 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 591 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
588 net_log_.bound(), callback_.callback())); | 592 net_log_.bound(), callback_.callback())); |
589 EXPECT_EQ(OK, | 593 EXPECT_EQ(OK, |
590 stream_->SendRequest(headers_, &response_, callback_.callback())); | 594 stream_->SendRequest(headers_, &response_, callback_.callback())); |
591 | 595 |
592 // Ack the request. | 596 // Ack the request. |
593 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); | 597 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); |
594 | 598 |
595 EXPECT_EQ(ERR_IO_PENDING, stream_->ReadResponseHeaders(callback_.callback())); | 599 EXPECT_THAT(stream_->ReadResponseHeaders(callback_.callback()), |
| 600 IsError(ERR_IO_PENDING)); |
596 | 601 |
597 SetResponse("404 Not Found", string()); | 602 SetResponse("404 Not Found", string()); |
598 size_t spdy_response_header_frame_length; | 603 size_t spdy_response_header_frame_length; |
599 ProcessPacket(ConstructResponseHeadersPacket( | 604 ProcessPacket(ConstructResponseHeadersPacket( |
600 2, kFin, &spdy_response_header_frame_length)); | 605 2, kFin, &spdy_response_header_frame_length)); |
601 | 606 |
602 // Now that the headers have been processed, the callback will return. | 607 // Now that the headers have been processed, the callback will return. |
603 EXPECT_EQ(OK, callback_.WaitForResult()); | 608 EXPECT_THAT(callback_.WaitForResult(), IsOk()); |
604 ASSERT_TRUE(response_.headers.get()); | 609 ASSERT_TRUE(response_.headers.get()); |
605 EXPECT_EQ(404, response_.headers->response_code()); | 610 EXPECT_EQ(404, response_.headers->response_code()); |
606 EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); | 611 EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); |
607 EXPECT_FALSE(response_.response_time.is_null()); | 612 EXPECT_FALSE(response_.response_time.is_null()); |
608 EXPECT_FALSE(response_.request_time.is_null()); | 613 EXPECT_FALSE(response_.request_time.is_null()); |
609 | 614 |
610 // There is no body, so this should return immediately. | 615 // There is no body, so this should return immediately. |
611 EXPECT_EQ(0, | 616 EXPECT_EQ(0, |
612 stream_->ReadResponseBody(read_buffer_.get(), read_buffer_->size(), | 617 stream_->ReadResponseBody(read_buffer_.get(), read_buffer_->size(), |
613 callback_.callback())); | 618 callback_.callback())); |
(...skipping 24 matching lines...) Expand all Loading... |
638 | 643 |
639 EXPECT_EQ(OK, | 644 EXPECT_EQ(OK, |
640 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 645 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
641 net_log_.bound(), callback_.callback())); | 646 net_log_.bound(), callback_.callback())); |
642 | 647 |
643 EXPECT_EQ(OK, | 648 EXPECT_EQ(OK, |
644 stream_->SendRequest(headers_, &response_, callback_.callback())); | 649 stream_->SendRequest(headers_, &response_, callback_.callback())); |
645 // Ack the request. | 650 // Ack the request. |
646 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); | 651 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); |
647 | 652 |
648 EXPECT_EQ(ERR_IO_PENDING, stream_->ReadResponseHeaders(callback_.callback())); | 653 EXPECT_THAT(stream_->ReadResponseHeaders(callback_.callback()), |
| 654 IsError(ERR_IO_PENDING)); |
649 | 655 |
650 SetResponse("200 OK", string()); | 656 SetResponse("200 OK", string()); |
651 | 657 |
652 // Send the response headers. | 658 // Send the response headers. |
653 size_t spdy_response_header_frame_length; | 659 size_t spdy_response_header_frame_length; |
654 QuicStreamOffset offset = 0; | 660 QuicStreamOffset offset = 0; |
655 ProcessPacket(ConstructResponseHeadersPacketWithOffset( | 661 ProcessPacket(ConstructResponseHeadersPacketWithOffset( |
656 2, !kFin, &spdy_response_header_frame_length, &offset)); | 662 2, !kFin, &spdy_response_header_frame_length, &offset)); |
657 // Now that the headers have been processed, the callback will return. | 663 // Now that the headers have been processed, the callback will return. |
658 EXPECT_EQ(OK, callback_.WaitForResult()); | 664 EXPECT_THAT(callback_.WaitForResult(), IsOk()); |
659 ASSERT_TRUE(response_.headers.get()); | 665 ASSERT_TRUE(response_.headers.get()); |
660 EXPECT_EQ(200, response_.headers->response_code()); | 666 EXPECT_EQ(200, response_.headers->response_code()); |
661 EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); | 667 EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); |
662 EXPECT_FALSE(response_.response_time.is_null()); | 668 EXPECT_FALSE(response_.response_time.is_null()); |
663 EXPECT_FALSE(response_.request_time.is_null()); | 669 EXPECT_FALSE(response_.request_time.is_null()); |
664 | 670 |
665 // Send the response body. | 671 // Send the response body. |
666 const char kResponseBody[] = "Hello world!"; | 672 const char kResponseBody[] = "Hello world!"; |
667 ProcessPacket( | 673 ProcessPacket( |
668 ConstructServerDataPacket(3, false, !kFin, /*offset=*/0, kResponseBody)); | 674 ConstructServerDataPacket(3, false, !kFin, /*offset=*/0, kResponseBody)); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 | 732 |
727 EXPECT_EQ(OK, | 733 EXPECT_EQ(OK, |
728 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 734 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
729 net_log_.bound(), callback_.callback())); | 735 net_log_.bound(), callback_.callback())); |
730 EXPECT_EQ(OK, | 736 EXPECT_EQ(OK, |
731 stream_->SendRequest(headers_, &response_, callback_.callback())); | 737 stream_->SendRequest(headers_, &response_, callback_.callback())); |
732 | 738 |
733 // Ack the request. | 739 // Ack the request. |
734 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); | 740 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); |
735 | 741 |
736 EXPECT_EQ(ERR_IO_PENDING, stream_->ReadResponseHeaders(callback_.callback())); | 742 EXPECT_THAT(stream_->ReadResponseHeaders(callback_.callback()), |
| 743 IsError(ERR_IO_PENDING)); |
737 | 744 |
738 response_headers_[":status"] = "200 OK"; | 745 response_headers_[":status"] = "200 OK"; |
739 response_headers_[":version"] = "HTTP/1.1"; | 746 response_headers_[":version"] = "HTTP/1.1"; |
740 response_headers_["content-type"] = "text/plain"; | 747 response_headers_["content-type"] = "text/plain"; |
741 response_headers_["big6"] = string(1000, 'x'); // Lots of x's. | 748 response_headers_["big6"] = string(1000, 'x'); // Lots of x's. |
742 | 749 |
743 size_t spdy_response_headers_frame_length; | 750 size_t spdy_response_headers_frame_length; |
744 ProcessPacket(ConstructResponseHeadersPacket( | 751 ProcessPacket(ConstructResponseHeadersPacket( |
745 2, kFin, &spdy_response_headers_frame_length)); | 752 2, kFin, &spdy_response_headers_frame_length)); |
746 | 753 |
747 // Now that the headers have been processed, the callback will return. | 754 // Now that the headers have been processed, the callback will return. |
748 EXPECT_EQ(OK, callback_.WaitForResult()); | 755 EXPECT_THAT(callback_.WaitForResult(), IsOk()); |
749 ASSERT_TRUE(response_.headers.get()); | 756 ASSERT_TRUE(response_.headers.get()); |
750 EXPECT_EQ(200, response_.headers->response_code()); | 757 EXPECT_EQ(200, response_.headers->response_code()); |
751 EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); | 758 EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); |
752 | 759 |
753 // There is no body, so this should return immediately. | 760 // There is no body, so this should return immediately. |
754 EXPECT_EQ(0, | 761 EXPECT_EQ(0, |
755 stream_->ReadResponseBody(read_buffer_.get(), read_buffer_->size(), | 762 stream_->ReadResponseBody(read_buffer_.get(), read_buffer_->size(), |
756 callback_.callback())); | 763 callback_.callback())); |
757 EXPECT_TRUE(stream_->IsResponseBodyComplete()); | 764 EXPECT_TRUE(stream_->IsResponseBodyComplete()); |
758 EXPECT_TRUE(AtEof()); | 765 EXPECT_TRUE(AtEof()); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 request_.url = GURL("http://www.example.org/"); | 832 request_.url = GURL("http://www.example.org/"); |
826 | 833 |
827 EXPECT_EQ(OK, | 834 EXPECT_EQ(OK, |
828 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 835 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
829 net_log_.bound(), callback_.callback())); | 836 net_log_.bound(), callback_.callback())); |
830 EXPECT_EQ(OK, | 837 EXPECT_EQ(OK, |
831 stream_->SendRequest(headers_, &response_, callback_.callback())); | 838 stream_->SendRequest(headers_, &response_, callback_.callback())); |
832 | 839 |
833 // Ack the request. | 840 // Ack the request. |
834 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); | 841 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); |
835 EXPECT_EQ(ERR_IO_PENDING, stream_->ReadResponseHeaders(callback_.callback())); | 842 EXPECT_THAT(stream_->ReadResponseHeaders(callback_.callback()), |
| 843 IsError(ERR_IO_PENDING)); |
836 | 844 |
837 EXPECT_TRUE(QuicHttpStreamPeer::WasHandshakeConfirmed(stream_.get())); | 845 EXPECT_TRUE(QuicHttpStreamPeer::WasHandshakeConfirmed(stream_.get())); |
838 | 846 |
839 QuicConnectionCloseFrame frame; | 847 QuicConnectionCloseFrame frame; |
840 frame.error_code = QUIC_PEER_GOING_AWAY; | 848 frame.error_code = QUIC_PEER_GOING_AWAY; |
841 session_->connection()->OnConnectionCloseFrame(frame); | 849 session_->connection()->OnConnectionCloseFrame(frame); |
842 | 850 |
843 NetErrorDetails details; | 851 NetErrorDetails details; |
844 EXPECT_EQ(QUIC_NO_ERROR, details.quic_connection_error); | 852 EXPECT_EQ(QUIC_NO_ERROR, details.quic_connection_error); |
845 stream_->PopulateNetErrorDetails(&details); | 853 stream_->PopulateNetErrorDetails(&details); |
(...skipping 13 matching lines...) Expand all Loading... |
859 request_.url = GURL("http://www.example.org/"); | 867 request_.url = GURL("http://www.example.org/"); |
860 | 868 |
861 EXPECT_EQ(OK, | 869 EXPECT_EQ(OK, |
862 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 870 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
863 net_log_.bound(), callback_.callback())); | 871 net_log_.bound(), callback_.callback())); |
864 EXPECT_EQ(OK, | 872 EXPECT_EQ(OK, |
865 stream_->SendRequest(headers_, &response_, callback_.callback())); | 873 stream_->SendRequest(headers_, &response_, callback_.callback())); |
866 | 874 |
867 // Ack the request. | 875 // Ack the request. |
868 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); | 876 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); |
869 EXPECT_EQ(ERR_IO_PENDING, stream_->ReadResponseHeaders(callback_.callback())); | 877 EXPECT_THAT(stream_->ReadResponseHeaders(callback_.callback()), |
| 878 IsError(ERR_IO_PENDING)); |
870 | 879 |
871 // The test setup defaults handshake to be confirmed. Manually set | 880 // The test setup defaults handshake to be confirmed. Manually set |
872 // it to be not confirmed. | 881 // it to be not confirmed. |
873 // Granular errors shouldn't be reported if handshake not confirmed. | 882 // Granular errors shouldn't be reported if handshake not confirmed. |
874 QuicHttpStreamPeer::SetHandshakeConfirmed(stream_.get(), false); | 883 QuicHttpStreamPeer::SetHandshakeConfirmed(stream_.get(), false); |
875 | 884 |
876 EXPECT_FALSE(QuicHttpStreamPeer::WasHandshakeConfirmed(stream_.get())); | 885 EXPECT_FALSE(QuicHttpStreamPeer::WasHandshakeConfirmed(stream_.get())); |
877 QuicConnectionCloseFrame frame; | 886 QuicConnectionCloseFrame frame; |
878 frame.error_code = QUIC_PEER_GOING_AWAY; | 887 frame.error_code = QUIC_PEER_GOING_AWAY; |
879 session_->connection()->OnConnectionCloseFrame(frame); | 888 session_->connection()->OnConnectionCloseFrame(frame); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
924 | 933 |
925 Initialize(); | 934 Initialize(); |
926 | 935 |
927 std::vector<std::unique_ptr<UploadElementReader>> element_readers; | 936 std::vector<std::unique_ptr<UploadElementReader>> element_readers; |
928 element_readers.push_back(base::WrapUnique( | 937 element_readers.push_back(base::WrapUnique( |
929 new UploadBytesElementReader(kUploadData, strlen(kUploadData)))); | 938 new UploadBytesElementReader(kUploadData, strlen(kUploadData)))); |
930 ElementsUploadDataStream upload_data_stream(std::move(element_readers), 0); | 939 ElementsUploadDataStream upload_data_stream(std::move(element_readers), 0); |
931 request_.method = "POST"; | 940 request_.method = "POST"; |
932 request_.url = GURL("http://www.example.org/"); | 941 request_.url = GURL("http://www.example.org/"); |
933 request_.upload_data_stream = &upload_data_stream; | 942 request_.upload_data_stream = &upload_data_stream; |
934 ASSERT_EQ(OK, request_.upload_data_stream->Init(CompletionCallback())); | 943 ASSERT_THAT(request_.upload_data_stream->Init(CompletionCallback()), IsOk()); |
935 | 944 |
936 EXPECT_EQ(OK, | 945 EXPECT_EQ(OK, |
937 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 946 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
938 net_log_.bound(), callback_.callback())); | 947 net_log_.bound(), callback_.callback())); |
939 EXPECT_EQ(OK, | 948 EXPECT_EQ(OK, |
940 stream_->SendRequest(headers_, &response_, callback_.callback())); | 949 stream_->SendRequest(headers_, &response_, callback_.callback())); |
941 | 950 |
942 // Ack both packets in the request. | 951 // Ack both packets in the request. |
943 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); | 952 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); |
944 | 953 |
945 // Send the response headers (but not the body). | 954 // Send the response headers (but not the body). |
946 SetResponse("200 OK", string()); | 955 SetResponse("200 OK", string()); |
947 size_t spdy_response_headers_frame_length; | 956 size_t spdy_response_headers_frame_length; |
948 ProcessPacket(ConstructResponseHeadersPacket( | 957 ProcessPacket(ConstructResponseHeadersPacket( |
949 2, !kFin, &spdy_response_headers_frame_length)); | 958 2, !kFin, &spdy_response_headers_frame_length)); |
950 | 959 |
951 // The headers have arrived, but they are delivered asynchronously. | 960 // The headers have arrived, but they are delivered asynchronously. |
952 EXPECT_EQ(ERR_IO_PENDING, stream_->ReadResponseHeaders(callback_.callback())); | 961 EXPECT_THAT(stream_->ReadResponseHeaders(callback_.callback()), |
953 EXPECT_EQ(OK, callback_.WaitForResult()); | 962 IsError(ERR_IO_PENDING)); |
| 963 EXPECT_THAT(callback_.WaitForResult(), IsOk()); |
954 ASSERT_TRUE(response_.headers.get()); | 964 ASSERT_TRUE(response_.headers.get()); |
955 EXPECT_EQ(200, response_.headers->response_code()); | 965 EXPECT_EQ(200, response_.headers->response_code()); |
956 EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); | 966 EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); |
957 | 967 |
958 // Send the response body. | 968 // Send the response body. |
959 const char kResponseBody[] = "Hello world!"; | 969 const char kResponseBody[] = "Hello world!"; |
960 ProcessPacket(ConstructServerDataPacket(3, false, kFin, 0, kResponseBody)); | 970 ProcessPacket(ConstructServerDataPacket(3, false, kFin, 0, kResponseBody)); |
961 // Since the body has already arrived, this should return immediately. | 971 // Since the body has already arrived, this should return immediately. |
962 EXPECT_EQ(static_cast<int>(strlen(kResponseBody)), | 972 EXPECT_EQ(static_cast<int>(strlen(kResponseBody)), |
963 stream_->ReadResponseBody(read_buffer_.get(), read_buffer_->size(), | 973 stream_->ReadResponseBody(read_buffer_.get(), read_buffer_->size(), |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 ASSERT_EQ(OK, request_.upload_data_stream->Init( | 1008 ASSERT_EQ(OK, request_.upload_data_stream->Init( |
999 TestCompletionCallback().callback())); | 1009 TestCompletionCallback().callback())); |
1000 | 1010 |
1001 ASSERT_EQ(OK, | 1011 ASSERT_EQ(OK, |
1002 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 1012 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
1003 net_log_.bound(), callback_.callback())); | 1013 net_log_.bound(), callback_.callback())); |
1004 ASSERT_EQ(ERR_IO_PENDING, | 1014 ASSERT_EQ(ERR_IO_PENDING, |
1005 stream_->SendRequest(headers_, &response_, callback_.callback())); | 1015 stream_->SendRequest(headers_, &response_, callback_.callback())); |
1006 | 1016 |
1007 upload_data_stream.AppendData(kUploadData, chunk_size, true); | 1017 upload_data_stream.AppendData(kUploadData, chunk_size, true); |
1008 EXPECT_EQ(OK, callback_.WaitForResult()); | 1018 EXPECT_THAT(callback_.WaitForResult(), IsOk()); |
1009 | 1019 |
1010 // Ack both packets in the request. | 1020 // Ack both packets in the request. |
1011 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); | 1021 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); |
1012 | 1022 |
1013 // Send the response headers (but not the body). | 1023 // Send the response headers (but not the body). |
1014 SetResponse("200 OK", string()); | 1024 SetResponse("200 OK", string()); |
1015 size_t spdy_response_headers_frame_length; | 1025 size_t spdy_response_headers_frame_length; |
1016 ProcessPacket(ConstructResponseHeadersPacket( | 1026 ProcessPacket(ConstructResponseHeadersPacket( |
1017 2, !kFin, &spdy_response_headers_frame_length)); | 1027 2, !kFin, &spdy_response_headers_frame_length)); |
1018 | 1028 |
1019 // The headers have arrived, but they are delivered asynchronously | 1029 // The headers have arrived, but they are delivered asynchronously |
1020 EXPECT_EQ(ERR_IO_PENDING, stream_->ReadResponseHeaders(callback_.callback())); | 1030 EXPECT_THAT(stream_->ReadResponseHeaders(callback_.callback()), |
1021 EXPECT_EQ(OK, callback_.WaitForResult()); | 1031 IsError(ERR_IO_PENDING)); |
| 1032 EXPECT_THAT(callback_.WaitForResult(), IsOk()); |
1022 ASSERT_TRUE(response_.headers.get()); | 1033 ASSERT_TRUE(response_.headers.get()); |
1023 EXPECT_EQ(200, response_.headers->response_code()); | 1034 EXPECT_EQ(200, response_.headers->response_code()); |
1024 EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); | 1035 EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); |
1025 | 1036 |
1026 // Send the response body. | 1037 // Send the response body. |
1027 const char kResponseBody[] = "Hello world!"; | 1038 const char kResponseBody[] = "Hello world!"; |
1028 ProcessPacket(ConstructServerDataPacket( | 1039 ProcessPacket(ConstructServerDataPacket( |
1029 3, false, kFin, response_data_.length(), kResponseBody)); | 1040 3, false, kFin, response_data_.length(), kResponseBody)); |
1030 | 1041 |
1031 // Since the body has already arrived, this should return immediately. | 1042 // Since the body has already arrived, this should return immediately. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1067 ASSERT_EQ(OK, request_.upload_data_stream->Init( | 1078 ASSERT_EQ(OK, request_.upload_data_stream->Init( |
1068 TestCompletionCallback().callback())); | 1079 TestCompletionCallback().callback())); |
1069 | 1080 |
1070 ASSERT_EQ(OK, | 1081 ASSERT_EQ(OK, |
1071 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 1082 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
1072 net_log_.bound(), callback_.callback())); | 1083 net_log_.bound(), callback_.callback())); |
1073 ASSERT_EQ(ERR_IO_PENDING, | 1084 ASSERT_EQ(ERR_IO_PENDING, |
1074 stream_->SendRequest(headers_, &response_, callback_.callback())); | 1085 stream_->SendRequest(headers_, &response_, callback_.callback())); |
1075 | 1086 |
1076 upload_data_stream.AppendData(nullptr, 0, true); | 1087 upload_data_stream.AppendData(nullptr, 0, true); |
1077 EXPECT_EQ(OK, callback_.WaitForResult()); | 1088 EXPECT_THAT(callback_.WaitForResult(), IsOk()); |
1078 | 1089 |
1079 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); | 1090 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); |
1080 | 1091 |
1081 // Send the response headers (but not the body). | 1092 // Send the response headers (but not the body). |
1082 SetResponse("200 OK", string()); | 1093 SetResponse("200 OK", string()); |
1083 size_t spdy_response_headers_frame_length; | 1094 size_t spdy_response_headers_frame_length; |
1084 ProcessPacket(ConstructResponseHeadersPacket( | 1095 ProcessPacket(ConstructResponseHeadersPacket( |
1085 2, !kFin, &spdy_response_headers_frame_length)); | 1096 2, !kFin, &spdy_response_headers_frame_length)); |
1086 | 1097 |
1087 // The headers have arrived, but they are delivered asynchronously | 1098 // The headers have arrived, but they are delivered asynchronously |
1088 EXPECT_EQ(ERR_IO_PENDING, stream_->ReadResponseHeaders(callback_.callback())); | 1099 EXPECT_THAT(stream_->ReadResponseHeaders(callback_.callback()), |
1089 EXPECT_EQ(OK, callback_.WaitForResult()); | 1100 IsError(ERR_IO_PENDING)); |
| 1101 EXPECT_THAT(callback_.WaitForResult(), IsOk()); |
1090 ASSERT_TRUE(response_.headers.get()); | 1102 ASSERT_TRUE(response_.headers.get()); |
1091 EXPECT_EQ(200, response_.headers->response_code()); | 1103 EXPECT_EQ(200, response_.headers->response_code()); |
1092 EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); | 1104 EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); |
1093 | 1105 |
1094 // Send the response body. | 1106 // Send the response body. |
1095 const char kResponseBody[] = "Hello world!"; | 1107 const char kResponseBody[] = "Hello world!"; |
1096 ProcessPacket(ConstructServerDataPacket( | 1108 ProcessPacket(ConstructServerDataPacket( |
1097 3, false, kFin, response_data_.length(), kResponseBody)); | 1109 3, false, kFin, response_data_.length(), kResponseBody)); |
1098 | 1110 |
1099 // The body has arrived, but it is delivered asynchronously | 1111 // The body has arrived, but it is delivered asynchronously |
(...skipping 30 matching lines...) Expand all Loading... |
1130 ASSERT_EQ(OK, request_.upload_data_stream->Init( | 1142 ASSERT_EQ(OK, request_.upload_data_stream->Init( |
1131 TestCompletionCallback().callback())); | 1143 TestCompletionCallback().callback())); |
1132 | 1144 |
1133 ASSERT_EQ(OK, | 1145 ASSERT_EQ(OK, |
1134 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 1146 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
1135 net_log_.bound(), callback_.callback())); | 1147 net_log_.bound(), callback_.callback())); |
1136 ASSERT_EQ(ERR_IO_PENDING, | 1148 ASSERT_EQ(ERR_IO_PENDING, |
1137 stream_->SendRequest(headers_, &response_, callback_.callback())); | 1149 stream_->SendRequest(headers_, &response_, callback_.callback())); |
1138 | 1150 |
1139 upload_data_stream.AppendData(nullptr, 0, true); | 1151 upload_data_stream.AppendData(nullptr, 0, true); |
1140 EXPECT_EQ(OK, callback_.WaitForResult()); | 1152 EXPECT_THAT(callback_.WaitForResult(), IsOk()); |
1141 | 1153 |
1142 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); | 1154 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); |
1143 | 1155 |
1144 // Send the response headers (but not the body). | 1156 // Send the response headers (but not the body). |
1145 SetResponse("200 OK", string()); | 1157 SetResponse("200 OK", string()); |
1146 size_t spdy_response_headers_frame_length; | 1158 size_t spdy_response_headers_frame_length; |
1147 ProcessPacket(ConstructResponseHeadersPacket( | 1159 ProcessPacket(ConstructResponseHeadersPacket( |
1148 2, !kFin, &spdy_response_headers_frame_length)); | 1160 2, !kFin, &spdy_response_headers_frame_length)); |
1149 | 1161 |
1150 // The headers have arrived, but they are delivered asynchronously | 1162 // The headers have arrived, but they are delivered asynchronously |
1151 EXPECT_EQ(ERR_IO_PENDING, stream_->ReadResponseHeaders(callback_.callback())); | 1163 EXPECT_THAT(stream_->ReadResponseHeaders(callback_.callback()), |
1152 EXPECT_EQ(OK, callback_.WaitForResult()); | 1164 IsError(ERR_IO_PENDING)); |
| 1165 EXPECT_THAT(callback_.WaitForResult(), IsOk()); |
1153 ASSERT_TRUE(response_.headers.get()); | 1166 ASSERT_TRUE(response_.headers.get()); |
1154 EXPECT_EQ(200, response_.headers->response_code()); | 1167 EXPECT_EQ(200, response_.headers->response_code()); |
1155 EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); | 1168 EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); |
1156 | 1169 |
1157 // Send the response body. | 1170 // Send the response body. |
1158 const char kResponseBody[] = "Hello world!"; | 1171 const char kResponseBody[] = "Hello world!"; |
1159 ProcessPacket(ConstructServerDataPacket( | 1172 ProcessPacket(ConstructServerDataPacket( |
1160 3, false, kFin, response_data_.length(), kResponseBody)); | 1173 3, false, kFin, response_data_.length(), kResponseBody)); |
1161 | 1174 |
1162 // The body has arrived, but it is delivered asynchronously | 1175 // The body has arrived, but it is delivered asynchronously |
(...skipping 26 matching lines...) Expand all Loading... |
1189 request_.url = GURL("http://www.example.org/"); | 1202 request_.url = GURL("http://www.example.org/"); |
1190 | 1203 |
1191 EXPECT_EQ(OK, | 1204 EXPECT_EQ(OK, |
1192 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 1205 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
1193 net_log_.bound(), callback_.callback())); | 1206 net_log_.bound(), callback_.callback())); |
1194 EXPECT_EQ(OK, | 1207 EXPECT_EQ(OK, |
1195 stream_->SendRequest(headers_, &response_, callback_.callback())); | 1208 stream_->SendRequest(headers_, &response_, callback_.callback())); |
1196 | 1209 |
1197 // Ack the request. | 1210 // Ack the request. |
1198 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); | 1211 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); |
1199 EXPECT_EQ(ERR_IO_PENDING, stream_->ReadResponseHeaders(callback_.callback())); | 1212 EXPECT_THAT(stream_->ReadResponseHeaders(callback_.callback()), |
| 1213 IsError(ERR_IO_PENDING)); |
1200 | 1214 |
1201 // Send the response with a body. | 1215 // Send the response with a body. |
1202 SetResponse("404 OK", "hello world!"); | 1216 SetResponse("404 OK", "hello world!"); |
1203 // In the course of processing this packet, the QuicHttpStream close itself. | 1217 // In the course of processing this packet, the QuicHttpStream close itself. |
1204 ProcessPacket(ConstructResponseHeadersPacket(2, kFin, nullptr)); | 1218 ProcessPacket(ConstructResponseHeadersPacket(2, kFin, nullptr)); |
1205 | 1219 |
1206 base::RunLoop().RunUntilIdle(); | 1220 base::RunLoop().RunUntilIdle(); |
1207 | 1221 |
1208 EXPECT_TRUE(AtEof()); | 1222 EXPECT_TRUE(AtEof()); |
1209 | 1223 |
(...skipping 28 matching lines...) Expand all Loading... |
1238 | 1252 |
1239 EXPECT_EQ(OK, | 1253 EXPECT_EQ(OK, |
1240 stream_->SendRequest(headers_, &response_, callback_.callback())); | 1254 stream_->SendRequest(headers_, &response_, callback_.callback())); |
1241 | 1255 |
1242 // Check that priority has now dropped back to MEDIUM. | 1256 // Check that priority has now dropped back to MEDIUM. |
1243 DCHECK_EQ(MEDIUM, | 1257 DCHECK_EQ(MEDIUM, |
1244 ConvertQuicPriorityToRequestPriority(reliable_stream->priority())); | 1258 ConvertQuicPriorityToRequestPriority(reliable_stream->priority())); |
1245 | 1259 |
1246 // Ack the request. | 1260 // Ack the request. |
1247 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); | 1261 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); |
1248 EXPECT_EQ(ERR_IO_PENDING, stream_->ReadResponseHeaders(callback_.callback())); | 1262 EXPECT_THAT(stream_->ReadResponseHeaders(callback_.callback()), |
| 1263 IsError(ERR_IO_PENDING)); |
1249 | 1264 |
1250 // Send the response with a body. | 1265 // Send the response with a body. |
1251 SetResponse("404 OK", "hello world!"); | 1266 SetResponse("404 OK", "hello world!"); |
1252 // In the course of processing this packet, the QuicHttpStream close itself. | 1267 // In the course of processing this packet, the QuicHttpStream close itself. |
1253 ProcessPacket(ConstructResponseHeadersPacket(2, kFin, nullptr)); | 1268 ProcessPacket(ConstructResponseHeadersPacket(2, kFin, nullptr)); |
1254 | 1269 |
1255 base::RunLoop().RunUntilIdle(); | 1270 base::RunLoop().RunUntilIdle(); |
1256 | 1271 |
1257 EXPECT_TRUE(AtEof()); | 1272 EXPECT_TRUE(AtEof()); |
1258 | 1273 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1382 // with the promised stream. | 1397 // with the promised stream. |
1383 EXPECT_EQ(OK, promised_stream_->SendRequest(headers_, &response_, | 1398 EXPECT_EQ(OK, promised_stream_->SendRequest(headers_, &response_, |
1384 callback_.callback())); | 1399 callback_.callback())); |
1385 | 1400 |
1386 EXPECT_EQ( | 1401 EXPECT_EQ( |
1387 QuicHttpStreamPeer::GetQuicChromiumClientStream(promised_stream_.get()) | 1402 QuicHttpStreamPeer::GetQuicChromiumClientStream(promised_stream_.get()) |
1388 ->id(), | 1403 ->id(), |
1389 promise_id_); | 1404 promise_id_); |
1390 | 1405 |
1391 // The headers will be immediately available. | 1406 // The headers will be immediately available. |
1392 EXPECT_EQ(OK, promised_stream_->ReadResponseHeaders(callback_.callback())); | 1407 EXPECT_THAT(promised_stream_->ReadResponseHeaders(callback_.callback()), |
| 1408 IsOk()); |
1393 | 1409 |
1394 // As will be the body. | 1410 // As will be the body. |
1395 EXPECT_EQ( | 1411 EXPECT_EQ( |
1396 static_cast<int>(strlen(kResponseBody)), | 1412 static_cast<int>(strlen(kResponseBody)), |
1397 promised_stream_->ReadResponseBody( | 1413 promised_stream_->ReadResponseBody( |
1398 read_buffer_.get(), read_buffer_->size(), callback_.callback())); | 1414 read_buffer_.get(), read_buffer_->size(), callback_.callback())); |
1399 EXPECT_TRUE(promised_stream_->IsResponseBodyComplete()); | 1415 EXPECT_TRUE(promised_stream_->IsResponseBodyComplete()); |
1400 EXPECT_TRUE(AtEof()); | 1416 EXPECT_TRUE(AtEof()); |
1401 | 1417 |
1402 EXPECT_EQ(0, stream_->GetTotalSentBytes()); | 1418 EXPECT_EQ(0, stream_->GetTotalSentBytes()); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1446 // Receive the promised response body. | 1462 // Receive the promised response body. |
1447 const char kResponseBody[] = "Hello world!"; | 1463 const char kResponseBody[] = "Hello world!"; |
1448 ProcessPacket(InnerConstructDataPacket(2, promise_id_, false, kFin, 0, | 1464 ProcessPacket(InnerConstructDataPacket(2, promise_id_, false, kFin, 0, |
1449 kResponseBody, &server_maker_)); | 1465 kResponseBody, &server_maker_)); |
1450 | 1466 |
1451 base::RunLoop().RunUntilIdle(); | 1467 base::RunLoop().RunUntilIdle(); |
1452 | 1468 |
1453 // Rendezvous should have succeeded now, so the promised stream | 1469 // Rendezvous should have succeeded now, so the promised stream |
1454 // should point at our push stream, and we should be able read | 1470 // should point at our push stream, and we should be able read |
1455 // headers and data from it. | 1471 // headers and data from it. |
1456 EXPECT_EQ(OK, callback_.WaitForResult()); | 1472 EXPECT_THAT(callback_.WaitForResult(), IsOk()); |
1457 | 1473 |
1458 EXPECT_EQ( | 1474 EXPECT_EQ( |
1459 QuicHttpStreamPeer::GetQuicChromiumClientStream(promised_stream_.get()) | 1475 QuicHttpStreamPeer::GetQuicChromiumClientStream(promised_stream_.get()) |
1460 ->id(), | 1476 ->id(), |
1461 promise_id_); | 1477 promise_id_); |
1462 | 1478 |
1463 EXPECT_EQ(OK, promised_stream_->ReadResponseHeaders(callback_.callback())); | 1479 EXPECT_THAT(promised_stream_->ReadResponseHeaders(callback_.callback()), |
| 1480 IsOk()); |
1464 | 1481 |
1465 EXPECT_EQ( | 1482 EXPECT_EQ( |
1466 static_cast<int>(strlen(kResponseBody)), | 1483 static_cast<int>(strlen(kResponseBody)), |
1467 promised_stream_->ReadResponseBody( | 1484 promised_stream_->ReadResponseBody( |
1468 read_buffer_.get(), read_buffer_->size(), callback_.callback())); | 1485 read_buffer_.get(), read_buffer_->size(), callback_.callback())); |
1469 | 1486 |
1470 // Callback should return | 1487 // Callback should return |
1471 EXPECT_TRUE(promised_stream_->IsResponseBodyComplete()); | 1488 EXPECT_TRUE(promised_stream_->IsResponseBodyComplete()); |
1472 EXPECT_TRUE(AtEof()); | 1489 EXPECT_TRUE(AtEof()); |
1473 | 1490 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1525 // with the promised stream. | 1542 // with the promised stream. |
1526 EXPECT_EQ(OK, promised_stream_->SendRequest(headers_, &response_, | 1543 EXPECT_EQ(OK, promised_stream_->SendRequest(headers_, &response_, |
1527 callback_.callback())); | 1544 callback_.callback())); |
1528 | 1545 |
1529 EXPECT_EQ( | 1546 EXPECT_EQ( |
1530 QuicHttpStreamPeer::GetQuicChromiumClientStream(promised_stream_.get()) | 1547 QuicHttpStreamPeer::GetQuicChromiumClientStream(promised_stream_.get()) |
1531 ->id(), | 1548 ->id(), |
1532 promise_id_); | 1549 promise_id_); |
1533 | 1550 |
1534 // The headers will be immediately available. | 1551 // The headers will be immediately available. |
1535 EXPECT_EQ(OK, promised_stream_->ReadResponseHeaders(callback_.callback())); | 1552 EXPECT_THAT(promised_stream_->ReadResponseHeaders(callback_.callback()), |
| 1553 IsOk()); |
1536 | 1554 |
1537 // As will be the body. | 1555 // As will be the body. |
1538 EXPECT_EQ( | 1556 EXPECT_EQ( |
1539 static_cast<int>(strlen(kResponseBody)), | 1557 static_cast<int>(strlen(kResponseBody)), |
1540 promised_stream_->ReadResponseBody( | 1558 promised_stream_->ReadResponseBody( |
1541 read_buffer_.get(), read_buffer_->size(), callback_.callback())); | 1559 read_buffer_.get(), read_buffer_->size(), callback_.callback())); |
1542 EXPECT_TRUE(promised_stream_->IsResponseBodyComplete()); | 1560 EXPECT_TRUE(promised_stream_->IsResponseBodyComplete()); |
1543 EXPECT_TRUE(AtEof()); | 1561 EXPECT_TRUE(AtEof()); |
1544 | 1562 |
1545 EXPECT_EQ(0, stream_->GetTotalSentBytes()); | 1563 EXPECT_EQ(0, stream_->GetTotalSentBytes()); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1621 // Receive the promised response body. | 1639 // Receive the promised response body. |
1622 const char kResponseBody[] = "Hello world!"; | 1640 const char kResponseBody[] = "Hello world!"; |
1623 ProcessPacket(InnerConstructDataPacket(2, promise_id_, false, kFin, 0, | 1641 ProcessPacket(InnerConstructDataPacket(2, promise_id_, false, kFin, 0, |
1624 kResponseBody, &server_maker_)); | 1642 kResponseBody, &server_maker_)); |
1625 | 1643 |
1626 base::RunLoop().RunUntilIdle(); | 1644 base::RunLoop().RunUntilIdle(); |
1627 | 1645 |
1628 // Rendezvous should have succeeded now, so the promised stream | 1646 // Rendezvous should have succeeded now, so the promised stream |
1629 // should point at our push stream, and we should be able read | 1647 // should point at our push stream, and we should be able read |
1630 // headers and data from it. | 1648 // headers and data from it. |
1631 EXPECT_EQ(OK, callback_.WaitForResult()); | 1649 EXPECT_THAT(callback_.WaitForResult(), IsOk()); |
1632 | 1650 |
1633 EXPECT_EQ( | 1651 EXPECT_EQ( |
1634 QuicHttpStreamPeer::GetQuicChromiumClientStream(promised_stream_.get()) | 1652 QuicHttpStreamPeer::GetQuicChromiumClientStream(promised_stream_.get()) |
1635 ->id(), | 1653 ->id(), |
1636 promise_id_); | 1654 promise_id_); |
1637 | 1655 |
1638 EXPECT_EQ(OK, promised_stream_->ReadResponseHeaders(callback_.callback())); | 1656 EXPECT_THAT(promised_stream_->ReadResponseHeaders(callback_.callback()), |
| 1657 IsOk()); |
1639 | 1658 |
1640 EXPECT_EQ( | 1659 EXPECT_EQ( |
1641 static_cast<int>(strlen(kResponseBody)), | 1660 static_cast<int>(strlen(kResponseBody)), |
1642 promised_stream_->ReadResponseBody( | 1661 promised_stream_->ReadResponseBody( |
1643 read_buffer_.get(), read_buffer_->size(), callback_.callback())); | 1662 read_buffer_.get(), read_buffer_->size(), callback_.callback())); |
1644 | 1663 |
1645 // Callback should return | 1664 // Callback should return |
1646 EXPECT_TRUE(promised_stream_->IsResponseBodyComplete()); | 1665 EXPECT_TRUE(promised_stream_->IsResponseBodyComplete()); |
1647 EXPECT_TRUE(AtEof()); | 1666 EXPECT_TRUE(AtEof()); |
1648 | 1667 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1706 response_headers_ = promised_response_.Clone(); | 1725 response_headers_ = promised_response_.Clone(); |
1707 size_t spdy_response_headers_frame_length; | 1726 size_t spdy_response_headers_frame_length; |
1708 ProcessPacket(InnerConstructResponseHeadersPacket( | 1727 ProcessPacket(InnerConstructResponseHeadersPacket( |
1709 1, promise_id_, false, &spdy_response_headers_frame_length)); | 1728 1, promise_id_, false, &spdy_response_headers_frame_length)); |
1710 | 1729 |
1711 base::RunLoop().RunUntilIdle(); | 1730 base::RunLoop().RunUntilIdle(); |
1712 | 1731 |
1713 // Rendezvous should have failed due to vary mismatch, so the | 1732 // Rendezvous should have failed due to vary mismatch, so the |
1714 // promised stream should have been aborted, and instead we have a | 1733 // promised stream should have been aborted, and instead we have a |
1715 // new, regular client initiated stream. | 1734 // new, regular client initiated stream. |
1716 EXPECT_EQ(OK, callback_.WaitForResult()); | 1735 EXPECT_THAT(callback_.WaitForResult(), IsOk()); |
1717 | 1736 |
1718 // Not a server-initiated stream. | 1737 // Not a server-initiated stream. |
1719 EXPECT_NE( | 1738 EXPECT_NE( |
1720 QuicHttpStreamPeer::GetQuicChromiumClientStream(promised_stream_.get()) | 1739 QuicHttpStreamPeer::GetQuicChromiumClientStream(promised_stream_.get()) |
1721 ->id(), | 1740 ->id(), |
1722 promise_id_); | 1741 promise_id_); |
1723 | 1742 |
1724 // Instead, a new client-initiated stream. | 1743 // Instead, a new client-initiated stream. |
1725 EXPECT_EQ( | 1744 EXPECT_EQ( |
1726 QuicHttpStreamPeer::GetQuicChromiumClientStream(promised_stream_.get()) | 1745 QuicHttpStreamPeer::GetQuicChromiumClientStream(promised_stream_.get()) |
1727 ->id(), | 1746 ->id(), |
1728 stream_id_ + 2); | 1747 stream_id_ + 2); |
1729 | 1748 |
1730 // After rendezvous failure, the push stream has been cancelled. | 1749 // After rendezvous failure, the push stream has been cancelled. |
1731 EXPECT_EQ(session_->GetPromisedByUrl(promise_url_), nullptr); | 1750 EXPECT_EQ(session_->GetPromisedByUrl(promise_url_), nullptr); |
1732 | 1751 |
1733 // The rest of the test verifies that the retried as | 1752 // The rest of the test verifies that the retried as |
1734 // client-initiated version of |promised_stream_| works as intended. | 1753 // client-initiated version of |promised_stream_| works as intended. |
1735 | 1754 |
1736 // Ack the request. | 1755 // Ack the request. |
1737 ProcessPacket(ConstructServerAckPacket(2, 0, 0)); | 1756 ProcessPacket(ConstructServerAckPacket(2, 0, 0)); |
1738 | 1757 |
1739 SetResponse("404 Not Found", string()); | 1758 SetResponse("404 Not Found", string()); |
1740 size_t spdy_response_header_frame_length; | 1759 size_t spdy_response_header_frame_length; |
1741 ProcessPacket(InnerConstructResponseHeadersPacket( | 1760 ProcessPacket(InnerConstructResponseHeadersPacket( |
1742 3, stream_id_ + 2, kFin, &spdy_response_header_frame_length)); | 1761 3, stream_id_ + 2, kFin, &spdy_response_header_frame_length)); |
1743 | 1762 |
1744 base::RunLoop().RunUntilIdle(); | 1763 base::RunLoop().RunUntilIdle(); |
1745 | 1764 |
1746 EXPECT_EQ(OK, promised_stream_->ReadResponseHeaders(callback_.callback())); | 1765 EXPECT_THAT(promised_stream_->ReadResponseHeaders(callback_.callback()), |
| 1766 IsOk()); |
1747 ASSERT_TRUE(response_.headers.get()); | 1767 ASSERT_TRUE(response_.headers.get()); |
1748 EXPECT_EQ(404, response_.headers->response_code()); | 1768 EXPECT_EQ(404, response_.headers->response_code()); |
1749 EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); | 1769 EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); |
1750 EXPECT_FALSE(response_.response_time.is_null()); | 1770 EXPECT_FALSE(response_.response_time.is_null()); |
1751 EXPECT_FALSE(response_.request_time.is_null()); | 1771 EXPECT_FALSE(response_.request_time.is_null()); |
1752 | 1772 |
1753 // There is no body, so this should return immediately. | 1773 // There is no body, so this should return immediately. |
1754 EXPECT_EQ( | 1774 EXPECT_EQ( |
1755 0, promised_stream_->ReadResponseBody( | 1775 0, promised_stream_->ReadResponseBody( |
1756 read_buffer_.get(), read_buffer_->size(), callback_.callback())); | 1776 read_buffer_.get(), read_buffer_->size(), callback_.callback())); |
(...skipping 26 matching lines...) Expand all Loading... |
1783 request_.url = GURL("http://www.example.org/"); | 1803 request_.url = GURL("http://www.example.org/"); |
1784 request_.upload_data_stream = &upload_data_stream; | 1804 request_.upload_data_stream = &upload_data_stream; |
1785 ASSERT_EQ(OK, request_.upload_data_stream->Init( | 1805 ASSERT_EQ(OK, request_.upload_data_stream->Init( |
1786 TestCompletionCallback().callback())); | 1806 TestCompletionCallback().callback())); |
1787 | 1807 |
1788 EXPECT_EQ(OK, | 1808 EXPECT_EQ(OK, |
1789 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 1809 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
1790 net_log_.bound(), callback_.callback())); | 1810 net_log_.bound(), callback_.callback())); |
1791 | 1811 |
1792 int result = stream_->SendRequest(headers_, &response_, callback_.callback()); | 1812 int result = stream_->SendRequest(headers_, &response_, callback_.callback()); |
1793 EXPECT_EQ(ERR_FAILED, result); | 1813 EXPECT_THAT(result, IsError(ERR_FAILED)); |
1794 | 1814 |
1795 EXPECT_TRUE(AtEof()); | 1815 EXPECT_TRUE(AtEof()); |
1796 | 1816 |
1797 // QuicHttpStream::GetTotalSent/ReceivedBytes includes only headers. | 1817 // QuicHttpStream::GetTotalSent/ReceivedBytes includes only headers. |
1798 EXPECT_EQ(static_cast<int64_t>(spdy_request_headers_frame_length), | 1818 EXPECT_EQ(static_cast<int64_t>(spdy_request_headers_frame_length), |
1799 stream_->GetTotalSentBytes()); | 1819 stream_->GetTotalSentBytes()); |
1800 EXPECT_EQ(0, stream_->GetTotalReceivedBytes()); | 1820 EXPECT_EQ(0, stream_->GetTotalReceivedBytes()); |
1801 } | 1821 } |
1802 | 1822 |
1803 TEST_P(QuicHttpStreamTest, DataReadErrorAsynchronous) { | 1823 TEST_P(QuicHttpStreamTest, DataReadErrorAsynchronous) { |
(...skipping 15 matching lines...) Expand all Loading... |
1819 | 1839 |
1820 EXPECT_EQ(OK, | 1840 EXPECT_EQ(OK, |
1821 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 1841 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
1822 net_log_.bound(), callback_.callback())); | 1842 net_log_.bound(), callback_.callback())); |
1823 | 1843 |
1824 int result = stream_->SendRequest(headers_, &response_, callback_.callback()); | 1844 int result = stream_->SendRequest(headers_, &response_, callback_.callback()); |
1825 | 1845 |
1826 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); | 1846 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); |
1827 SetResponse("200 OK", string()); | 1847 SetResponse("200 OK", string()); |
1828 | 1848 |
1829 EXPECT_EQ(ERR_IO_PENDING, result); | 1849 EXPECT_THAT(result, IsError(ERR_IO_PENDING)); |
1830 EXPECT_EQ(ERR_FAILED, callback_.GetResult(result)); | 1850 EXPECT_THAT(callback_.GetResult(result), IsError(ERR_FAILED)); |
1831 | 1851 |
1832 EXPECT_TRUE(AtEof()); | 1852 EXPECT_TRUE(AtEof()); |
1833 | 1853 |
1834 // QuicHttpStream::GetTotalSent/ReceivedBytes includes only headers. | 1854 // QuicHttpStream::GetTotalSent/ReceivedBytes includes only headers. |
1835 EXPECT_EQ(static_cast<int64_t>(spdy_request_headers_frame_length), | 1855 EXPECT_EQ(static_cast<int64_t>(spdy_request_headers_frame_length), |
1836 stream_->GetTotalSentBytes()); | 1856 stream_->GetTotalSentBytes()); |
1837 EXPECT_EQ(0, stream_->GetTotalReceivedBytes()); | 1857 EXPECT_EQ(0, stream_->GetTotalReceivedBytes()); |
1838 } | 1858 } |
1839 | 1859 |
1840 } // namespace test | 1860 } // namespace test |
1841 } // namespace net | 1861 } // namespace net |
OLD | NEW |