OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/spdy/spdy_stream.h" | 5 #include "net/spdy/spdy_stream.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <cstddef> | 9 #include <cstddef> |
10 #include <limits> | 10 #include <limits> |
11 #include <memory> | 11 #include <memory> |
12 #include <string> | 12 #include <string> |
13 #include <utility> | 13 #include <utility> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
18 #include "base/strings/string_piece.h" | 18 #include "base/strings/string_piece.h" |
19 #include "net/base/completion_callback.h" | 19 #include "net/base/completion_callback.h" |
20 #include "net/base/request_priority.h" | 20 #include "net/base/request_priority.h" |
21 #include "net/log/test_net_log.h" | 21 #include "net/log/test_net_log.h" |
22 #include "net/log/test_net_log_entry.h" | 22 #include "net/log/test_net_log_entry.h" |
23 #include "net/log/test_net_log_util.h" | 23 #include "net/log/test_net_log_util.h" |
24 #include "net/socket/next_proto.h" | |
25 #include "net/socket/socket_test_util.h" | 24 #include "net/socket/socket_test_util.h" |
26 #include "net/spdy/buffered_spdy_framer.h" | 25 #include "net/spdy/buffered_spdy_framer.h" |
27 #include "net/spdy/spdy_http_utils.h" | 26 #include "net/spdy/spdy_http_utils.h" |
28 #include "net/spdy/spdy_protocol.h" | 27 #include "net/spdy/spdy_protocol.h" |
29 #include "net/spdy/spdy_session.h" | 28 #include "net/spdy/spdy_session.h" |
30 #include "net/spdy/spdy_stream_test_util.h" | 29 #include "net/spdy/spdy_stream_test_util.h" |
31 #include "net/spdy/spdy_test_util_common.h" | 30 #include "net/spdy/spdy_test_util_common.h" |
32 #include "net/test/gtest_util.h" | 31 #include "net/test/gtest_util.h" |
33 #include "testing/gmock/include/gmock/gmock.h" | 32 #include "testing/gmock/include/gmock/gmock.h" |
34 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1112 EXPECT_FALSE(stream->HasUrlFromHeaders()); | 1111 EXPECT_FALSE(stream->HasUrlFromHeaders()); |
1113 | 1112 |
1114 std::unique_ptr<SpdyHeaderBlock> headers( | 1113 std::unique_ptr<SpdyHeaderBlock> headers( |
1115 new SpdyHeaderBlock(spdy_util_.ConstructGetHeaderBlock(kStreamUrl))); | 1114 new SpdyHeaderBlock(spdy_util_.ConstructGetHeaderBlock(kStreamUrl))); |
1116 EXPECT_EQ(ERR_IO_PENDING, stream->SendRequestHeaders(std::move(headers), | 1115 EXPECT_EQ(ERR_IO_PENDING, stream->SendRequestHeaders(std::move(headers), |
1117 NO_MORE_DATA_TO_SEND)); | 1116 NO_MORE_DATA_TO_SEND)); |
1118 EXPECT_TRUE(stream->HasUrlFromHeaders()); | 1117 EXPECT_TRUE(stream->HasUrlFromHeaders()); |
1119 EXPECT_EQ(kStreamUrl, stream->GetUrlFromHeaders().spec()); | 1118 EXPECT_EQ(kStreamUrl, stream->GetUrlFromHeaders().spec()); |
1120 | 1119 |
1121 int64_t reply_frame_len = reply->size(); | 1120 int64_t reply_frame_len = reply->size(); |
1122 int64_t data_header_len = SpdyConstants::GetDataFrameMinimumSize( | 1121 int64_t data_header_len = SpdyConstants::GetDataFrameMinimumSize(HTTP2); |
1123 NextProtoToSpdyMajorVersion(kProtoHTTP2)); | |
1124 int64_t data_frame_len = data_header_len + kPostBodyLength; | 1122 int64_t data_frame_len = data_header_len + kPostBodyLength; |
1125 int64_t response_len = reply_frame_len + data_frame_len; | 1123 int64_t response_len = reply_frame_len + data_frame_len; |
1126 | 1124 |
1127 EXPECT_EQ(0, stream->raw_received_bytes()); | 1125 EXPECT_EQ(0, stream->raw_received_bytes()); |
1128 | 1126 |
1129 // SYN | 1127 // SYN |
1130 data.RunUntilPaused(); | 1128 data.RunUntilPaused(); |
1131 EXPECT_EQ(0, stream->raw_received_bytes()); | 1129 EXPECT_EQ(0, stream->raw_received_bytes()); |
1132 | 1130 |
1133 // REPLY | 1131 // REPLY |
1134 data.Resume(); | 1132 data.Resume(); |
1135 data.RunUntilPaused(); | 1133 data.RunUntilPaused(); |
1136 EXPECT_EQ(reply_frame_len, stream->raw_received_bytes()); | 1134 EXPECT_EQ(reply_frame_len, stream->raw_received_bytes()); |
1137 | 1135 |
1138 // DATA | 1136 // DATA |
1139 data.Resume(); | 1137 data.Resume(); |
1140 data.RunUntilPaused(); | 1138 data.RunUntilPaused(); |
1141 EXPECT_EQ(response_len, stream->raw_received_bytes()); | 1139 EXPECT_EQ(response_len, stream->raw_received_bytes()); |
1142 | 1140 |
1143 // FIN | 1141 // FIN |
1144 data.Resume(); | 1142 data.Resume(); |
1145 EXPECT_THAT(delegate.WaitForClose(), IsError(ERR_CONNECTION_CLOSED)); | 1143 EXPECT_THAT(delegate.WaitForClose(), IsError(ERR_CONNECTION_CLOSED)); |
1146 } | 1144 } |
1147 | 1145 |
1148 } // namespace test | 1146 } // namespace test |
1149 | 1147 |
1150 } // namespace net | 1148 } // namespace net |
OLD | NEW |