OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/http/http_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 | 120 |
121 std::vector<std::string> next_protos; | 121 std::vector<std::string> next_protos; |
122 next_protos.push_back("http/1.1"); | 122 next_protos.push_back("http/1.1"); |
123 next_protos.push_back("spdy/2"); | 123 next_protos.push_back("spdy/2"); |
124 next_protos.push_back("spdy/2.1"); | 124 next_protos.push_back("spdy/2.1"); |
125 | 125 |
126 switch (test_type_) { | 126 switch (test_type_) { |
127 case SPDYNPN: | 127 case SPDYNPN: |
128 session_->http_server_properties()->SetAlternateProtocol( | 128 session_->http_server_properties()->SetAlternateProtocol( |
129 HostPortPair("www.google.com", 80), 443, | 129 HostPortPair("www.google.com", 80), 443, |
130 NPN_SPDY_2); | 130 NPN_SPDY_21); |
131 HttpStreamFactory::set_use_alternate_protocols(true); | 131 HttpStreamFactory::set_use_alternate_protocols(true); |
132 HttpStreamFactory::set_next_protos(next_protos); | 132 HttpStreamFactory::set_next_protos(next_protos); |
133 break; | 133 break; |
134 case SPDYNOSSL: | 134 case SPDYNOSSL: |
135 HttpStreamFactory::set_force_spdy_over_ssl(false); | 135 HttpStreamFactory::set_force_spdy_over_ssl(false); |
136 HttpStreamFactory::set_force_spdy_always(true); | 136 HttpStreamFactory::set_force_spdy_always(true); |
137 break; | 137 break; |
138 case SPDYSSL: | 138 case SPDYSSL: |
139 HttpStreamFactory::set_force_spdy_over_ssl(true); | 139 HttpStreamFactory::set_force_spdy_over_ssl(true); |
140 HttpStreamFactory::set_force_spdy_always(true); | 140 HttpStreamFactory::set_force_spdy_always(true); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 VerifyDataConsumed(); | 227 VerifyDataConsumed(); |
228 } | 228 } |
229 | 229 |
230 void AddData(StaticSocketDataProvider* data) { | 230 void AddData(StaticSocketDataProvider* data) { |
231 DCHECK(!deterministic_); | 231 DCHECK(!deterministic_); |
232 data_vector_.push_back(data); | 232 data_vector_.push_back(data); |
233 linked_ptr<SSLSocketDataProvider> ssl_( | 233 linked_ptr<SSLSocketDataProvider> ssl_( |
234 new SSLSocketDataProvider(true, OK)); | 234 new SSLSocketDataProvider(true, OK)); |
235 if (test_type_ == SPDYNPN) { | 235 if (test_type_ == SPDYNPN) { |
236 ssl_->next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 236 ssl_->next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
237 ssl_->next_proto = "spdy/2"; | 237 ssl_->next_proto = "spdy/2.1"; |
238 ssl_->was_npn_negotiated = true; | 238 ssl_->was_npn_negotiated = true; |
239 ssl_->protocol_negotiated = SSLClientSocket::kProtoSPDY2; | 239 ssl_->protocol_negotiated = SSLClientSocket::kProtoSPDY21; |
240 } | 240 } |
241 ssl_vector_.push_back(ssl_); | 241 ssl_vector_.push_back(ssl_); |
242 if (test_type_ == SPDYNPN || test_type_ == SPDYSSL) | 242 if (test_type_ == SPDYNPN || test_type_ == SPDYSSL) |
243 session_deps_->socket_factory->AddSSLSocketDataProvider(ssl_.get()); | 243 session_deps_->socket_factory->AddSSLSocketDataProvider(ssl_.get()); |
244 session_deps_->socket_factory->AddSocketDataProvider(data); | 244 session_deps_->socket_factory->AddSocketDataProvider(data); |
245 if (test_type_ == SPDYNPN) { | 245 if (test_type_ == SPDYNPN) { |
246 MockConnect never_finishing_connect(false, ERR_IO_PENDING); | 246 MockConnect never_finishing_connect(false, ERR_IO_PENDING); |
247 linked_ptr<StaticSocketDataProvider> | 247 linked_ptr<StaticSocketDataProvider> |
248 hanging_non_alternate_protocol_socket( | 248 hanging_non_alternate_protocol_socket( |
249 new StaticSocketDataProvider(NULL, 0, NULL, 0)); | 249 new StaticSocketDataProvider(NULL, 0, NULL, 0)); |
250 hanging_non_alternate_protocol_socket->set_connect_data( | 250 hanging_non_alternate_protocol_socket->set_connect_data( |
251 never_finishing_connect); | 251 never_finishing_connect); |
252 session_deps_->socket_factory->AddSocketDataProvider( | 252 session_deps_->socket_factory->AddSocketDataProvider( |
253 hanging_non_alternate_protocol_socket.get()); | 253 hanging_non_alternate_protocol_socket.get()); |
254 alternate_vector_.push_back(hanging_non_alternate_protocol_socket); | 254 alternate_vector_.push_back(hanging_non_alternate_protocol_socket); |
255 } | 255 } |
256 } | 256 } |
257 | 257 |
258 void AddDeterministicData(DeterministicSocketData* data) { | 258 void AddDeterministicData(DeterministicSocketData* data) { |
259 DCHECK(deterministic_); | 259 DCHECK(deterministic_); |
260 data_vector_.push_back(data); | 260 data_vector_.push_back(data); |
261 linked_ptr<SSLSocketDataProvider> ssl_( | 261 linked_ptr<SSLSocketDataProvider> ssl_( |
262 new SSLSocketDataProvider(true, OK)); | 262 new SSLSocketDataProvider(true, OK)); |
263 if (test_type_ == SPDYNPN) { | 263 if (test_type_ == SPDYNPN) { |
264 ssl_->next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 264 ssl_->next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
265 ssl_->next_proto = "spdy/2"; | 265 ssl_->next_proto = "spdy/2.1"; |
266 ssl_->was_npn_negotiated = true; | 266 ssl_->was_npn_negotiated = true; |
267 ssl_->protocol_negotiated = SSLClientSocket::kProtoSPDY2; | 267 ssl_->protocol_negotiated = SSLClientSocket::kProtoSPDY21; |
268 } | 268 } |
269 ssl_vector_.push_back(ssl_); | 269 ssl_vector_.push_back(ssl_); |
270 if (test_type_ == SPDYNPN || test_type_ == SPDYSSL) { | 270 if (test_type_ == SPDYNPN || test_type_ == SPDYSSL) { |
271 session_deps_->deterministic_socket_factory-> | 271 session_deps_->deterministic_socket_factory-> |
272 AddSSLSocketDataProvider(ssl_.get()); | 272 AddSSLSocketDataProvider(ssl_.get()); |
273 } | 273 } |
274 session_deps_->deterministic_socket_factory->AddSocketDataProvider(data); | 274 session_deps_->deterministic_socket_factory->AddSocketDataProvider(data); |
275 if (test_type_ == SPDYNPN) { | 275 if (test_type_ == SPDYNPN) { |
276 MockConnect never_finishing_connect(false, ERR_IO_PENDING); | 276 MockConnect never_finishing_connect(false, ERR_IO_PENDING); |
277 scoped_refptr<DeterministicSocketData> | 277 scoped_refptr<DeterministicSocketData> |
(...skipping 1600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1878 // enough number of WINDOW_UPDATEs to finish the first read and cause a | 1878 // enough number of WINDOW_UPDATEs to finish the first read and cause a |
1879 // write, leading to a complete write of request body; after that we send | 1879 // write, leading to a complete write of request body; after that we send |
1880 // a reply with a body, to cause a graceful shutdown. | 1880 // a reply with a body, to cause a graceful shutdown. |
1881 | 1881 |
1882 // TODO(agayev): develop a socket data provider where both, reads and | 1882 // TODO(agayev): develop a socket data provider where both, reads and |
1883 // writes are ordered so that writing tests like these are easy and rewrite | 1883 // writes are ordered so that writing tests like these are easy and rewrite |
1884 // all these tests using it. Right now we are working around the | 1884 // all these tests using it. Right now we are working around the |
1885 // limitations as described above and it's not deterministic, tests may | 1885 // limitations as described above and it's not deterministic, tests may |
1886 // fail under specific circumstances. | 1886 // fail under specific circumstances. |
1887 TEST_P(SpdyNetworkTransactionTest, WindowUpdateReceived) { | 1887 TEST_P(SpdyNetworkTransactionTest, WindowUpdateReceived) { |
1888 SpdySession::set_use_flow_control(true); | 1888 SpdySession::set_use_flow_control(SpdySession::kEnableFlowControl); |
1889 | 1889 |
1890 static int kFrameCount = 2; | 1890 static int kFrameCount = 2; |
1891 scoped_ptr<std::string> content( | 1891 scoped_ptr<std::string> content( |
1892 new std::string(kMaxSpdyFrameChunkSize, 'a')); | 1892 new std::string(kMaxSpdyFrameChunkSize, 'a')); |
1893 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyPost( | 1893 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyPost( |
1894 kMaxSpdyFrameChunkSize * kFrameCount, NULL, 0)); | 1894 kMaxSpdyFrameChunkSize * kFrameCount, NULL, 0)); |
1895 scoped_ptr<spdy::SpdyFrame> body( | 1895 scoped_ptr<spdy::SpdyFrame> body( |
1896 ConstructSpdyBodyFrame(1, content->c_str(), content->size(), false)); | 1896 ConstructSpdyBodyFrame(1, content->c_str(), content->size(), false)); |
1897 scoped_ptr<spdy::SpdyFrame> body_end( | 1897 scoped_ptr<spdy::SpdyFrame> body_end( |
1898 ConstructSpdyBodyFrame(1, content->c_str(), content->size(), true)); | 1898 ConstructSpdyBodyFrame(1, content->c_str(), content->size(), true)); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1949 EXPECT_EQ(OK, rv); | 1949 EXPECT_EQ(OK, rv); |
1950 | 1950 |
1951 SpdyHttpStream* stream = static_cast<SpdyHttpStream*>(trans->stream_.get()); | 1951 SpdyHttpStream* stream = static_cast<SpdyHttpStream*>(trans->stream_.get()); |
1952 ASSERT_TRUE(stream != NULL); | 1952 ASSERT_TRUE(stream != NULL); |
1953 ASSERT_TRUE(stream->stream() != NULL); | 1953 ASSERT_TRUE(stream->stream() != NULL); |
1954 EXPECT_EQ(static_cast<int>(spdy::kSpdyStreamInitialWindowSize) + | 1954 EXPECT_EQ(static_cast<int>(spdy::kSpdyStreamInitialWindowSize) + |
1955 kDeltaWindowSize * kDeltaCount - | 1955 kDeltaWindowSize * kDeltaCount - |
1956 kMaxSpdyFrameChunkSize * kFrameCount, | 1956 kMaxSpdyFrameChunkSize * kFrameCount, |
1957 stream->stream()->send_window_size()); | 1957 stream->stream()->send_window_size()); |
1958 helper.VerifyDataConsumed(); | 1958 helper.VerifyDataConsumed(); |
1959 SpdySession::set_use_flow_control(false); | 1959 |
| 1960 SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); |
1960 } | 1961 } |
1961 | 1962 |
1962 // Test that received data frames and sent WINDOW_UPDATE frames change | 1963 // Test that received data frames and sent WINDOW_UPDATE frames change |
1963 // the recv_window_size_ correctly. | 1964 // the recv_window_size_ correctly. |
1964 TEST_P(SpdyNetworkTransactionTest, WindowUpdateSent) { | 1965 TEST_P(SpdyNetworkTransactionTest, WindowUpdateSent) { |
1965 SpdySession::set_use_flow_control(true); | 1966 SpdySession::set_use_flow_control(SpdySession::kEnableFlowControl); |
1966 | 1967 |
1967 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 1968 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
1968 scoped_ptr<spdy::SpdyFrame> window_update( | 1969 scoped_ptr<spdy::SpdyFrame> window_update( |
1969 ConstructSpdyWindowUpdate(1, kUploadDataSize)); | 1970 ConstructSpdyWindowUpdate(1, kUploadDataSize)); |
1970 | 1971 |
1971 MockWrite writes[] = { | 1972 MockWrite writes[] = { |
1972 CreateMockWrite(*req), | 1973 CreateMockWrite(*req), |
1973 CreateMockWrite(*window_update), | 1974 CreateMockWrite(*window_update), |
1974 }; | 1975 }; |
1975 | 1976 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2032 data->CompleteRead(); | 2033 data->CompleteRead(); |
2033 | 2034 |
2034 // Force write of WINDOW_UPDATE which was scheduled during the above | 2035 // Force write of WINDOW_UPDATE which was scheduled during the above |
2035 // read. | 2036 // read. |
2036 MessageLoop::current()->RunAllPending(); | 2037 MessageLoop::current()->RunAllPending(); |
2037 | 2038 |
2038 // Read EOF. | 2039 // Read EOF. |
2039 data->CompleteRead(); | 2040 data->CompleteRead(); |
2040 | 2041 |
2041 helper.VerifyDataConsumed(); | 2042 helper.VerifyDataConsumed(); |
2042 SpdySession::set_use_flow_control(false); | 2043 |
| 2044 SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); |
2043 } | 2045 } |
2044 | 2046 |
2045 // Test that WINDOW_UPDATE frame causing overflow is handled correctly. We | 2047 // Test that WINDOW_UPDATE frame causing overflow is handled correctly. We |
2046 // use the same trick as in the above test to enforce our scenario. | 2048 // use the same trick as in the above test to enforce our scenario. |
2047 TEST_P(SpdyNetworkTransactionTest, WindowUpdateOverflow) { | 2049 TEST_P(SpdyNetworkTransactionTest, WindowUpdateOverflow) { |
2048 SpdySession::set_use_flow_control(true); | 2050 SpdySession::set_use_flow_control(SpdySession::kEnableFlowControl); |
2049 | 2051 |
2050 // number of full frames we hope to write (but will not, used to | 2052 // number of full frames we hope to write (but will not, used to |
2051 // set content-length header correctly) | 2053 // set content-length header correctly) |
2052 static int kFrameCount = 3; | 2054 static int kFrameCount = 3; |
2053 | 2055 |
2054 scoped_ptr<std::string> content( | 2056 scoped_ptr<std::string> content( |
2055 new std::string(kMaxSpdyFrameChunkSize, 'a')); | 2057 new std::string(kMaxSpdyFrameChunkSize, 'a')); |
2056 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyPost( | 2058 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyPost( |
2057 kMaxSpdyFrameChunkSize * kFrameCount, NULL, 0)); | 2059 kMaxSpdyFrameChunkSize * kFrameCount, NULL, 0)); |
2058 scoped_ptr<spdy::SpdyFrame> body( | 2060 scoped_ptr<spdy::SpdyFrame> body( |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2111 rv = callback.WaitForResult(); | 2113 rv = callback.WaitForResult(); |
2112 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, rv); | 2114 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, rv); |
2113 | 2115 |
2114 data->CompleteRead(); | 2116 data->CompleteRead(); |
2115 | 2117 |
2116 ASSERT_TRUE(helper.session() != NULL); | 2118 ASSERT_TRUE(helper.session() != NULL); |
2117 ASSERT_TRUE(helper.session()->spdy_session_pool() != NULL); | 2119 ASSERT_TRUE(helper.session()->spdy_session_pool() != NULL); |
2118 helper.session()->spdy_session_pool()->CloseAllSessions(); | 2120 helper.session()->spdy_session_pool()->CloseAllSessions(); |
2119 helper.VerifyDataConsumed(); | 2121 helper.VerifyDataConsumed(); |
2120 | 2122 |
2121 SpdySession::set_use_flow_control(false); | 2123 SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); |
2122 } | 2124 } |
2123 | 2125 |
2124 // Test that after hitting a send window size of 0, the write process | 2126 // Test that after hitting a send window size of 0, the write process |
2125 // stalls and upon receiving WINDOW_UPDATE frame write resumes. | 2127 // stalls and upon receiving WINDOW_UPDATE frame write resumes. |
2126 | 2128 |
2127 // This test constructs a POST request followed by enough data frames | 2129 // This test constructs a POST request followed by enough data frames |
2128 // containing 'a' that would make the window size 0, followed by another | 2130 // containing 'a' that would make the window size 0, followed by another |
2129 // data frame containing default content (which is "hello!") and this frame | 2131 // data frame containing default content (which is "hello!") and this frame |
2130 // also contains a FIN flag. DelayedSocketData is used to enforce all | 2132 // also contains a FIN flag. DelayedSocketData is used to enforce all |
2131 // writes go through before a read could happen. However, the last frame | 2133 // writes go through before a read could happen. However, the last frame |
2132 // ("hello!") is not supposed to go through since by the time its turn | 2134 // ("hello!") is not supposed to go through since by the time its turn |
2133 // arrives, window size is 0. At this point MessageLoop::Run() called via | 2135 // arrives, window size is 0. At this point MessageLoop::Run() called via |
2134 // callback would block. Therefore we call MessageLoop::RunAllPending() | 2136 // callback would block. Therefore we call MessageLoop::RunAllPending() |
2135 // which returns after performing all possible writes. We use DCHECKS to | 2137 // which returns after performing all possible writes. We use DCHECKS to |
2136 // ensure that last data frame is still there and stream has stalled. | 2138 // ensure that last data frame is still there and stream has stalled. |
2137 // After that, next read is artifically enforced, which causes a | 2139 // After that, next read is artifically enforced, which causes a |
2138 // WINDOW_UPDATE to be read and I/O process resumes. | 2140 // WINDOW_UPDATE to be read and I/O process resumes. |
2139 TEST_P(SpdyNetworkTransactionTest, FlowControlStallResume) { | 2141 TEST_P(SpdyNetworkTransactionTest, FlowControlStallResume) { |
2140 SpdySession::set_use_flow_control(true); | 2142 SpdySession::set_use_flow_control(SpdySession::kEnableFlowControl); |
2141 | 2143 |
2142 // Number of frames we need to send to zero out the window size: data | 2144 // Number of frames we need to send to zero out the window size: data |
2143 // frames plus SYN_STREAM plus the last data frame; also we need another | 2145 // frames plus SYN_STREAM plus the last data frame; also we need another |
2144 // data frame that we will send once the WINDOW_UPDATE is received, | 2146 // data frame that we will send once the WINDOW_UPDATE is received, |
2145 // therefore +3. | 2147 // therefore +3. |
2146 size_t nwrites = | 2148 size_t nwrites = |
2147 spdy::kSpdyStreamInitialWindowSize / kMaxSpdyFrameChunkSize + 3; | 2149 spdy::kSpdyStreamInitialWindowSize / kMaxSpdyFrameChunkSize + 3; |
2148 | 2150 |
2149 // Calculate last frame's size; 0 size data frame is legal. | 2151 // Calculate last frame's size; 0 size data frame is legal. |
2150 size_t last_frame_size = | 2152 size_t last_frame_size = |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2221 SpdyHttpStream* stream = static_cast<SpdyHttpStream*>(trans->stream_.get()); | 2223 SpdyHttpStream* stream = static_cast<SpdyHttpStream*>(trans->stream_.get()); |
2222 ASSERT_TRUE(stream != NULL); | 2224 ASSERT_TRUE(stream != NULL); |
2223 ASSERT_TRUE(stream->stream() != NULL); | 2225 ASSERT_TRUE(stream->stream() != NULL); |
2224 EXPECT_EQ(0, stream->stream()->send_window_size()); | 2226 EXPECT_EQ(0, stream->stream()->send_window_size()); |
2225 EXPECT_FALSE(stream->request_body_stream_->eof()); | 2227 EXPECT_FALSE(stream->request_body_stream_->eof()); |
2226 | 2228 |
2227 data->ForceNextRead(); // Read in WINDOW_UPDATE frame. | 2229 data->ForceNextRead(); // Read in WINDOW_UPDATE frame. |
2228 rv = callback.WaitForResult(); | 2230 rv = callback.WaitForResult(); |
2229 helper.VerifyDataConsumed(); | 2231 helper.VerifyDataConsumed(); |
2230 | 2232 |
2231 SpdySession::set_use_flow_control(false); | 2233 SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); |
2232 } | 2234 } |
2233 | 2235 |
2234 TEST_P(SpdyNetworkTransactionTest, CancelledTransaction) { | 2236 TEST_P(SpdyNetworkTransactionTest, CancelledTransaction) { |
2235 // Construct the request. | 2237 // Construct the request. |
2236 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 2238 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
2237 MockWrite writes[] = { | 2239 MockWrite writes[] = { |
2238 CreateMockWrite(*req), | 2240 CreateMockWrite(*req), |
2239 }; | 2241 }; |
2240 | 2242 |
2241 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 2243 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2958 // Verify the SYN_REPLY. | 2960 // Verify the SYN_REPLY. |
2959 EXPECT_TRUE(response.headers != NULL); | 2961 EXPECT_TRUE(response.headers != NULL); |
2960 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 2962 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
2961 | 2963 |
2962 // Verify the pushed stream. | 2964 // Verify the pushed stream. |
2963 EXPECT_TRUE(response2.headers != NULL); | 2965 EXPECT_TRUE(response2.headers != NULL); |
2964 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 2966 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
2965 } | 2967 } |
2966 | 2968 |
2967 TEST_P(SpdyNetworkTransactionTest, ServerPushMultipleDataFrameInterrupted) { | 2969 TEST_P(SpdyNetworkTransactionTest, ServerPushMultipleDataFrameInterrupted) { |
| 2970 SpdySession::set_use_flow_control(SpdySession::kDisableFlowControl); |
| 2971 |
2968 static const unsigned char kPushBodyFrame1[] = { | 2972 static const unsigned char kPushBodyFrame1[] = { |
2969 0x00, 0x00, 0x00, 0x02, // header, ID | 2973 0x00, 0x00, 0x00, 0x02, // header, ID |
2970 0x01, 0x00, 0x00, 0x1F, // FIN, length | 2974 0x01, 0x00, 0x00, 0x1F, // FIN, length |
2971 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | 2975 'p', 'u', 's', 'h', 'e', 'd' // "pushed" |
2972 }; | 2976 }; |
2973 static const char kPushBodyFrame2[] = " my darling"; | 2977 static const char kPushBodyFrame2[] = " my darling"; |
2974 static const char kPushBodyFrame3[] = " hello"; | 2978 static const char kPushBodyFrame3[] = " hello"; |
2975 static const char kPushBodyFrame4[] = " my baby"; | 2979 static const char kPushBodyFrame4[] = " my baby"; |
2976 | 2980 |
2977 scoped_ptr<spdy::SpdyFrame> | 2981 scoped_ptr<spdy::SpdyFrame> |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3019 &response2, | 3023 &response2, |
3020 expected_push_result); | 3024 expected_push_result); |
3021 | 3025 |
3022 // Verify the SYN_REPLY. | 3026 // Verify the SYN_REPLY. |
3023 EXPECT_TRUE(response.headers != NULL); | 3027 EXPECT_TRUE(response.headers != NULL); |
3024 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3028 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
3025 | 3029 |
3026 // Verify the pushed stream. | 3030 // Verify the pushed stream. |
3027 EXPECT_TRUE(response2.headers != NULL); | 3031 EXPECT_TRUE(response2.headers != NULL); |
3028 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 3032 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
| 3033 |
| 3034 SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); |
3029 } | 3035 } |
3030 | 3036 |
3031 TEST_P(SpdyNetworkTransactionTest, ServerPushInvalidAssociatedStreamID0) { | 3037 TEST_P(SpdyNetworkTransactionTest, ServerPushInvalidAssociatedStreamID0) { |
3032 scoped_ptr<spdy::SpdyFrame> | 3038 scoped_ptr<spdy::SpdyFrame> |
3033 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 3039 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
3034 scoped_ptr<spdy::SpdyFrame> | 3040 scoped_ptr<spdy::SpdyFrame> |
3035 stream1_body(ConstructSpdyBodyFrame(1, true)); | 3041 stream1_body(ConstructSpdyBodyFrame(1, true)); |
3036 scoped_ptr<spdy::SpdyFrame> | 3042 scoped_ptr<spdy::SpdyFrame> |
3037 stream2_rst(ConstructSpdyRstStream(2, spdy::INVALID_STREAM)); | 3043 stream2_rst(ConstructSpdyRstStream(2, spdy::INVALID_STREAM)); |
3038 MockWrite writes[] = { | 3044 MockWrite writes[] = { |
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3733 ++it) { | 3739 ++it) { |
3734 EXPECT_EQ(it->second, (*headers)[it->first]); | 3740 EXPECT_EQ(it->second, (*headers)[it->first]); |
3735 } | 3741 } |
3736 } | 3742 } |
3737 | 3743 |
3738 // Since we buffer the IO from the stream to the renderer, this test verifies | 3744 // Since we buffer the IO from the stream to the renderer, this test verifies |
3739 // that when we read out the maximum amount of data (e.g. we received 50 bytes | 3745 // that when we read out the maximum amount of data (e.g. we received 50 bytes |
3740 // on the network, but issued a Read for only 5 of those bytes) that the data | 3746 // on the network, but issued a Read for only 5 of those bytes) that the data |
3741 // flow still works correctly. | 3747 // flow still works correctly. |
3742 TEST_P(SpdyNetworkTransactionTest, BufferFull) { | 3748 TEST_P(SpdyNetworkTransactionTest, BufferFull) { |
| 3749 SpdySession::set_use_flow_control(SpdySession::kDisableFlowControl); |
| 3750 |
3743 spdy::SpdyFramer framer; | 3751 spdy::SpdyFramer framer; |
3744 | 3752 |
3745 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 3753 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
3746 MockWrite writes[] = { CreateMockWrite(*req) }; | 3754 MockWrite writes[] = { CreateMockWrite(*req) }; |
3747 | 3755 |
3748 // 2 data frames in a single read. | 3756 // 2 data frames in a single read. |
3749 scoped_ptr<spdy::SpdyFrame> data_frame_1( | 3757 scoped_ptr<spdy::SpdyFrame> data_frame_1( |
3750 framer.CreateDataFrame(1, "goodby", 6, spdy::DATA_FLAG_NONE)); | 3758 framer.CreateDataFrame(1, "goodby", 6, spdy::DATA_FLAG_NONE)); |
3751 scoped_ptr<spdy::SpdyFrame> data_frame_2( | 3759 scoped_ptr<spdy::SpdyFrame> data_frame_2( |
3752 framer.CreateDataFrame(1, "e worl", 6, spdy::DATA_FLAG_NONE)); | 3760 framer.CreateDataFrame(1, "e worl", 6, spdy::DATA_FLAG_NONE)); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3822 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the | 3830 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the |
3823 // MockClientSocketFactory) are still alive. | 3831 // MockClientSocketFactory) are still alive. |
3824 MessageLoop::current()->RunAllPending(); | 3832 MessageLoop::current()->RunAllPending(); |
3825 | 3833 |
3826 // Verify that we consumed all test data. | 3834 // Verify that we consumed all test data. |
3827 helper.VerifyDataConsumed(); | 3835 helper.VerifyDataConsumed(); |
3828 | 3836 |
3829 EXPECT_EQ(OK, out.rv); | 3837 EXPECT_EQ(OK, out.rv); |
3830 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 3838 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
3831 EXPECT_EQ("goodbye world", out.response_data); | 3839 EXPECT_EQ("goodbye world", out.response_data); |
| 3840 |
| 3841 SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); |
3832 } | 3842 } |
3833 | 3843 |
3834 // Verify that basic buffering works; when multiple data frames arrive | 3844 // Verify that basic buffering works; when multiple data frames arrive |
3835 // at the same time, ensure that we don't notify a read completion for | 3845 // at the same time, ensure that we don't notify a read completion for |
3836 // each data frame individually. | 3846 // each data frame individually. |
3837 TEST_P(SpdyNetworkTransactionTest, Buffering) { | 3847 TEST_P(SpdyNetworkTransactionTest, Buffering) { |
| 3848 SpdySession::set_use_flow_control(SpdySession::kDisableFlowControl); |
| 3849 |
3838 spdy::SpdyFramer framer; | 3850 spdy::SpdyFramer framer; |
3839 | 3851 |
3840 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 3852 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
3841 MockWrite writes[] = { CreateMockWrite(*req) }; | 3853 MockWrite writes[] = { CreateMockWrite(*req) }; |
3842 | 3854 |
3843 // 4 data frames in a single read. | 3855 // 4 data frames in a single read. |
3844 scoped_ptr<spdy::SpdyFrame> data_frame( | 3856 scoped_ptr<spdy::SpdyFrame> data_frame( |
3845 framer.CreateDataFrame(1, "message", 7, spdy::DATA_FLAG_NONE)); | 3857 framer.CreateDataFrame(1, "message", 7, spdy::DATA_FLAG_NONE)); |
3846 scoped_ptr<spdy::SpdyFrame> data_frame_fin( | 3858 scoped_ptr<spdy::SpdyFrame> data_frame_fin( |
3847 framer.CreateDataFrame(1, "message", 7, spdy::DATA_FLAG_FIN)); | 3859 framer.CreateDataFrame(1, "message", 7, spdy::DATA_FLAG_FIN)); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3919 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the | 3931 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the |
3920 // MockClientSocketFactory) are still alive. | 3932 // MockClientSocketFactory) are still alive. |
3921 MessageLoop::current()->RunAllPending(); | 3933 MessageLoop::current()->RunAllPending(); |
3922 | 3934 |
3923 // Verify that we consumed all test data. | 3935 // Verify that we consumed all test data. |
3924 helper.VerifyDataConsumed(); | 3936 helper.VerifyDataConsumed(); |
3925 | 3937 |
3926 EXPECT_EQ(OK, out.rv); | 3938 EXPECT_EQ(OK, out.rv); |
3927 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 3939 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
3928 EXPECT_EQ("messagemessagemessagemessage", out.response_data); | 3940 EXPECT_EQ("messagemessagemessagemessage", out.response_data); |
| 3941 |
| 3942 SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); |
3929 } | 3943 } |
3930 | 3944 |
3931 // Verify the case where we buffer data but read it after it has been buffered. | 3945 // Verify the case where we buffer data but read it after it has been buffered. |
3932 TEST_P(SpdyNetworkTransactionTest, BufferedAll) { | 3946 TEST_P(SpdyNetworkTransactionTest, BufferedAll) { |
3933 spdy::SpdyFramer framer; | 3947 spdy::SpdyFramer framer; |
3934 | 3948 |
3935 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 3949 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
3936 MockWrite writes[] = { CreateMockWrite(*req) }; | 3950 MockWrite writes[] = { CreateMockWrite(*req) }; |
3937 | 3951 |
3938 // 5 data frames in a single read. | 3952 // 5 data frames in a single read. |
(...skipping 1741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5680 << " Write index: " | 5694 << " Write index: " |
5681 << data->write_index(); | 5695 << data->write_index(); |
5682 | 5696 |
5683 // Verify the SYN_REPLY. | 5697 // Verify the SYN_REPLY. |
5684 HttpResponseInfo response = *trans->GetResponseInfo(); | 5698 HttpResponseInfo response = *trans->GetResponseInfo(); |
5685 EXPECT_TRUE(response.headers != NULL); | 5699 EXPECT_TRUE(response.headers != NULL); |
5686 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5700 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
5687 } | 5701 } |
5688 | 5702 |
5689 } // namespace net | 5703 } // namespace net |
OLD | NEW |