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" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "net/base/auth.h" | 12 #include "net/base/auth.h" |
13 #include "net/base/net_log_unittest.h" | 13 #include "net/base/net_log_unittest.h" |
14 #include "net/http/http_network_session_peer.h" | 14 #include "net/http/http_network_session_peer.h" |
15 #include "net/http/http_transaction_unittest.h" | 15 #include "net/http/http_transaction_unittest.h" |
16 #include "net/socket/client_socket_pool_base.h" | 16 #include "net/socket/client_socket_pool_base.h" |
17 #include "net/spdy/spdy_http_stream.h" | 17 #include "net/spdy/spdy_http_stream.h" |
18 #include "net/spdy/spdy_http_utils.h" | 18 #include "net/spdy/spdy_http_utils.h" |
19 #include "net/spdy/spdy_session.h" | 19 #include "net/spdy/spdy_session.h" |
20 #include "net/spdy/spdy_session_pool.h" | 20 #include "net/spdy/spdy_session_pool.h" |
21 #include "net/spdy/spdy_test_util.h" | 21 #include "net/spdy/spdy_test_util_spdy2.h" |
22 #include "net/url_request/url_request_test_util.h" | 22 #include "net/url_request/url_request_test_util.h" |
23 #include "testing/platform_test.h" | 23 #include "testing/platform_test.h" |
24 | 24 |
| 25 using namespace net::test_spdy2; |
| 26 |
25 //----------------------------------------------------------------------------- | 27 //----------------------------------------------------------------------------- |
26 | 28 |
27 namespace net { | 29 namespace net { |
28 | 30 |
29 enum SpdyNetworkTransactionTestTypes { | 31 enum SpdyNetworkTransactionSpdy2TestTypes { |
30 SPDYNPN, | 32 SPDYNPN, |
31 SPDYNOSSL, | 33 SPDYNOSSL, |
32 SPDYSSL, | 34 SPDYSSL, |
33 }; | 35 }; |
34 class SpdyNetworkTransactionTest | 36 class SpdyNetworkTransactionSpdy2Test |
35 : public ::testing::TestWithParam<SpdyNetworkTransactionTestTypes> { | 37 : public ::testing::TestWithParam<SpdyNetworkTransactionSpdy2TestTypes> { |
36 protected: | 38 protected: |
37 | 39 |
38 virtual void SetUp() { | 40 virtual void SetUp() { |
39 // By default, all tests turn off compression. | 41 // By default, all tests turn off compression. |
40 EnableCompression(false); | 42 EnableCompression(false); |
41 google_get_request_initialized_ = false; | 43 google_get_request_initialized_ = false; |
42 google_post_request_initialized_ = false; | 44 google_post_request_initialized_ = false; |
43 google_chunked_post_request_initialized_ = false; | 45 google_chunked_post_request_initialized_ = false; |
44 } | 46 } |
45 | 47 |
(...skipping 11 matching lines...) Expand all Loading... |
57 | 59 |
58 void EnableCompression(bool enabled) { | 60 void EnableCompression(bool enabled) { |
59 spdy::SpdyFramer::set_enable_compression_default(enabled); | 61 spdy::SpdyFramer::set_enable_compression_default(enabled); |
60 } | 62 } |
61 | 63 |
62 // A helper class that handles all the initial npn/ssl setup. | 64 // A helper class that handles all the initial npn/ssl setup. |
63 class NormalSpdyTransactionHelper { | 65 class NormalSpdyTransactionHelper { |
64 public: | 66 public: |
65 NormalSpdyTransactionHelper(const HttpRequestInfo& request, | 67 NormalSpdyTransactionHelper(const HttpRequestInfo& request, |
66 const BoundNetLog& log, | 68 const BoundNetLog& log, |
67 SpdyNetworkTransactionTestTypes test_type) | 69 SpdyNetworkTransactionSpdy2TestTypes test_type) |
68 : request_(request), | 70 : request_(request), |
69 session_deps_(new SpdySessionDependencies()), | 71 session_deps_(new SpdySessionDependencies()), |
70 session_(SpdySessionDependencies::SpdyCreateSession( | 72 session_(SpdySessionDependencies::SpdyCreateSession( |
71 session_deps_.get())), | 73 session_deps_.get())), |
72 log_(log), | 74 log_(log), |
73 test_type_(test_type), | 75 test_type_(test_type), |
74 deterministic_(false), | 76 deterministic_(false), |
75 spdy_enabled_(true) { | 77 spdy_enabled_(true) { |
76 switch (test_type_) { | 78 switch (test_type_) { |
77 case SPDYNOSSL: | 79 case SPDYNOSSL: |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 | 122 |
121 std::vector<std::string> next_protos; | 123 std::vector<std::string> next_protos; |
122 next_protos.push_back("http/1.1"); | 124 next_protos.push_back("http/1.1"); |
123 next_protos.push_back("spdy/2"); | 125 next_protos.push_back("spdy/2"); |
124 next_protos.push_back("spdy/2.1"); | 126 next_protos.push_back("spdy/2.1"); |
125 | 127 |
126 switch (test_type_) { | 128 switch (test_type_) { |
127 case SPDYNPN: | 129 case SPDYNPN: |
128 session_->http_server_properties()->SetAlternateProtocol( | 130 session_->http_server_properties()->SetAlternateProtocol( |
129 HostPortPair("www.google.com", 80), 443, | 131 HostPortPair("www.google.com", 80), 443, |
130 NPN_SPDY_21); | 132 NPN_SPDY_2); |
131 HttpStreamFactory::set_use_alternate_protocols(true); | 133 HttpStreamFactory::set_use_alternate_protocols(true); |
132 HttpStreamFactory::set_next_protos(next_protos); | 134 HttpStreamFactory::SetNextProtos(next_protos); |
133 break; | 135 break; |
134 case SPDYNOSSL: | 136 case SPDYNOSSL: |
135 HttpStreamFactory::set_force_spdy_over_ssl(false); | 137 HttpStreamFactory::set_force_spdy_over_ssl(false); |
136 HttpStreamFactory::set_force_spdy_always(true); | 138 HttpStreamFactory::set_force_spdy_always(true); |
137 break; | 139 break; |
138 case SPDYSSL: | 140 case SPDYSSL: |
139 HttpStreamFactory::set_force_spdy_over_ssl(true); | 141 HttpStreamFactory::set_force_spdy_over_ssl(true); |
140 HttpStreamFactory::set_force_spdy_always(true); | 142 HttpStreamFactory::set_force_spdy_always(true); |
141 break; | 143 break; |
142 default: | 144 default: |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 RunDefaultTest(); | 228 RunDefaultTest(); |
227 VerifyDataConsumed(); | 229 VerifyDataConsumed(); |
228 } | 230 } |
229 | 231 |
230 void AddData(StaticSocketDataProvider* data) { | 232 void AddData(StaticSocketDataProvider* data) { |
231 DCHECK(!deterministic_); | 233 DCHECK(!deterministic_); |
232 data_vector_.push_back(data); | 234 data_vector_.push_back(data); |
233 linked_ptr<SSLSocketDataProvider> ssl_( | 235 linked_ptr<SSLSocketDataProvider> ssl_( |
234 new SSLSocketDataProvider(ASYNC, OK)); | 236 new SSLSocketDataProvider(ASYNC, OK)); |
235 if (test_type_ == SPDYNPN) { | 237 if (test_type_ == SPDYNPN) { |
236 ssl_->SetNextProto(SSLClientSocket::kProtoSPDY21); | 238 ssl_->SetNextProto(SSLClientSocket::kProtoSPDY2); |
237 } | 239 } |
238 ssl_vector_.push_back(ssl_); | 240 ssl_vector_.push_back(ssl_); |
239 if (test_type_ == SPDYNPN || test_type_ == SPDYSSL) | 241 if (test_type_ == SPDYNPN || test_type_ == SPDYSSL) |
240 session_deps_->socket_factory->AddSSLSocketDataProvider(ssl_.get()); | 242 session_deps_->socket_factory->AddSSLSocketDataProvider(ssl_.get()); |
241 session_deps_->socket_factory->AddSocketDataProvider(data); | 243 session_deps_->socket_factory->AddSocketDataProvider(data); |
242 if (test_type_ == SPDYNPN) { | 244 if (test_type_ == SPDYNPN) { |
243 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); | 245 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); |
244 linked_ptr<StaticSocketDataProvider> | 246 linked_ptr<StaticSocketDataProvider> |
245 hanging_non_alternate_protocol_socket( | 247 hanging_non_alternate_protocol_socket( |
246 new StaticSocketDataProvider(NULL, 0, NULL, 0)); | 248 new StaticSocketDataProvider(NULL, 0, NULL, 0)); |
247 hanging_non_alternate_protocol_socket->set_connect_data( | 249 hanging_non_alternate_protocol_socket->set_connect_data( |
248 never_finishing_connect); | 250 never_finishing_connect); |
249 session_deps_->socket_factory->AddSocketDataProvider( | 251 session_deps_->socket_factory->AddSocketDataProvider( |
250 hanging_non_alternate_protocol_socket.get()); | 252 hanging_non_alternate_protocol_socket.get()); |
251 alternate_vector_.push_back(hanging_non_alternate_protocol_socket); | 253 alternate_vector_.push_back(hanging_non_alternate_protocol_socket); |
252 } | 254 } |
253 } | 255 } |
254 | 256 |
255 void AddDeterministicData(DeterministicSocketData* data) { | 257 void AddDeterministicData(DeterministicSocketData* data) { |
256 DCHECK(deterministic_); | 258 DCHECK(deterministic_); |
257 data_vector_.push_back(data); | 259 data_vector_.push_back(data); |
258 linked_ptr<SSLSocketDataProvider> ssl_( | 260 linked_ptr<SSLSocketDataProvider> ssl_( |
259 new SSLSocketDataProvider(ASYNC, OK)); | 261 new SSLSocketDataProvider(ASYNC, OK)); |
260 if (test_type_ == SPDYNPN) { | 262 if (test_type_ == SPDYNPN) { |
261 ssl_->SetNextProto(SSLClientSocket::kProtoSPDY21); | 263 ssl_->SetNextProto(SSLClientSocket::kProtoSPDY2); |
262 } | 264 } |
263 ssl_vector_.push_back(ssl_); | 265 ssl_vector_.push_back(ssl_); |
264 if (test_type_ == SPDYNPN || test_type_ == SPDYSSL) { | 266 if (test_type_ == SPDYNPN || test_type_ == SPDYSSL) { |
265 session_deps_->deterministic_socket_factory-> | 267 session_deps_->deterministic_socket_factory-> |
266 AddSSLSocketDataProvider(ssl_.get()); | 268 AddSSLSocketDataProvider(ssl_.get()); |
267 } | 269 } |
268 session_deps_->deterministic_socket_factory->AddSocketDataProvider(data); | 270 session_deps_->deterministic_socket_factory->AddSocketDataProvider(data); |
269 if (test_type_ == SPDYNPN) { | 271 if (test_type_ == SPDYNPN) { |
270 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); | 272 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); |
271 scoped_refptr<DeterministicSocketData> | 273 scoped_refptr<DeterministicSocketData> |
(...skipping 26 matching lines...) Expand all Loading... |
298 void ResetTrans() { trans_.reset(); } | 300 void ResetTrans() { trans_.reset(); } |
299 TransactionHelperResult& output() { return output_; } | 301 TransactionHelperResult& output() { return output_; } |
300 const HttpRequestInfo& request() const { return request_; } | 302 const HttpRequestInfo& request() const { return request_; } |
301 const scoped_refptr<HttpNetworkSession>& session() const { | 303 const scoped_refptr<HttpNetworkSession>& session() const { |
302 return session_; | 304 return session_; |
303 } | 305 } |
304 scoped_ptr<SpdySessionDependencies>& session_deps() { | 306 scoped_ptr<SpdySessionDependencies>& session_deps() { |
305 return session_deps_; | 307 return session_deps_; |
306 } | 308 } |
307 int port() const { return port_; } | 309 int port() const { return port_; } |
308 SpdyNetworkTransactionTestTypes test_type() const { return test_type_; } | 310 SpdyNetworkTransactionSpdy2TestTypes test_type() const { |
| 311 return test_type_; |
| 312 } |
309 | 313 |
310 private: | 314 private: |
311 typedef std::vector<StaticSocketDataProvider*> DataVector; | 315 typedef std::vector<StaticSocketDataProvider*> DataVector; |
312 typedef std::vector<linked_ptr<SSLSocketDataProvider> > SSLVector; | 316 typedef std::vector<linked_ptr<SSLSocketDataProvider> > SSLVector; |
313 typedef std::vector<linked_ptr<StaticSocketDataProvider> > AlternateVector; | 317 typedef std::vector<linked_ptr<StaticSocketDataProvider> > AlternateVector; |
314 typedef std::vector<scoped_refptr<DeterministicSocketData> > | 318 typedef std::vector<scoped_refptr<DeterministicSocketData> > |
315 AlternateDeterministicVector; | 319 AlternateDeterministicVector; |
316 HttpRequestInfo request_; | 320 HttpRequestInfo request_; |
317 scoped_ptr<SpdySessionDependencies> session_deps_; | 321 scoped_ptr<SpdySessionDependencies> session_deps_; |
318 scoped_refptr<HttpNetworkSession> session_; | 322 scoped_refptr<HttpNetworkSession> session_; |
319 TransactionHelperResult output_; | 323 TransactionHelperResult output_; |
320 scoped_ptr<StaticSocketDataProvider> first_transaction_; | 324 scoped_ptr<StaticSocketDataProvider> first_transaction_; |
321 SSLVector ssl_vector_; | 325 SSLVector ssl_vector_; |
322 TestCompletionCallback callback; | 326 TestCompletionCallback callback; |
323 scoped_ptr<HttpNetworkTransaction> trans_; | 327 scoped_ptr<HttpNetworkTransaction> trans_; |
324 scoped_ptr<HttpNetworkTransaction> trans_http_; | 328 scoped_ptr<HttpNetworkTransaction> trans_http_; |
325 DataVector data_vector_; | 329 DataVector data_vector_; |
326 AlternateVector alternate_vector_; | 330 AlternateVector alternate_vector_; |
327 AlternateDeterministicVector alternate_deterministic_vector_; | 331 AlternateDeterministicVector alternate_deterministic_vector_; |
328 const BoundNetLog& log_; | 332 const BoundNetLog& log_; |
329 SpdyNetworkTransactionTestTypes test_type_; | 333 SpdyNetworkTransactionSpdy2TestTypes test_type_; |
330 int port_; | 334 int port_; |
331 bool deterministic_; | 335 bool deterministic_; |
332 bool spdy_enabled_; | 336 bool spdy_enabled_; |
333 }; | 337 }; |
334 | 338 |
335 void ConnectStatusHelperWithExpectedStatus(const MockRead& status, | 339 void ConnectStatusHelperWithExpectedStatus(const MockRead& status, |
336 int expected_status); | 340 int expected_status); |
337 | 341 |
338 void ConnectStatusHelper(const MockRead& status); | 342 void ConnectStatusHelper(const MockRead& status); |
339 | 343 |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 HttpRequestInfo google_get_request_; | 526 HttpRequestInfo google_get_request_; |
523 HttpRequestInfo google_post_request_; | 527 HttpRequestInfo google_post_request_; |
524 HttpRequestInfo google_chunked_post_request_; | 528 HttpRequestInfo google_chunked_post_request_; |
525 HttpRequestInfo google_get_push_request_; | 529 HttpRequestInfo google_get_push_request_; |
526 }; | 530 }; |
527 | 531 |
528 //----------------------------------------------------------------------------- | 532 //----------------------------------------------------------------------------- |
529 // All tests are run with three different connection types: SPDY after NPN | 533 // All tests are run with three different connection types: SPDY after NPN |
530 // negotiation, SPDY without SSL, and SPDY with SSL. | 534 // negotiation, SPDY without SSL, and SPDY with SSL. |
531 INSTANTIATE_TEST_CASE_P(Spdy, | 535 INSTANTIATE_TEST_CASE_P(Spdy, |
532 SpdyNetworkTransactionTest, | 536 SpdyNetworkTransactionSpdy2Test, |
533 ::testing::Values(SPDYNOSSL, SPDYSSL, SPDYNPN)); | 537 ::testing::Values(SPDYNOSSL, SPDYSSL, SPDYNPN)); |
534 | 538 |
535 | 539 |
536 // Verify HttpNetworkTransaction constructor. | 540 // Verify HttpNetworkTransaction constructor. |
537 TEST_P(SpdyNetworkTransactionTest, Constructor) { | 541 TEST_P(SpdyNetworkTransactionSpdy2Test, Constructor) { |
538 SpdySessionDependencies session_deps; | 542 SpdySessionDependencies session_deps; |
539 scoped_refptr<HttpNetworkSession> session( | 543 scoped_refptr<HttpNetworkSession> session( |
540 SpdySessionDependencies::SpdyCreateSession(&session_deps)); | 544 SpdySessionDependencies::SpdyCreateSession(&session_deps)); |
541 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 545 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
542 } | 546 } |
543 | 547 |
544 TEST_P(SpdyNetworkTransactionTest, Get) { | 548 TEST_P(SpdyNetworkTransactionSpdy2Test, Get) { |
545 // Construct the request. | 549 // Construct the request. |
546 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 550 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
547 MockWrite writes[] = { CreateMockWrite(*req) }; | 551 MockWrite writes[] = { CreateMockWrite(*req) }; |
548 | 552 |
549 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 553 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
550 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); | 554 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); |
551 MockRead reads[] = { | 555 MockRead reads[] = { |
552 CreateMockRead(*resp), | 556 CreateMockRead(*resp), |
553 CreateMockRead(*body), | 557 CreateMockRead(*body), |
554 MockRead(ASYNC, 0, 0) // EOF | 558 MockRead(ASYNC, 0, 0) // EOF |
555 }; | 559 }; |
556 | 560 |
557 scoped_ptr<DelayedSocketData> data( | 561 scoped_ptr<DelayedSocketData> data( |
558 new DelayedSocketData(1, reads, arraysize(reads), | 562 new DelayedSocketData(1, reads, arraysize(reads), |
559 writes, arraysize(writes))); | 563 writes, arraysize(writes))); |
560 NormalSpdyTransactionHelper helper(CreateGetRequest(), | 564 NormalSpdyTransactionHelper helper(CreateGetRequest(), |
561 BoundNetLog(), GetParam()); | 565 BoundNetLog(), GetParam()); |
562 helper.RunToCompletion(data.get()); | 566 helper.RunToCompletion(data.get()); |
563 TransactionHelperResult out = helper.output(); | 567 TransactionHelperResult out = helper.output(); |
564 EXPECT_EQ(OK, out.rv); | 568 EXPECT_EQ(OK, out.rv); |
565 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 569 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
566 EXPECT_EQ("hello!", out.response_data); | 570 EXPECT_EQ("hello!", out.response_data); |
567 } | 571 } |
568 | 572 |
569 TEST_P(SpdyNetworkTransactionTest, GetAtEachPriority) { | 573 TEST_P(SpdyNetworkTransactionSpdy2Test, GetAtEachPriority) { |
570 for (RequestPriority p = HIGHEST; p < NUM_PRIORITIES; | 574 for (RequestPriority p = HIGHEST; p < NUM_PRIORITIES; |
571 p = RequestPriority(p+1)) { | 575 p = RequestPriority(p+1)) { |
572 // Construct the request. | 576 // Construct the request. |
573 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, p)); | 577 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, p)); |
574 MockWrite writes[] = { CreateMockWrite(*req) }; | 578 MockWrite writes[] = { CreateMockWrite(*req) }; |
575 | 579 |
576 const int spdy_prio = reinterpret_cast<spdy::SpdySynStreamControlFrame*>( | 580 const int spdy_prio = reinterpret_cast<spdy::SpdySynStreamControlFrame*>( |
577 req.get())->priority(); | 581 req.get())->priority(); |
578 // this repeats the RequestPriority-->SpdyPriority mapping from | 582 // this repeats the RequestPriority-->SpdyPriority mapping from |
579 // SpdyFramer::ConvertRequestPriorityToSpdyPriority to make | 583 // SpdyFramer::ConvertRequestPriorityToSpdyPriority to make |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 // Start three gets simultaniously; making sure that multiplexed | 626 // Start three gets simultaniously; making sure that multiplexed |
623 // streams work properly. | 627 // streams work properly. |
624 | 628 |
625 // This can't use the TransactionHelper method, since it only | 629 // This can't use the TransactionHelper method, since it only |
626 // handles a single transaction, and finishes them as soon | 630 // handles a single transaction, and finishes them as soon |
627 // as it launches them. | 631 // as it launches them. |
628 | 632 |
629 // TODO(gavinp): create a working generalized TransactionHelper that | 633 // TODO(gavinp): create a working generalized TransactionHelper that |
630 // can allow multiple streams in flight. | 634 // can allow multiple streams in flight. |
631 | 635 |
632 TEST_P(SpdyNetworkTransactionTest, ThreeGets) { | 636 TEST_P(SpdyNetworkTransactionSpdy2Test, ThreeGets) { |
633 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 637 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
634 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 638 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
635 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, false)); | 639 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, false)); |
636 scoped_ptr<spdy::SpdyFrame> fbody(ConstructSpdyBodyFrame(1, true)); | 640 scoped_ptr<spdy::SpdyFrame> fbody(ConstructSpdyBodyFrame(1, true)); |
637 | 641 |
638 scoped_ptr<spdy::SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST)); | 642 scoped_ptr<spdy::SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST)); |
639 scoped_ptr<spdy::SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3)); | 643 scoped_ptr<spdy::SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3)); |
640 scoped_ptr<spdy::SpdyFrame> body2(ConstructSpdyBodyFrame(3, false)); | 644 scoped_ptr<spdy::SpdyFrame> body2(ConstructSpdyBodyFrame(3, false)); |
641 scoped_ptr<spdy::SpdyFrame> fbody2(ConstructSpdyBodyFrame(3, true)); | 645 scoped_ptr<spdy::SpdyFrame> fbody2(ConstructSpdyBodyFrame(3, true)); |
642 | 646 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 | 721 |
718 out.rv = ReadTransaction(trans1.get(), &out.response_data); | 722 out.rv = ReadTransaction(trans1.get(), &out.response_data); |
719 helper.VerifyDataConsumed(); | 723 helper.VerifyDataConsumed(); |
720 EXPECT_EQ(OK, out.rv); | 724 EXPECT_EQ(OK, out.rv); |
721 | 725 |
722 EXPECT_EQ(OK, out.rv); | 726 EXPECT_EQ(OK, out.rv); |
723 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 727 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
724 EXPECT_EQ("hello!hello!", out.response_data); | 728 EXPECT_EQ("hello!hello!", out.response_data); |
725 } | 729 } |
726 | 730 |
727 TEST_P(SpdyNetworkTransactionTest, TwoGetsLateBinding) { | 731 TEST_P(SpdyNetworkTransactionSpdy2Test, TwoGetsLateBinding) { |
728 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 732 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
729 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 733 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
730 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, false)); | 734 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, false)); |
731 scoped_ptr<spdy::SpdyFrame> fbody(ConstructSpdyBodyFrame(1, true)); | 735 scoped_ptr<spdy::SpdyFrame> fbody(ConstructSpdyBodyFrame(1, true)); |
732 | 736 |
733 scoped_ptr<spdy::SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST)); | 737 scoped_ptr<spdy::SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST)); |
734 scoped_ptr<spdy::SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3)); | 738 scoped_ptr<spdy::SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3)); |
735 scoped_ptr<spdy::SpdyFrame> body2(ConstructSpdyBodyFrame(3, false)); | 739 scoped_ptr<spdy::SpdyFrame> body2(ConstructSpdyBodyFrame(3, false)); |
736 scoped_ptr<spdy::SpdyFrame> fbody2(ConstructSpdyBodyFrame(3, true)); | 740 scoped_ptr<spdy::SpdyFrame> fbody2(ConstructSpdyBodyFrame(3, true)); |
737 | 741 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 out.status_line = response2->headers->GetStatusLine(); | 808 out.status_line = response2->headers->GetStatusLine(); |
805 out.response_info = *response2; | 809 out.response_info = *response2; |
806 out.rv = ReadTransaction(trans2.get(), &out.response_data); | 810 out.rv = ReadTransaction(trans2.get(), &out.response_data); |
807 EXPECT_EQ(OK, out.rv); | 811 EXPECT_EQ(OK, out.rv); |
808 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 812 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
809 EXPECT_EQ("hello!hello!", out.response_data); | 813 EXPECT_EQ("hello!hello!", out.response_data); |
810 | 814 |
811 helper.VerifyDataConsumed(); | 815 helper.VerifyDataConsumed(); |
812 } | 816 } |
813 | 817 |
814 TEST_P(SpdyNetworkTransactionTest, TwoGetsLateBindingFromPreconnect) { | 818 TEST_P(SpdyNetworkTransactionSpdy2Test, TwoGetsLateBindingFromPreconnect) { |
815 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 819 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
816 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 820 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
817 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, false)); | 821 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, false)); |
818 scoped_ptr<spdy::SpdyFrame> fbody(ConstructSpdyBodyFrame(1, true)); | 822 scoped_ptr<spdy::SpdyFrame> fbody(ConstructSpdyBodyFrame(1, true)); |
819 | 823 |
820 scoped_ptr<spdy::SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST)); | 824 scoped_ptr<spdy::SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST)); |
821 scoped_ptr<spdy::SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3)); | 825 scoped_ptr<spdy::SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3)); |
822 scoped_ptr<spdy::SpdyFrame> body2(ConstructSpdyBodyFrame(3, false)); | 826 scoped_ptr<spdy::SpdyFrame> body2(ConstructSpdyBodyFrame(3, false)); |
823 scoped_ptr<spdy::SpdyFrame> fbody2(ConstructSpdyBodyFrame(3, true)); | 827 scoped_ptr<spdy::SpdyFrame> fbody2(ConstructSpdyBodyFrame(3, true)); |
824 | 828 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
909 EXPECT_EQ("hello!hello!", out.response_data); | 913 EXPECT_EQ("hello!hello!", out.response_data); |
910 | 914 |
911 helper.VerifyDataConsumed(); | 915 helper.VerifyDataConsumed(); |
912 } | 916 } |
913 | 917 |
914 // Similar to ThreeGets above, however this test adds a SETTINGS | 918 // Similar to ThreeGets above, however this test adds a SETTINGS |
915 // frame. The SETTINGS frame is read during the IO loop waiting on | 919 // frame. The SETTINGS frame is read during the IO loop waiting on |
916 // the first transaction completion, and sets a maximum concurrent | 920 // the first transaction completion, and sets a maximum concurrent |
917 // stream limit of 1. This means that our IO loop exists after the | 921 // stream limit of 1. This means that our IO loop exists after the |
918 // second transaction completes, so we can assert on read_index(). | 922 // second transaction completes, so we can assert on read_index(). |
919 TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrent) { | 923 TEST_P(SpdyNetworkTransactionSpdy2Test, ThreeGetsWithMaxConcurrent) { |
920 // Construct the request. | 924 // Construct the request. |
921 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 925 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
922 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 926 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
923 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, false)); | 927 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, false)); |
924 scoped_ptr<spdy::SpdyFrame> fbody(ConstructSpdyBodyFrame(1, true)); | 928 scoped_ptr<spdy::SpdyFrame> fbody(ConstructSpdyBodyFrame(1, true)); |
925 | 929 |
926 scoped_ptr<spdy::SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST)); | 930 scoped_ptr<spdy::SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST)); |
927 scoped_ptr<spdy::SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3)); | 931 scoped_ptr<spdy::SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3)); |
928 scoped_ptr<spdy::SpdyFrame> body2(ConstructSpdyBodyFrame(3, false)); | 932 scoped_ptr<spdy::SpdyFrame> body2(ConstructSpdyBodyFrame(3, false)); |
929 scoped_ptr<spdy::SpdyFrame> fbody2(ConstructSpdyBodyFrame(3, true)); | 933 scoped_ptr<spdy::SpdyFrame> fbody2(ConstructSpdyBodyFrame(3, true)); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1042 helper.VerifyDataConsumed(); | 1046 helper.VerifyDataConsumed(); |
1043 } | 1047 } |
1044 EXPECT_EQ(OK, out.rv); | 1048 EXPECT_EQ(OK, out.rv); |
1045 } | 1049 } |
1046 | 1050 |
1047 // Similar to ThreeGetsWithMaxConcurrent above, however this test adds | 1051 // Similar to ThreeGetsWithMaxConcurrent above, however this test adds |
1048 // a fourth transaction. The third and fourth transactions have | 1052 // a fourth transaction. The third and fourth transactions have |
1049 // different data ("hello!" vs "hello!hello!") and because of the | 1053 // different data ("hello!" vs "hello!hello!") and because of the |
1050 // user specified priority, we expect to see them inverted in | 1054 // user specified priority, we expect to see them inverted in |
1051 // the response from the server. | 1055 // the response from the server. |
1052 TEST_P(SpdyNetworkTransactionTest, FourGetsWithMaxConcurrentPriority) { | 1056 TEST_P(SpdyNetworkTransactionSpdy2Test, FourGetsWithMaxConcurrentPriority) { |
1053 // Construct the request. | 1057 // Construct the request. |
1054 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 1058 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
1055 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 1059 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
1056 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, false)); | 1060 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, false)); |
1057 scoped_ptr<spdy::SpdyFrame> fbody(ConstructSpdyBodyFrame(1, true)); | 1061 scoped_ptr<spdy::SpdyFrame> fbody(ConstructSpdyBodyFrame(1, true)); |
1058 | 1062 |
1059 scoped_ptr<spdy::SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST)); | 1063 scoped_ptr<spdy::SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST)); |
1060 scoped_ptr<spdy::SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3)); | 1064 scoped_ptr<spdy::SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3)); |
1061 scoped_ptr<spdy::SpdyFrame> body2(ConstructSpdyBodyFrame(3, false)); | 1065 scoped_ptr<spdy::SpdyFrame> body2(ConstructSpdyBodyFrame(3, false)); |
1062 scoped_ptr<spdy::SpdyFrame> fbody2(ConstructSpdyBodyFrame(3, true)); | 1066 scoped_ptr<spdy::SpdyFrame> fbody2(ConstructSpdyBodyFrame(3, true)); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1198 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 1202 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
1199 EXPECT_EQ("hello!", out.response_data); | 1203 EXPECT_EQ("hello!", out.response_data); |
1200 helper.VerifyDataConsumed(); | 1204 helper.VerifyDataConsumed(); |
1201 EXPECT_EQ(OK, out.rv); | 1205 EXPECT_EQ(OK, out.rv); |
1202 } | 1206 } |
1203 | 1207 |
1204 // Similar to ThreeGetsMaxConcurrrent above, however, this test | 1208 // Similar to ThreeGetsMaxConcurrrent above, however, this test |
1205 // deletes a session in the middle of the transaction to insure | 1209 // deletes a session in the middle of the transaction to insure |
1206 // that we properly remove pendingcreatestream objects from | 1210 // that we properly remove pendingcreatestream objects from |
1207 // the spdy_session | 1211 // the spdy_session |
1208 TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrentDelete) { | 1212 TEST_P(SpdyNetworkTransactionSpdy2Test, ThreeGetsWithMaxConcurrentDelete) { |
1209 // Construct the request. | 1213 // Construct the request. |
1210 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 1214 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
1211 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 1215 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
1212 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, false)); | 1216 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, false)); |
1213 scoped_ptr<spdy::SpdyFrame> fbody(ConstructSpdyBodyFrame(1, true)); | 1217 scoped_ptr<spdy::SpdyFrame> fbody(ConstructSpdyBodyFrame(1, true)); |
1214 | 1218 |
1215 scoped_ptr<spdy::SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST)); | 1219 scoped_ptr<spdy::SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST)); |
1216 scoped_ptr<spdy::SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3)); | 1220 scoped_ptr<spdy::SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3)); |
1217 scoped_ptr<spdy::SpdyFrame> body2(ConstructSpdyBodyFrame(3, false)); | 1221 scoped_ptr<spdy::SpdyFrame> body2(ConstructSpdyBodyFrame(3, false)); |
1218 scoped_ptr<spdy::SpdyFrame> fbody2(ConstructSpdyBodyFrame(3, true)); | 1222 scoped_ptr<spdy::SpdyFrame> fbody2(ConstructSpdyBodyFrame(3, true)); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1303 out.status_line = response2->headers->GetStatusLine(); | 1307 out.status_line = response2->headers->GetStatusLine(); |
1304 out.response_info = *response2; | 1308 out.response_info = *response2; |
1305 out.rv = ReadTransaction(trans2.get(), &out.response_data); | 1309 out.rv = ReadTransaction(trans2.get(), &out.response_data); |
1306 EXPECT_EQ(OK, out.rv); | 1310 EXPECT_EQ(OK, out.rv); |
1307 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 1311 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
1308 EXPECT_EQ("hello!hello!", out.response_data); | 1312 EXPECT_EQ("hello!hello!", out.response_data); |
1309 helper.VerifyDataConsumed(); | 1313 helper.VerifyDataConsumed(); |
1310 EXPECT_EQ(OK, out.rv); | 1314 EXPECT_EQ(OK, out.rv); |
1311 } | 1315 } |
1312 | 1316 |
| 1317 namespace { |
| 1318 |
1313 // The KillerCallback will delete the transaction on error as part of the | 1319 // The KillerCallback will delete the transaction on error as part of the |
1314 // callback. | 1320 // callback. |
1315 class KillerCallback : public TestCompletionCallbackBase { | 1321 class KillerCallback : public TestCompletionCallbackBase { |
1316 public: | 1322 public: |
1317 explicit KillerCallback(HttpNetworkTransaction* transaction) | 1323 explicit KillerCallback(HttpNetworkTransaction* transaction) |
1318 : transaction_(transaction), | 1324 : transaction_(transaction), |
1319 ALLOW_THIS_IN_INITIALIZER_LIST(callback_( | 1325 ALLOW_THIS_IN_INITIALIZER_LIST(callback_( |
1320 base::Bind(&KillerCallback::OnComplete, base::Unretained(this)))) { | 1326 base::Bind(&KillerCallback::OnComplete, base::Unretained(this)))) { |
1321 } | 1327 } |
1322 | 1328 |
1323 virtual ~KillerCallback() {} | 1329 virtual ~KillerCallback() {} |
1324 | 1330 |
1325 const CompletionCallback& callback() const { return callback_; } | 1331 const CompletionCallback& callback() const { return callback_; } |
1326 | 1332 |
1327 private: | 1333 private: |
1328 void OnComplete(int result) { | 1334 void OnComplete(int result) { |
1329 if (result < 0) | 1335 if (result < 0) |
1330 delete transaction_; | 1336 delete transaction_; |
1331 | 1337 |
1332 SetResult(result); | 1338 SetResult(result); |
1333 } | 1339 } |
1334 | 1340 |
1335 HttpNetworkTransaction* transaction_; | 1341 HttpNetworkTransaction* transaction_; |
1336 CompletionCallback callback_; | 1342 CompletionCallback callback_; |
1337 }; | 1343 }; |
1338 | 1344 |
| 1345 } // namespace |
| 1346 |
1339 // Similar to ThreeGetsMaxConcurrrentDelete above, however, this test | 1347 // Similar to ThreeGetsMaxConcurrrentDelete above, however, this test |
1340 // closes the socket while we have a pending transaction waiting for | 1348 // closes the socket while we have a pending transaction waiting for |
1341 // a pending stream creation. http://crbug.com/52901 | 1349 // a pending stream creation. http://crbug.com/52901 |
1342 TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrentSocketClose) { | 1350 TEST_P(SpdyNetworkTransactionSpdy2Test, ThreeGetsWithMaxConcurrentSocketClose) { |
1343 // Construct the request. | 1351 // Construct the request. |
1344 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 1352 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
1345 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 1353 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
1346 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, false)); | 1354 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, false)); |
1347 scoped_ptr<spdy::SpdyFrame> fin_body(ConstructSpdyBodyFrame(1, true)); | 1355 scoped_ptr<spdy::SpdyFrame> fin_body(ConstructSpdyBodyFrame(1, true)); |
1348 | 1356 |
1349 scoped_ptr<spdy::SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST)); | 1357 scoped_ptr<spdy::SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST)); |
1350 scoped_ptr<spdy::SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3)); | 1358 scoped_ptr<spdy::SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3)); |
1351 | 1359 |
1352 spdy::SpdySettings settings; | 1360 spdy::SpdySettings settings; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1426 ASSERT_TRUE(response2 != NULL); | 1434 ASSERT_TRUE(response2 != NULL); |
1427 out.status_line = response2->headers->GetStatusLine(); | 1435 out.status_line = response2->headers->GetStatusLine(); |
1428 out.response_info = *response2; | 1436 out.response_info = *response2; |
1429 out.rv = ReadTransaction(&trans2, &out.response_data); | 1437 out.rv = ReadTransaction(&trans2, &out.response_data); |
1430 EXPECT_EQ(ERR_CONNECTION_RESET, out.rv); | 1438 EXPECT_EQ(ERR_CONNECTION_RESET, out.rv); |
1431 | 1439 |
1432 helper.VerifyDataConsumed(); | 1440 helper.VerifyDataConsumed(); |
1433 } | 1441 } |
1434 | 1442 |
1435 // Test that a simple PUT request works. | 1443 // Test that a simple PUT request works. |
1436 TEST_P(SpdyNetworkTransactionTest, Put) { | 1444 TEST_P(SpdyNetworkTransactionSpdy2Test, Put) { |
1437 // Setup the request | 1445 // Setup the request |
1438 HttpRequestInfo request; | 1446 HttpRequestInfo request; |
1439 request.method = "PUT"; | 1447 request.method = "PUT"; |
1440 request.url = GURL("http://www.google.com/"); | 1448 request.url = GURL("http://www.google.com/"); |
1441 | 1449 |
1442 const SpdyHeaderInfo kSynStartHeader = { | 1450 const SpdyHeaderInfo kSynStartHeader = { |
1443 spdy::SYN_STREAM, // Kind = Syn | 1451 spdy::SYN_STREAM, // Kind = Syn |
1444 1, // Stream ID | 1452 1, // Stream ID |
1445 0, // Associated stream ID | 1453 0, // Associated stream ID |
1446 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority | 1454 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1497 NormalSpdyTransactionHelper helper(request, | 1505 NormalSpdyTransactionHelper helper(request, |
1498 BoundNetLog(), GetParam()); | 1506 BoundNetLog(), GetParam()); |
1499 helper.RunToCompletion(data.get()); | 1507 helper.RunToCompletion(data.get()); |
1500 TransactionHelperResult out = helper.output(); | 1508 TransactionHelperResult out = helper.output(); |
1501 | 1509 |
1502 EXPECT_EQ(OK, out.rv); | 1510 EXPECT_EQ(OK, out.rv); |
1503 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 1511 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
1504 } | 1512 } |
1505 | 1513 |
1506 // Test that a simple HEAD request works. | 1514 // Test that a simple HEAD request works. |
1507 TEST_P(SpdyNetworkTransactionTest, Head) { | 1515 TEST_P(SpdyNetworkTransactionSpdy2Test, Head) { |
1508 // Setup the request | 1516 // Setup the request |
1509 HttpRequestInfo request; | 1517 HttpRequestInfo request; |
1510 request.method = "HEAD"; | 1518 request.method = "HEAD"; |
1511 request.url = GURL("http://www.google.com/"); | 1519 request.url = GURL("http://www.google.com/"); |
1512 | 1520 |
1513 const SpdyHeaderInfo kSynStartHeader = { | 1521 const SpdyHeaderInfo kSynStartHeader = { |
1514 spdy::SYN_STREAM, // Kind = Syn | 1522 spdy::SYN_STREAM, // Kind = Syn |
1515 1, // Stream ID | 1523 1, // Stream ID |
1516 0, // Associated stream ID | 1524 0, // Associated stream ID |
1517 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority | 1525 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1568 NormalSpdyTransactionHelper helper(request, | 1576 NormalSpdyTransactionHelper helper(request, |
1569 BoundNetLog(), GetParam()); | 1577 BoundNetLog(), GetParam()); |
1570 helper.RunToCompletion(data.get()); | 1578 helper.RunToCompletion(data.get()); |
1571 TransactionHelperResult out = helper.output(); | 1579 TransactionHelperResult out = helper.output(); |
1572 | 1580 |
1573 EXPECT_EQ(OK, out.rv); | 1581 EXPECT_EQ(OK, out.rv); |
1574 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 1582 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
1575 } | 1583 } |
1576 | 1584 |
1577 // Test that a simple POST works. | 1585 // Test that a simple POST works. |
1578 TEST_P(SpdyNetworkTransactionTest, Post) { | 1586 TEST_P(SpdyNetworkTransactionSpdy2Test, Post) { |
1579 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyPost(kUploadDataSize, NULL, 0)); | 1587 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyPost(kUploadDataSize, NULL, 0)); |
1580 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); | 1588 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); |
1581 MockWrite writes[] = { | 1589 MockWrite writes[] = { |
1582 CreateMockWrite(*req), | 1590 CreateMockWrite(*req), |
1583 CreateMockWrite(*body), // POST upload frame | 1591 CreateMockWrite(*body), // POST upload frame |
1584 }; | 1592 }; |
1585 | 1593 |
1586 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0)); | 1594 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0)); |
1587 MockRead reads[] = { | 1595 MockRead reads[] = { |
1588 CreateMockRead(*resp), | 1596 CreateMockRead(*resp), |
1589 CreateMockRead(*body), | 1597 CreateMockRead(*body), |
1590 MockRead(ASYNC, 0, 0) // EOF | 1598 MockRead(ASYNC, 0, 0) // EOF |
1591 }; | 1599 }; |
1592 | 1600 |
1593 scoped_ptr<DelayedSocketData> data( | 1601 scoped_ptr<DelayedSocketData> data( |
1594 new DelayedSocketData(2, reads, arraysize(reads), | 1602 new DelayedSocketData(2, reads, arraysize(reads), |
1595 writes, arraysize(writes))); | 1603 writes, arraysize(writes))); |
1596 NormalSpdyTransactionHelper helper(CreatePostRequest(), | 1604 NormalSpdyTransactionHelper helper(CreatePostRequest(), |
1597 BoundNetLog(), GetParam()); | 1605 BoundNetLog(), GetParam()); |
1598 helper.RunToCompletion(data.get()); | 1606 helper.RunToCompletion(data.get()); |
1599 TransactionHelperResult out = helper.output(); | 1607 TransactionHelperResult out = helper.output(); |
1600 EXPECT_EQ(OK, out.rv); | 1608 EXPECT_EQ(OK, out.rv); |
1601 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 1609 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
1602 EXPECT_EQ("hello!", out.response_data); | 1610 EXPECT_EQ("hello!", out.response_data); |
1603 } | 1611 } |
1604 | 1612 |
1605 // Test that a chunked POST works. | 1613 // Test that a chunked POST works. |
1606 TEST_P(SpdyNetworkTransactionTest, ChunkedPost) { | 1614 TEST_P(SpdyNetworkTransactionSpdy2Test, ChunkedPost) { |
1607 UploadDataStream::set_merge_chunks(false); | 1615 UploadDataStream::set_merge_chunks(false); |
1608 scoped_ptr<spdy::SpdyFrame> req(ConstructChunkedSpdyPost(NULL, 0)); | 1616 scoped_ptr<spdy::SpdyFrame> req(ConstructChunkedSpdyPost(NULL, 0)); |
1609 scoped_ptr<spdy::SpdyFrame> chunk1(ConstructSpdyBodyFrame(1, false)); | 1617 scoped_ptr<spdy::SpdyFrame> chunk1(ConstructSpdyBodyFrame(1, false)); |
1610 scoped_ptr<spdy::SpdyFrame> chunk2(ConstructSpdyBodyFrame(1, true)); | 1618 scoped_ptr<spdy::SpdyFrame> chunk2(ConstructSpdyBodyFrame(1, true)); |
1611 MockWrite writes[] = { | 1619 MockWrite writes[] = { |
1612 CreateMockWrite(*req), | 1620 CreateMockWrite(*req), |
1613 CreateMockWrite(*chunk1), | 1621 CreateMockWrite(*chunk1), |
1614 CreateMockWrite(*chunk2), | 1622 CreateMockWrite(*chunk2), |
1615 }; | 1623 }; |
1616 | 1624 |
(...skipping 11 matching lines...) Expand all Loading... |
1628 NormalSpdyTransactionHelper helper(CreateChunkedPostRequest(), | 1636 NormalSpdyTransactionHelper helper(CreateChunkedPostRequest(), |
1629 BoundNetLog(), GetParam()); | 1637 BoundNetLog(), GetParam()); |
1630 helper.RunToCompletion(data.get()); | 1638 helper.RunToCompletion(data.get()); |
1631 TransactionHelperResult out = helper.output(); | 1639 TransactionHelperResult out = helper.output(); |
1632 EXPECT_EQ(OK, out.rv); | 1640 EXPECT_EQ(OK, out.rv); |
1633 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 1641 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
1634 EXPECT_EQ("hello!hello!", out.response_data); | 1642 EXPECT_EQ("hello!hello!", out.response_data); |
1635 } | 1643 } |
1636 | 1644 |
1637 // Test that a POST without any post data works. | 1645 // Test that a POST without any post data works. |
1638 TEST_P(SpdyNetworkTransactionTest, NullPost) { | 1646 TEST_P(SpdyNetworkTransactionSpdy2Test, NullPost) { |
1639 // Setup the request | 1647 // Setup the request |
1640 HttpRequestInfo request; | 1648 HttpRequestInfo request; |
1641 request.method = "POST"; | 1649 request.method = "POST"; |
1642 request.url = GURL("http://www.google.com/"); | 1650 request.url = GURL("http://www.google.com/"); |
1643 // Create an empty UploadData. | 1651 // Create an empty UploadData. |
1644 request.upload_data = NULL; | 1652 request.upload_data = NULL; |
1645 | 1653 |
1646 // When request.upload_data is NULL for post, content-length is | 1654 // When request.upload_data is NULL for post, content-length is |
1647 // expected to be 0. | 1655 // expected to be 0. |
1648 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyPost(0, NULL, 0)); | 1656 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyPost(0, NULL, 0)); |
(...skipping 18 matching lines...) Expand all Loading... |
1667 NormalSpdyTransactionHelper helper(request, | 1675 NormalSpdyTransactionHelper helper(request, |
1668 BoundNetLog(), GetParam()); | 1676 BoundNetLog(), GetParam()); |
1669 helper.RunToCompletion(data.get()); | 1677 helper.RunToCompletion(data.get()); |
1670 TransactionHelperResult out = helper.output(); | 1678 TransactionHelperResult out = helper.output(); |
1671 EXPECT_EQ(OK, out.rv); | 1679 EXPECT_EQ(OK, out.rv); |
1672 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 1680 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
1673 EXPECT_EQ("hello!", out.response_data); | 1681 EXPECT_EQ("hello!", out.response_data); |
1674 } | 1682 } |
1675 | 1683 |
1676 // Test that a simple POST works. | 1684 // Test that a simple POST works. |
1677 TEST_P(SpdyNetworkTransactionTest, EmptyPost) { | 1685 TEST_P(SpdyNetworkTransactionSpdy2Test, EmptyPost) { |
1678 // Setup the request | 1686 // Setup the request |
1679 HttpRequestInfo request; | 1687 HttpRequestInfo request; |
1680 request.method = "POST"; | 1688 request.method = "POST"; |
1681 request.url = GURL("http://www.google.com/"); | 1689 request.url = GURL("http://www.google.com/"); |
1682 // Create an empty UploadData. | 1690 // Create an empty UploadData. |
1683 request.upload_data = new UploadData(); | 1691 request.upload_data = new UploadData(); |
1684 | 1692 |
1685 // Http POST Content-Length is using UploadDataStream::size(). | 1693 // Http POST Content-Length is using UploadDataStream::size(). |
1686 // It is the same as request.upload_data->GetContentLengthSync(). | 1694 // It is the same as request.upload_data->GetContentLengthSync(). |
1687 scoped_ptr<UploadDataStream> stream( | 1695 scoped_ptr<UploadDataStream> stream( |
(...skipping 26 matching lines...) Expand all Loading... |
1714 NormalSpdyTransactionHelper helper(request, | 1722 NormalSpdyTransactionHelper helper(request, |
1715 BoundNetLog(), GetParam()); | 1723 BoundNetLog(), GetParam()); |
1716 helper.RunToCompletion(data.get()); | 1724 helper.RunToCompletion(data.get()); |
1717 TransactionHelperResult out = helper.output(); | 1725 TransactionHelperResult out = helper.output(); |
1718 EXPECT_EQ(OK, out.rv); | 1726 EXPECT_EQ(OK, out.rv); |
1719 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 1727 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
1720 EXPECT_EQ("hello!", out.response_data); | 1728 EXPECT_EQ("hello!", out.response_data); |
1721 } | 1729 } |
1722 | 1730 |
1723 // While we're doing a post, the server sends back a SYN_REPLY. | 1731 // While we're doing a post, the server sends back a SYN_REPLY. |
1724 TEST_P(SpdyNetworkTransactionTest, PostWithEarlySynReply) { | 1732 TEST_P(SpdyNetworkTransactionSpdy2Test, PostWithEarlySynReply) { |
1725 static const char upload[] = { "hello!" }; | 1733 static const char upload[] = { "hello!" }; |
1726 | 1734 |
1727 // Setup the request | 1735 // Setup the request |
1728 HttpRequestInfo request; | 1736 HttpRequestInfo request; |
1729 request.method = "POST"; | 1737 request.method = "POST"; |
1730 request.url = GURL("http://www.google.com/"); | 1738 request.url = GURL("http://www.google.com/"); |
1731 request.upload_data = new UploadData(); | 1739 request.upload_data = new UploadData(); |
1732 request.upload_data->AppendBytes(upload, sizeof(upload)); | 1740 request.upload_data->AppendBytes(upload, sizeof(upload)); |
1733 | 1741 |
1734 // Http POST Content-Length is using UploadDataStream::size(). | 1742 // Http POST Content-Length is using UploadDataStream::size(). |
(...skipping 20 matching lines...) Expand all Loading... |
1755 helper.RunDefaultTest(); | 1763 helper.RunDefaultTest(); |
1756 helper.VerifyDataConsumed(); | 1764 helper.VerifyDataConsumed(); |
1757 | 1765 |
1758 TransactionHelperResult out = helper.output(); | 1766 TransactionHelperResult out = helper.output(); |
1759 EXPECT_EQ(ERR_SYN_REPLY_NOT_RECEIVED, out.rv); | 1767 EXPECT_EQ(ERR_SYN_REPLY_NOT_RECEIVED, out.rv); |
1760 } | 1768 } |
1761 | 1769 |
1762 // The client upon cancellation tries to send a RST_STREAM frame. The mock | 1770 // The client upon cancellation tries to send a RST_STREAM frame. The mock |
1763 // socket causes the TCP write to return zero. This test checks that the client | 1771 // socket causes the TCP write to return zero. This test checks that the client |
1764 // tries to queue up the RST_STREAM frame again. | 1772 // tries to queue up the RST_STREAM frame again. |
1765 TEST_P(SpdyNetworkTransactionTest, SocketWriteReturnsZero) { | 1773 TEST_P(SpdyNetworkTransactionSpdy2Test, SocketWriteReturnsZero) { |
1766 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 1774 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
1767 scoped_ptr<spdy::SpdyFrame> rst( | 1775 scoped_ptr<spdy::SpdyFrame> rst( |
1768 ConstructSpdyRstStream(1, spdy::CANCEL)); | 1776 ConstructSpdyRstStream(1, spdy::CANCEL)); |
1769 MockWrite writes[] = { | 1777 MockWrite writes[] = { |
1770 CreateMockWrite(*req.get(), 0, SYNCHRONOUS), | 1778 CreateMockWrite(*req.get(), 0, SYNCHRONOUS), |
1771 MockWrite(SYNCHRONOUS, 0, 0, 2), | 1779 MockWrite(SYNCHRONOUS, 0, 0, 2), |
1772 CreateMockWrite(*rst.get(), 3, SYNCHRONOUS), | 1780 CreateMockWrite(*rst.get(), 3, SYNCHRONOUS), |
1773 }; | 1781 }; |
1774 | 1782 |
1775 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 1783 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
(...skipping 20 matching lines...) Expand all Loading... |
1796 data->SetStop(2); | 1804 data->SetStop(2); |
1797 data->Run(); | 1805 data->Run(); |
1798 helper.ResetTrans(); | 1806 helper.ResetTrans(); |
1799 data->SetStop(20); | 1807 data->SetStop(20); |
1800 data->Run(); | 1808 data->Run(); |
1801 | 1809 |
1802 helper.VerifyDataConsumed(); | 1810 helper.VerifyDataConsumed(); |
1803 } | 1811 } |
1804 | 1812 |
1805 // Test that the transaction doesn't crash when we don't have a reply. | 1813 // Test that the transaction doesn't crash when we don't have a reply. |
1806 TEST_P(SpdyNetworkTransactionTest, ResponseWithoutSynReply) { | 1814 TEST_P(SpdyNetworkTransactionSpdy2Test, ResponseWithoutSynReply) { |
1807 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); | 1815 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); |
1808 MockRead reads[] = { | 1816 MockRead reads[] = { |
1809 CreateMockRead(*body), | 1817 CreateMockRead(*body), |
1810 MockRead(ASYNC, 0, 0) // EOF | 1818 MockRead(ASYNC, 0, 0) // EOF |
1811 }; | 1819 }; |
1812 | 1820 |
1813 scoped_ptr<DelayedSocketData> data( | 1821 scoped_ptr<DelayedSocketData> data( |
1814 new DelayedSocketData(1, reads, arraysize(reads), NULL, 0)); | 1822 new DelayedSocketData(1, reads, arraysize(reads), NULL, 0)); |
1815 NormalSpdyTransactionHelper helper(CreateGetRequest(), | 1823 NormalSpdyTransactionHelper helper(CreateGetRequest(), |
1816 BoundNetLog(), GetParam()); | 1824 BoundNetLog(), GetParam()); |
1817 helper.RunToCompletion(data.get()); | 1825 helper.RunToCompletion(data.get()); |
1818 TransactionHelperResult out = helper.output(); | 1826 TransactionHelperResult out = helper.output(); |
1819 EXPECT_EQ(ERR_SYN_REPLY_NOT_RECEIVED, out.rv); | 1827 EXPECT_EQ(ERR_SYN_REPLY_NOT_RECEIVED, out.rv); |
1820 } | 1828 } |
1821 | 1829 |
1822 // Test that the transaction doesn't crash when we get two replies on the same | 1830 // Test that the transaction doesn't crash when we get two replies on the same |
1823 // stream ID. See http://crbug.com/45639. | 1831 // stream ID. See http://crbug.com/45639. |
1824 TEST_P(SpdyNetworkTransactionTest, ResponseWithTwoSynReplies) { | 1832 TEST_P(SpdyNetworkTransactionSpdy2Test, ResponseWithTwoSynReplies) { |
1825 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 1833 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
1826 MockWrite writes[] = { CreateMockWrite(*req) }; | 1834 MockWrite writes[] = { CreateMockWrite(*req) }; |
1827 | 1835 |
1828 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 1836 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
1829 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); | 1837 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); |
1830 MockRead reads[] = { | 1838 MockRead reads[] = { |
1831 CreateMockRead(*resp), | 1839 CreateMockRead(*resp), |
1832 CreateMockRead(*resp), | 1840 CreateMockRead(*resp), |
1833 CreateMockRead(*body), | 1841 CreateMockRead(*body), |
1834 MockRead(ASYNC, 0, 0) // EOF | 1842 MockRead(ASYNC, 0, 0) // EOF |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1876 // since request has not been completely written, therefore we feed | 1884 // since request has not been completely written, therefore we feed |
1877 // enough number of WINDOW_UPDATEs to finish the first read and cause a | 1885 // enough number of WINDOW_UPDATEs to finish the first read and cause a |
1878 // write, leading to a complete write of request body; after that we send | 1886 // write, leading to a complete write of request body; after that we send |
1879 // a reply with a body, to cause a graceful shutdown. | 1887 // a reply with a body, to cause a graceful shutdown. |
1880 | 1888 |
1881 // TODO(agayev): develop a socket data provider where both, reads and | 1889 // TODO(agayev): develop a socket data provider where both, reads and |
1882 // writes are ordered so that writing tests like these are easy and rewrite | 1890 // writes are ordered so that writing tests like these are easy and rewrite |
1883 // all these tests using it. Right now we are working around the | 1891 // all these tests using it. Right now we are working around the |
1884 // limitations as described above and it's not deterministic, tests may | 1892 // limitations as described above and it's not deterministic, tests may |
1885 // fail under specific circumstances. | 1893 // fail under specific circumstances. |
1886 TEST_P(SpdyNetworkTransactionTest, WindowUpdateReceived) { | 1894 TEST_P(SpdyNetworkTransactionSpdy2Test, WindowUpdateReceived) { |
1887 SpdySession::set_use_flow_control(SpdySession::kEnableFlowControl); | 1895 SpdySession::set_use_flow_control(SpdySession::kEnableFlowControl); |
1888 | 1896 |
1889 static int kFrameCount = 2; | 1897 static int kFrameCount = 2; |
1890 scoped_ptr<std::string> content( | 1898 scoped_ptr<std::string> content( |
1891 new std::string(kMaxSpdyFrameChunkSize, 'a')); | 1899 new std::string(kMaxSpdyFrameChunkSize, 'a')); |
1892 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyPost( | 1900 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyPost( |
1893 kMaxSpdyFrameChunkSize * kFrameCount, NULL, 0)); | 1901 kMaxSpdyFrameChunkSize * kFrameCount, NULL, 0)); |
1894 scoped_ptr<spdy::SpdyFrame> body( | 1902 scoped_ptr<spdy::SpdyFrame> body( |
1895 ConstructSpdyBodyFrame(1, content->c_str(), content->size(), false)); | 1903 ConstructSpdyBodyFrame(1, content->c_str(), content->size(), false)); |
1896 scoped_ptr<spdy::SpdyFrame> body_end( | 1904 scoped_ptr<spdy::SpdyFrame> body_end( |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1954 kDeltaWindowSize * kDeltaCount - | 1962 kDeltaWindowSize * kDeltaCount - |
1955 kMaxSpdyFrameChunkSize * kFrameCount, | 1963 kMaxSpdyFrameChunkSize * kFrameCount, |
1956 stream->stream()->send_window_size()); | 1964 stream->stream()->send_window_size()); |
1957 helper.VerifyDataConsumed(); | 1965 helper.VerifyDataConsumed(); |
1958 | 1966 |
1959 SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); | 1967 SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); |
1960 } | 1968 } |
1961 | 1969 |
1962 // Test that received data frames and sent WINDOW_UPDATE frames change | 1970 // Test that received data frames and sent WINDOW_UPDATE frames change |
1963 // the recv_window_size_ correctly. | 1971 // the recv_window_size_ correctly. |
1964 TEST_P(SpdyNetworkTransactionTest, WindowUpdateSent) { | 1972 TEST_P(SpdyNetworkTransactionSpdy2Test, WindowUpdateSent) { |
1965 SpdySession::set_use_flow_control(SpdySession::kEnableFlowControl); | 1973 SpdySession::set_use_flow_control(SpdySession::kEnableFlowControl); |
1966 | 1974 |
1967 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 1975 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
1968 scoped_ptr<spdy::SpdyFrame> window_update( | 1976 scoped_ptr<spdy::SpdyFrame> window_update( |
1969 ConstructSpdyWindowUpdate(1, kUploadDataSize)); | 1977 ConstructSpdyWindowUpdate(1, kUploadDataSize)); |
1970 | 1978 |
1971 MockWrite writes[] = { | 1979 MockWrite writes[] = { |
1972 CreateMockWrite(*req), | 1980 CreateMockWrite(*req), |
1973 CreateMockWrite(*window_update), | 1981 CreateMockWrite(*window_update), |
1974 }; | 1982 }; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2042 // Read EOF. | 2050 // Read EOF. |
2043 data->CompleteRead(); | 2051 data->CompleteRead(); |
2044 | 2052 |
2045 helper.VerifyDataConsumed(); | 2053 helper.VerifyDataConsumed(); |
2046 | 2054 |
2047 SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); | 2055 SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); |
2048 } | 2056 } |
2049 | 2057 |
2050 // Test that WINDOW_UPDATE frame causing overflow is handled correctly. We | 2058 // Test that WINDOW_UPDATE frame causing overflow is handled correctly. We |
2051 // use the same trick as in the above test to enforce our scenario. | 2059 // use the same trick as in the above test to enforce our scenario. |
2052 TEST_P(SpdyNetworkTransactionTest, WindowUpdateOverflow) { | 2060 TEST_P(SpdyNetworkTransactionSpdy2Test, WindowUpdateOverflow) { |
2053 SpdySession::set_use_flow_control(SpdySession::kEnableFlowControl); | 2061 SpdySession::set_use_flow_control(SpdySession::kEnableFlowControl); |
2054 | 2062 |
2055 // number of full frames we hope to write (but will not, used to | 2063 // number of full frames we hope to write (but will not, used to |
2056 // set content-length header correctly) | 2064 // set content-length header correctly) |
2057 static int kFrameCount = 3; | 2065 static int kFrameCount = 3; |
2058 | 2066 |
2059 scoped_ptr<std::string> content( | 2067 scoped_ptr<std::string> content( |
2060 new std::string(kMaxSpdyFrameChunkSize, 'a')); | 2068 new std::string(kMaxSpdyFrameChunkSize, 'a')); |
2061 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyPost( | 2069 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyPost( |
2062 kMaxSpdyFrameChunkSize * kFrameCount, NULL, 0)); | 2070 kMaxSpdyFrameChunkSize * kFrameCount, NULL, 0)); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2134 // data frame containing default content (which is "hello!") and this frame | 2142 // data frame containing default content (which is "hello!") and this frame |
2135 // also contains a FIN flag. DelayedSocketData is used to enforce all | 2143 // also contains a FIN flag. DelayedSocketData is used to enforce all |
2136 // writes go through before a read could happen. However, the last frame | 2144 // writes go through before a read could happen. However, the last frame |
2137 // ("hello!") is not supposed to go through since by the time its turn | 2145 // ("hello!") is not supposed to go through since by the time its turn |
2138 // arrives, window size is 0. At this point MessageLoop::Run() called via | 2146 // arrives, window size is 0. At this point MessageLoop::Run() called via |
2139 // callback would block. Therefore we call MessageLoop::RunAllPending() | 2147 // callback would block. Therefore we call MessageLoop::RunAllPending() |
2140 // which returns after performing all possible writes. We use DCHECKS to | 2148 // which returns after performing all possible writes. We use DCHECKS to |
2141 // ensure that last data frame is still there and stream has stalled. | 2149 // ensure that last data frame is still there and stream has stalled. |
2142 // After that, next read is artifically enforced, which causes a | 2150 // After that, next read is artifically enforced, which causes a |
2143 // WINDOW_UPDATE to be read and I/O process resumes. | 2151 // WINDOW_UPDATE to be read and I/O process resumes. |
2144 TEST_P(SpdyNetworkTransactionTest, FlowControlStallResume) { | 2152 TEST_P(SpdyNetworkTransactionSpdy2Test, FlowControlStallResume) { |
2145 SpdySession::set_use_flow_control(SpdySession::kEnableFlowControl); | 2153 SpdySession::set_use_flow_control(SpdySession::kEnableFlowControl); |
2146 | 2154 |
2147 // Number of frames we need to send to zero out the window size: data | 2155 // Number of frames we need to send to zero out the window size: data |
2148 // frames plus SYN_STREAM plus the last data frame; also we need another | 2156 // frames plus SYN_STREAM plus the last data frame; also we need another |
2149 // data frame that we will send once the WINDOW_UPDATE is received, | 2157 // data frame that we will send once the WINDOW_UPDATE is received, |
2150 // therefore +3. | 2158 // therefore +3. |
2151 size_t nwrites = | 2159 size_t nwrites = |
2152 spdy::kSpdyStreamInitialWindowSize / kMaxSpdyFrameChunkSize + 3; | 2160 spdy::kSpdyStreamInitialWindowSize / kMaxSpdyFrameChunkSize + 3; |
2153 | 2161 |
2154 // Calculate last frame's size; 0 size data frame is legal. | 2162 // Calculate last frame's size; 0 size data frame is legal. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2234 // But the body is not yet fully sent ("hello!" is not yet sent). | 2242 // But the body is not yet fully sent ("hello!" is not yet sent). |
2235 EXPECT_FALSE(stream->stream()->body_sent()); | 2243 EXPECT_FALSE(stream->stream()->body_sent()); |
2236 | 2244 |
2237 data->ForceNextRead(); // Read in WINDOW_UPDATE frame. | 2245 data->ForceNextRead(); // Read in WINDOW_UPDATE frame. |
2238 rv = callback.WaitForResult(); | 2246 rv = callback.WaitForResult(); |
2239 helper.VerifyDataConsumed(); | 2247 helper.VerifyDataConsumed(); |
2240 | 2248 |
2241 SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); | 2249 SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); |
2242 } | 2250 } |
2243 | 2251 |
2244 TEST_P(SpdyNetworkTransactionTest, CancelledTransaction) { | 2252 TEST_P(SpdyNetworkTransactionSpdy2Test, CancelledTransaction) { |
2245 // Construct the request. | 2253 // Construct the request. |
2246 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 2254 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
2247 MockWrite writes[] = { | 2255 MockWrite writes[] = { |
2248 CreateMockWrite(*req), | 2256 CreateMockWrite(*req), |
2249 }; | 2257 }; |
2250 | 2258 |
2251 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 2259 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
2252 MockRead reads[] = { | 2260 MockRead reads[] = { |
2253 CreateMockRead(*resp), | 2261 CreateMockRead(*resp), |
2254 // This following read isn't used by the test, except during the | 2262 // This following read isn't used by the test, except during the |
(...skipping 18 matching lines...) Expand all Loading... |
2273 EXPECT_EQ(ERR_IO_PENDING, rv); | 2281 EXPECT_EQ(ERR_IO_PENDING, rv); |
2274 helper.ResetTrans(); // Cancel the transaction. | 2282 helper.ResetTrans(); // Cancel the transaction. |
2275 | 2283 |
2276 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the | 2284 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the |
2277 // MockClientSocketFactory) are still alive. | 2285 // MockClientSocketFactory) are still alive. |
2278 MessageLoop::current()->RunAllPending(); | 2286 MessageLoop::current()->RunAllPending(); |
2279 helper.VerifyDataNotConsumed(); | 2287 helper.VerifyDataNotConsumed(); |
2280 } | 2288 } |
2281 | 2289 |
2282 // Verify that the client sends a Rst Frame upon cancelling the stream. | 2290 // Verify that the client sends a Rst Frame upon cancelling the stream. |
2283 TEST_P(SpdyNetworkTransactionTest, CancelledTransactionSendRst) { | 2291 TEST_P(SpdyNetworkTransactionSpdy2Test, CancelledTransactionSendRst) { |
2284 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 2292 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
2285 scoped_ptr<spdy::SpdyFrame> rst( | 2293 scoped_ptr<spdy::SpdyFrame> rst( |
2286 ConstructSpdyRstStream(1, spdy::CANCEL)); | 2294 ConstructSpdyRstStream(1, spdy::CANCEL)); |
2287 MockWrite writes[] = { | 2295 MockWrite writes[] = { |
2288 CreateMockWrite(*req, 0, SYNCHRONOUS), | 2296 CreateMockWrite(*req, 0, SYNCHRONOUS), |
2289 CreateMockWrite(*rst, 2, SYNCHRONOUS), | 2297 CreateMockWrite(*rst, 2, SYNCHRONOUS), |
2290 }; | 2298 }; |
2291 | 2299 |
2292 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 2300 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
2293 MockRead reads[] = { | 2301 MockRead reads[] = { |
(...skipping 24 matching lines...) Expand all Loading... |
2318 helper.ResetTrans(); | 2326 helper.ResetTrans(); |
2319 data->SetStop(20); | 2327 data->SetStop(20); |
2320 data->Run(); | 2328 data->Run(); |
2321 | 2329 |
2322 helper.VerifyDataConsumed(); | 2330 helper.VerifyDataConsumed(); |
2323 } | 2331 } |
2324 | 2332 |
2325 // Verify that the client can correctly deal with the user callback attempting | 2333 // Verify that the client can correctly deal with the user callback attempting |
2326 // to start another transaction on a session that is closing down. See | 2334 // to start another transaction on a session that is closing down. See |
2327 // http://crbug.com/47455 | 2335 // http://crbug.com/47455 |
2328 TEST_P(SpdyNetworkTransactionTest, StartTransactionOnReadCallback) { | 2336 TEST_P(SpdyNetworkTransactionSpdy2Test, StartTransactionOnReadCallback) { |
2329 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 2337 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
2330 MockWrite writes[] = { CreateMockWrite(*req) }; | 2338 MockWrite writes[] = { CreateMockWrite(*req) }; |
2331 MockWrite writes2[] = { CreateMockWrite(*req) }; | 2339 MockWrite writes2[] = { CreateMockWrite(*req) }; |
2332 | 2340 |
2333 // The indicated length of this packet is longer than its actual length. When | 2341 // The indicated length of this packet is longer than its actual length. When |
2334 // the session receives an empty packet after this one, it shuts down the | 2342 // the session receives an empty packet after this one, it shuts down the |
2335 // session, and calls the read callback with the incomplete data. | 2343 // session, and calls the read callback with the incomplete data. |
2336 const uint8 kGetBodyFrame2[] = { | 2344 const uint8 kGetBodyFrame2[] = { |
2337 0x00, 0x00, 0x00, 0x01, | 2345 0x00, 0x00, 0x00, 0x01, |
2338 0x01, 0x00, 0x00, 0x07, | 2346 0x01, 0x00, 0x00, 0x07, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2370 // Start the transaction with basic parameters. | 2378 // Start the transaction with basic parameters. |
2371 TestCompletionCallback callback; | 2379 TestCompletionCallback callback; |
2372 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); | 2380 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); |
2373 EXPECT_EQ(ERR_IO_PENDING, rv); | 2381 EXPECT_EQ(ERR_IO_PENDING, rv); |
2374 rv = callback.WaitForResult(); | 2382 rv = callback.WaitForResult(); |
2375 | 2383 |
2376 const int kSize = 3000; | 2384 const int kSize = 3000; |
2377 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSize)); | 2385 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSize)); |
2378 rv = trans->Read( | 2386 rv = trans->Read( |
2379 buf, kSize, | 2387 buf, kSize, |
2380 base::Bind(&SpdyNetworkTransactionTest::StartTransactionCallback, | 2388 base::Bind(&SpdyNetworkTransactionSpdy2Test::StartTransactionCallback, |
2381 helper.session())); | 2389 helper.session())); |
2382 // This forces an err_IO_pending, which sets the callback. | 2390 // This forces an err_IO_pending, which sets the callback. |
2383 data->CompleteRead(); | 2391 data->CompleteRead(); |
2384 // This finishes the read. | 2392 // This finishes the read. |
2385 data->CompleteRead(); | 2393 data->CompleteRead(); |
2386 helper.VerifyDataConsumed(); | 2394 helper.VerifyDataConsumed(); |
2387 } | 2395 } |
2388 | 2396 |
2389 // Verify that the client can correctly deal with the user callback deleting the | 2397 // Verify that the client can correctly deal with the user callback deleting the |
2390 // transaction. Failures will usually be valgrind errors. See | 2398 // transaction. Failures will usually be valgrind errors. See |
2391 // http://crbug.com/46925 | 2399 // http://crbug.com/46925 |
2392 TEST_P(SpdyNetworkTransactionTest, DeleteSessionOnReadCallback) { | 2400 TEST_P(SpdyNetworkTransactionSpdy2Test, DeleteSessionOnReadCallback) { |
2393 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 2401 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
2394 MockWrite writes[] = { CreateMockWrite(*req) }; | 2402 MockWrite writes[] = { CreateMockWrite(*req) }; |
2395 | 2403 |
2396 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 2404 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
2397 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); | 2405 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); |
2398 MockRead reads[] = { | 2406 MockRead reads[] = { |
2399 CreateMockRead(*resp.get(), 2), | 2407 CreateMockRead(*resp.get(), 2), |
2400 MockRead(ASYNC, ERR_IO_PENDING, 3), // Force a pause | 2408 MockRead(ASYNC, ERR_IO_PENDING, 3), // Force a pause |
2401 CreateMockRead(*body.get(), 4), | 2409 CreateMockRead(*body.get(), 4), |
2402 MockRead(ASYNC, 0, 0, 5), // EOF | 2410 MockRead(ASYNC, 0, 0, 5), // EOF |
(...skipping 14 matching lines...) Expand all Loading... |
2417 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); | 2425 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); |
2418 EXPECT_EQ(ERR_IO_PENDING, rv); | 2426 EXPECT_EQ(ERR_IO_PENDING, rv); |
2419 rv = callback.WaitForResult(); | 2427 rv = callback.WaitForResult(); |
2420 | 2428 |
2421 // Setup a user callback which will delete the session, and clear out the | 2429 // Setup a user callback which will delete the session, and clear out the |
2422 // memory holding the stream object. Note that the callback deletes trans. | 2430 // memory holding the stream object. Note that the callback deletes trans. |
2423 const int kSize = 3000; | 2431 const int kSize = 3000; |
2424 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSize)); | 2432 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSize)); |
2425 rv = trans->Read( | 2433 rv = trans->Read( |
2426 buf, kSize, | 2434 buf, kSize, |
2427 base::Bind(&SpdyNetworkTransactionTest::DeleteSessionCallback, | 2435 base::Bind(&SpdyNetworkTransactionSpdy2Test::DeleteSessionCallback, |
2428 base::Unretained(&helper))); | 2436 base::Unretained(&helper))); |
2429 ASSERT_EQ(ERR_IO_PENDING, rv); | 2437 ASSERT_EQ(ERR_IO_PENDING, rv); |
2430 data->CompleteRead(); | 2438 data->CompleteRead(); |
2431 | 2439 |
2432 // Finish running rest of tasks. | 2440 // Finish running rest of tasks. |
2433 MessageLoop::current()->RunAllPending(); | 2441 MessageLoop::current()->RunAllPending(); |
2434 helper.VerifyDataConsumed(); | 2442 helper.VerifyDataConsumed(); |
2435 } | 2443 } |
2436 | 2444 |
2437 // Send a spdy request to www.google.com that gets redirected to www.foo.com. | 2445 // Send a spdy request to www.google.com that gets redirected to www.foo.com. |
2438 TEST_P(SpdyNetworkTransactionTest, RedirectGetRequest) { | 2446 TEST_P(SpdyNetworkTransactionSpdy2Test, RedirectGetRequest) { |
2439 // These are headers which the net::URLRequest tacks on. | 2447 // These are headers which the net::URLRequest tacks on. |
2440 const char* const kExtraHeaders[] = { | 2448 const char* const kExtraHeaders[] = { |
2441 "accept-encoding", | 2449 "accept-encoding", |
2442 "gzip,deflate", | 2450 "gzip,deflate", |
2443 }; | 2451 }; |
2444 const SpdyHeaderInfo kSynStartHeader = MakeSpdyHeader(spdy::SYN_STREAM); | 2452 const SpdyHeaderInfo kSynStartHeader = MakeSpdyHeader(spdy::SYN_STREAM); |
2445 const char* const kStandardGetHeaders[] = { | 2453 const char* const kStandardGetHeaders[] = { |
2446 "host", | 2454 "host", |
2447 "www.google.com", | 2455 "www.google.com", |
2448 "method", | 2456 "method", |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2533 std::string contents("hello!"); | 2541 std::string contents("hello!"); |
2534 EXPECT_EQ(contents, d.data_received()); | 2542 EXPECT_EQ(contents, d.data_received()); |
2535 } | 2543 } |
2536 EXPECT_TRUE(data->at_read_eof()); | 2544 EXPECT_TRUE(data->at_read_eof()); |
2537 EXPECT_TRUE(data->at_write_eof()); | 2545 EXPECT_TRUE(data->at_write_eof()); |
2538 EXPECT_TRUE(data2->at_read_eof()); | 2546 EXPECT_TRUE(data2->at_read_eof()); |
2539 EXPECT_TRUE(data2->at_write_eof()); | 2547 EXPECT_TRUE(data2->at_write_eof()); |
2540 } | 2548 } |
2541 | 2549 |
2542 // Detect response with upper case headers and reset the stream. | 2550 // Detect response with upper case headers and reset the stream. |
2543 TEST_P(SpdyNetworkTransactionTest, UpperCaseHeaders) { | 2551 TEST_P(SpdyNetworkTransactionSpdy2Test, UpperCaseHeaders) { |
2544 scoped_ptr<spdy::SpdyFrame> | 2552 scoped_ptr<spdy::SpdyFrame> |
2545 syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 2553 syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
2546 scoped_ptr<spdy::SpdyFrame> | 2554 scoped_ptr<spdy::SpdyFrame> |
2547 rst(ConstructSpdyRstStream(1, spdy::PROTOCOL_ERROR)); | 2555 rst(ConstructSpdyRstStream(1, spdy::PROTOCOL_ERROR)); |
2548 MockWrite writes[] = { | 2556 MockWrite writes[] = { |
2549 CreateMockWrite(*syn, 0), | 2557 CreateMockWrite(*syn, 0), |
2550 CreateMockWrite(*rst, 2), | 2558 CreateMockWrite(*rst, 2), |
2551 }; | 2559 }; |
2552 | 2560 |
2553 const char* const kExtraHeaders[] = {"X-UpperCase", "yes"}; | 2561 const char* const kExtraHeaders[] = {"X-UpperCase", "yes"}; |
(...skipping 13 matching lines...) Expand all Loading... |
2567 arraysize(writes))); | 2575 arraysize(writes))); |
2568 NormalSpdyTransactionHelper helper(CreateGetRequest(), | 2576 NormalSpdyTransactionHelper helper(CreateGetRequest(), |
2569 BoundNetLog(), GetParam()); | 2577 BoundNetLog(), GetParam()); |
2570 helper.RunToCompletion(data.get()); | 2578 helper.RunToCompletion(data.get()); |
2571 TransactionHelperResult out = helper.output(); | 2579 TransactionHelperResult out = helper.output(); |
2572 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); | 2580 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); |
2573 } | 2581 } |
2574 | 2582 |
2575 // Detect response with upper case headers in a HEADERS frame and reset the | 2583 // Detect response with upper case headers in a HEADERS frame and reset the |
2576 // stream. | 2584 // stream. |
2577 TEST_P(SpdyNetworkTransactionTest, UpperCaseHeadersInHeadersFrame) { | 2585 TEST_P(SpdyNetworkTransactionSpdy2Test, UpperCaseHeadersInHeadersFrame) { |
2578 scoped_ptr<spdy::SpdyFrame> | 2586 scoped_ptr<spdy::SpdyFrame> |
2579 syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 2587 syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
2580 scoped_ptr<spdy::SpdyFrame> | 2588 scoped_ptr<spdy::SpdyFrame> |
2581 rst(ConstructSpdyRstStream(1, spdy::PROTOCOL_ERROR)); | 2589 rst(ConstructSpdyRstStream(1, spdy::PROTOCOL_ERROR)); |
2582 MockWrite writes[] = { | 2590 MockWrite writes[] = { |
2583 CreateMockWrite(*syn, 0), | 2591 CreateMockWrite(*syn, 0), |
2584 CreateMockWrite(*rst, 2), | 2592 CreateMockWrite(*rst, 2), |
2585 }; | 2593 }; |
2586 | 2594 |
2587 static const char* const kInitialHeaders[] = { | 2595 static const char* const kInitialHeaders[] = { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2625 new DelayedSocketData(1, reads, arraysize(reads), | 2633 new DelayedSocketData(1, reads, arraysize(reads), |
2626 writes, arraysize(writes))); | 2634 writes, arraysize(writes))); |
2627 NormalSpdyTransactionHelper helper(CreateGetRequest(), | 2635 NormalSpdyTransactionHelper helper(CreateGetRequest(), |
2628 BoundNetLog(), GetParam()); | 2636 BoundNetLog(), GetParam()); |
2629 helper.RunToCompletion(data.get()); | 2637 helper.RunToCompletion(data.get()); |
2630 TransactionHelperResult out = helper.output(); | 2638 TransactionHelperResult out = helper.output(); |
2631 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); | 2639 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); |
2632 } | 2640 } |
2633 | 2641 |
2634 // Detect push stream with upper case headers and reset the stream. | 2642 // Detect push stream with upper case headers and reset the stream. |
2635 TEST_P(SpdyNetworkTransactionTest, UpperCaseHeadersOnPush) { | 2643 TEST_P(SpdyNetworkTransactionSpdy2Test, UpperCaseHeadersOnPush) { |
2636 scoped_ptr<spdy::SpdyFrame> | 2644 scoped_ptr<spdy::SpdyFrame> |
2637 syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 2645 syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
2638 scoped_ptr<spdy::SpdyFrame> | 2646 scoped_ptr<spdy::SpdyFrame> |
2639 rst(ConstructSpdyRstStream(2, spdy::PROTOCOL_ERROR)); | 2647 rst(ConstructSpdyRstStream(2, spdy::PROTOCOL_ERROR)); |
2640 MockWrite writes[] = { | 2648 MockWrite writes[] = { |
2641 CreateMockWrite(*syn, 0), | 2649 CreateMockWrite(*syn, 0), |
2642 CreateMockWrite(*rst, 2), | 2650 CreateMockWrite(*rst, 2), |
2643 }; | 2651 }; |
2644 | 2652 |
2645 scoped_ptr<spdy::SpdyFrame> | 2653 scoped_ptr<spdy::SpdyFrame> |
(...skipping 18 matching lines...) Expand all Loading... |
2664 arraysize(writes))); | 2672 arraysize(writes))); |
2665 NormalSpdyTransactionHelper helper(CreateGetRequest(), | 2673 NormalSpdyTransactionHelper helper(CreateGetRequest(), |
2666 BoundNetLog(), GetParam()); | 2674 BoundNetLog(), GetParam()); |
2667 helper.RunToCompletion(data.get()); | 2675 helper.RunToCompletion(data.get()); |
2668 TransactionHelperResult out = helper.output(); | 2676 TransactionHelperResult out = helper.output(); |
2669 EXPECT_EQ(OK, out.rv); | 2677 EXPECT_EQ(OK, out.rv); |
2670 } | 2678 } |
2671 | 2679 |
2672 // Send a spdy request to www.google.com. Get a pushed stream that redirects to | 2680 // Send a spdy request to www.google.com. Get a pushed stream that redirects to |
2673 // www.foo.com. | 2681 // www.foo.com. |
2674 TEST_P(SpdyNetworkTransactionTest, RedirectServerPush) { | 2682 TEST_P(SpdyNetworkTransactionSpdy2Test, RedirectServerPush) { |
2675 // These are headers which the net::URLRequest tacks on. | 2683 // These are headers which the net::URLRequest tacks on. |
2676 const char* const kExtraHeaders[] = { | 2684 const char* const kExtraHeaders[] = { |
2677 "accept-encoding", | 2685 "accept-encoding", |
2678 "gzip,deflate", | 2686 "gzip,deflate", |
2679 }; | 2687 }; |
2680 const SpdyHeaderInfo kSynStartHeader = MakeSpdyHeader(spdy::SYN_STREAM); | 2688 const SpdyHeaderInfo kSynStartHeader = MakeSpdyHeader(spdy::SYN_STREAM); |
2681 const char* const kStandardGetHeaders[] = { | 2689 const char* const kStandardGetHeaders[] = { |
2682 "host", | 2690 "host", |
2683 "www.google.com", | 2691 "www.google.com", |
2684 "method", | 2692 "method", |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2800 EXPECT_EQ(contents2, d2.data_received()); | 2808 EXPECT_EQ(contents2, d2.data_received()); |
2801 } | 2809 } |
2802 data->CompleteRead(); | 2810 data->CompleteRead(); |
2803 data2->CompleteRead(); | 2811 data2->CompleteRead(); |
2804 EXPECT_TRUE(data->at_read_eof()); | 2812 EXPECT_TRUE(data->at_read_eof()); |
2805 EXPECT_TRUE(data->at_write_eof()); | 2813 EXPECT_TRUE(data->at_write_eof()); |
2806 EXPECT_TRUE(data2->at_read_eof()); | 2814 EXPECT_TRUE(data2->at_read_eof()); |
2807 EXPECT_TRUE(data2->at_write_eof()); | 2815 EXPECT_TRUE(data2->at_write_eof()); |
2808 } | 2816 } |
2809 | 2817 |
2810 TEST_P(SpdyNetworkTransactionTest, ServerPushSingleDataFrame) { | 2818 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushSingleDataFrame) { |
2811 static const unsigned char kPushBodyFrame[] = { | 2819 static const unsigned char kPushBodyFrame[] = { |
2812 0x00, 0x00, 0x00, 0x02, // header, ID | 2820 0x00, 0x00, 0x00, 0x02, // header, ID |
2813 0x01, 0x00, 0x00, 0x06, // FIN, length | 2821 0x01, 0x00, 0x00, 0x06, // FIN, length |
2814 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | 2822 'p', 'u', 's', 'h', 'e', 'd' // "pushed" |
2815 }; | 2823 }; |
2816 scoped_ptr<spdy::SpdyFrame> | 2824 scoped_ptr<spdy::SpdyFrame> |
2817 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 2825 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
2818 scoped_ptr<spdy::SpdyFrame> | 2826 scoped_ptr<spdy::SpdyFrame> |
2819 stream1_body(ConstructSpdyBodyFrame(1, true)); | 2827 stream1_body(ConstructSpdyBodyFrame(1, true)); |
2820 MockWrite writes[] = { | 2828 MockWrite writes[] = { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2853 | 2861 |
2854 // Verify the SYN_REPLY. | 2862 // Verify the SYN_REPLY. |
2855 EXPECT_TRUE(response.headers != NULL); | 2863 EXPECT_TRUE(response.headers != NULL); |
2856 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 2864 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
2857 | 2865 |
2858 // Verify the pushed stream. | 2866 // Verify the pushed stream. |
2859 EXPECT_TRUE(response2.headers != NULL); | 2867 EXPECT_TRUE(response2.headers != NULL); |
2860 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 2868 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
2861 } | 2869 } |
2862 | 2870 |
2863 TEST_P(SpdyNetworkTransactionTest, ServerPushSingleDataFrame2) { | 2871 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushSingleDataFrame2) { |
2864 static const unsigned char kPushBodyFrame[] = { | 2872 static const unsigned char kPushBodyFrame[] = { |
2865 0x00, 0x00, 0x00, 0x02, // header, ID | 2873 0x00, 0x00, 0x00, 0x02, // header, ID |
2866 0x01, 0x00, 0x00, 0x06, // FIN, length | 2874 0x01, 0x00, 0x00, 0x06, // FIN, length |
2867 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | 2875 'p', 'u', 's', 'h', 'e', 'd' // "pushed" |
2868 }; | 2876 }; |
2869 scoped_ptr<spdy::SpdyFrame> | 2877 scoped_ptr<spdy::SpdyFrame> |
2870 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 2878 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
2871 MockWrite writes[] = { | 2879 MockWrite writes[] = { |
2872 CreateMockWrite(*stream1_syn, 1), | 2880 CreateMockWrite(*stream1_syn, 1), |
2873 }; | 2881 }; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2906 | 2914 |
2907 // Verify the SYN_REPLY. | 2915 // Verify the SYN_REPLY. |
2908 EXPECT_TRUE(response.headers != NULL); | 2916 EXPECT_TRUE(response.headers != NULL); |
2909 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 2917 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
2910 | 2918 |
2911 // Verify the pushed stream. | 2919 // Verify the pushed stream. |
2912 EXPECT_TRUE(response2.headers != NULL); | 2920 EXPECT_TRUE(response2.headers != NULL); |
2913 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 2921 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
2914 } | 2922 } |
2915 | 2923 |
2916 TEST_P(SpdyNetworkTransactionTest, ServerPushServerAborted) { | 2924 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushServerAborted) { |
2917 scoped_ptr<spdy::SpdyFrame> | 2925 scoped_ptr<spdy::SpdyFrame> |
2918 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 2926 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
2919 scoped_ptr<spdy::SpdyFrame> | 2927 scoped_ptr<spdy::SpdyFrame> |
2920 stream1_body(ConstructSpdyBodyFrame(1, true)); | 2928 stream1_body(ConstructSpdyBodyFrame(1, true)); |
2921 MockWrite writes[] = { | 2929 MockWrite writes[] = { |
2922 CreateMockWrite(*stream1_syn, 1), | 2930 CreateMockWrite(*stream1_syn, 1), |
2923 }; | 2931 }; |
2924 | 2932 |
2925 scoped_ptr<spdy::SpdyFrame> | 2933 scoped_ptr<spdy::SpdyFrame> |
2926 stream1_reply(ConstructSpdyGetSynReply(NULL, 0, 1)); | 2934 stream1_reply(ConstructSpdyGetSynReply(NULL, 0, 1)); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2968 << data->write_count() | 2976 << data->write_count() |
2969 << " Write index: " | 2977 << " Write index: " |
2970 << data->write_index(); | 2978 << data->write_index(); |
2971 | 2979 |
2972 // Verify the SYN_REPLY. | 2980 // Verify the SYN_REPLY. |
2973 HttpResponseInfo response = *trans->GetResponseInfo(); | 2981 HttpResponseInfo response = *trans->GetResponseInfo(); |
2974 EXPECT_TRUE(response.headers != NULL); | 2982 EXPECT_TRUE(response.headers != NULL); |
2975 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 2983 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
2976 } | 2984 } |
2977 | 2985 |
2978 TEST_P(SpdyNetworkTransactionTest, ServerPushDuplicate) { | 2986 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushDuplicate) { |
2979 // Verify that we don't leak streams and that we properly send a reset | 2987 // Verify that we don't leak streams and that we properly send a reset |
2980 // if the server pushes the same stream twice. | 2988 // if the server pushes the same stream twice. |
2981 static const unsigned char kPushBodyFrame[] = { | 2989 static const unsigned char kPushBodyFrame[] = { |
2982 0x00, 0x00, 0x00, 0x02, // header, ID | 2990 0x00, 0x00, 0x00, 0x02, // header, ID |
2983 0x01, 0x00, 0x00, 0x06, // FIN, length | 2991 0x01, 0x00, 0x00, 0x06, // FIN, length |
2984 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | 2992 'p', 'u', 's', 'h', 'e', 'd' // "pushed" |
2985 }; | 2993 }; |
2986 | 2994 |
2987 scoped_ptr<spdy::SpdyFrame> | 2995 scoped_ptr<spdy::SpdyFrame> |
2988 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 2996 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3034 | 3042 |
3035 // Verify the SYN_REPLY. | 3043 // Verify the SYN_REPLY. |
3036 EXPECT_TRUE(response.headers != NULL); | 3044 EXPECT_TRUE(response.headers != NULL); |
3037 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3045 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
3038 | 3046 |
3039 // Verify the pushed stream. | 3047 // Verify the pushed stream. |
3040 EXPECT_TRUE(response2.headers != NULL); | 3048 EXPECT_TRUE(response2.headers != NULL); |
3041 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 3049 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
3042 } | 3050 } |
3043 | 3051 |
3044 TEST_P(SpdyNetworkTransactionTest, ServerPushMultipleDataFrame) { | 3052 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushMultipleDataFrame) { |
3045 static const unsigned char kPushBodyFrame1[] = { | 3053 static const unsigned char kPushBodyFrame1[] = { |
3046 0x00, 0x00, 0x00, 0x02, // header, ID | 3054 0x00, 0x00, 0x00, 0x02, // header, ID |
3047 0x01, 0x00, 0x00, 0x1F, // FIN, length | 3055 0x01, 0x00, 0x00, 0x1F, // FIN, length |
3048 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | 3056 'p', 'u', 's', 'h', 'e', 'd' // "pushed" |
3049 }; | 3057 }; |
3050 static const char kPushBodyFrame2[] = " my darling"; | 3058 static const char kPushBodyFrame2[] = " my darling"; |
3051 static const char kPushBodyFrame3[] = " hello"; | 3059 static const char kPushBodyFrame3[] = " hello"; |
3052 static const char kPushBodyFrame4[] = " my baby"; | 3060 static const char kPushBodyFrame4[] = " my baby"; |
3053 | 3061 |
3054 scoped_ptr<spdy::SpdyFrame> | 3062 scoped_ptr<spdy::SpdyFrame> |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3097 | 3105 |
3098 // Verify the SYN_REPLY. | 3106 // Verify the SYN_REPLY. |
3099 EXPECT_TRUE(response.headers != NULL); | 3107 EXPECT_TRUE(response.headers != NULL); |
3100 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3108 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
3101 | 3109 |
3102 // Verify the pushed stream. | 3110 // Verify the pushed stream. |
3103 EXPECT_TRUE(response2.headers != NULL); | 3111 EXPECT_TRUE(response2.headers != NULL); |
3104 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 3112 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
3105 } | 3113 } |
3106 | 3114 |
3107 TEST_P(SpdyNetworkTransactionTest, ServerPushMultipleDataFrameInterrupted) { | 3115 TEST_P(SpdyNetworkTransactionSpdy2Test, |
| 3116 ServerPushMultipleDataFrameInterrupted) { |
3108 SpdySession::set_use_flow_control(SpdySession::kDisableFlowControl); | 3117 SpdySession::set_use_flow_control(SpdySession::kDisableFlowControl); |
3109 | 3118 |
3110 static const unsigned char kPushBodyFrame1[] = { | 3119 static const unsigned char kPushBodyFrame1[] = { |
3111 0x00, 0x00, 0x00, 0x02, // header, ID | 3120 0x00, 0x00, 0x00, 0x02, // header, ID |
3112 0x01, 0x00, 0x00, 0x1F, // FIN, length | 3121 0x01, 0x00, 0x00, 0x1F, // FIN, length |
3113 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | 3122 'p', 'u', 's', 'h', 'e', 'd' // "pushed" |
3114 }; | 3123 }; |
3115 static const char kPushBodyFrame2[] = " my darling"; | 3124 static const char kPushBodyFrame2[] = " my darling"; |
3116 static const char kPushBodyFrame3[] = " hello"; | 3125 static const char kPushBodyFrame3[] = " hello"; |
3117 static const char kPushBodyFrame4[] = " my baby"; | 3126 static const char kPushBodyFrame4[] = " my baby"; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3165 EXPECT_TRUE(response.headers != NULL); | 3174 EXPECT_TRUE(response.headers != NULL); |
3166 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3175 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
3167 | 3176 |
3168 // Verify the pushed stream. | 3177 // Verify the pushed stream. |
3169 EXPECT_TRUE(response2.headers != NULL); | 3178 EXPECT_TRUE(response2.headers != NULL); |
3170 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 3179 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
3171 | 3180 |
3172 SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); | 3181 SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); |
3173 } | 3182 } |
3174 | 3183 |
3175 TEST_P(SpdyNetworkTransactionTest, ServerPushInvalidAssociatedStreamID0) { | 3184 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushInvalidAssociatedStreamID0) { |
3176 scoped_ptr<spdy::SpdyFrame> | 3185 scoped_ptr<spdy::SpdyFrame> |
3177 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 3186 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
3178 scoped_ptr<spdy::SpdyFrame> | 3187 scoped_ptr<spdy::SpdyFrame> |
3179 stream1_body(ConstructSpdyBodyFrame(1, true)); | 3188 stream1_body(ConstructSpdyBodyFrame(1, true)); |
3180 scoped_ptr<spdy::SpdyFrame> | 3189 scoped_ptr<spdy::SpdyFrame> |
3181 stream2_rst(ConstructSpdyRstStream(2, spdy::INVALID_STREAM)); | 3190 stream2_rst(ConstructSpdyRstStream(2, spdy::INVALID_STREAM)); |
3182 MockWrite writes[] = { | 3191 MockWrite writes[] = { |
3183 CreateMockWrite(*stream1_syn, 1), | 3192 CreateMockWrite(*stream1_syn, 1), |
3184 CreateMockWrite(*stream2_rst, 4), | 3193 CreateMockWrite(*stream2_rst, 4), |
3185 }; | 3194 }; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3227 << data->write_count() | 3236 << data->write_count() |
3228 << " Write index: " | 3237 << " Write index: " |
3229 << data->write_index(); | 3238 << data->write_index(); |
3230 | 3239 |
3231 // Verify the SYN_REPLY. | 3240 // Verify the SYN_REPLY. |
3232 HttpResponseInfo response = *trans->GetResponseInfo(); | 3241 HttpResponseInfo response = *trans->GetResponseInfo(); |
3233 EXPECT_TRUE(response.headers != NULL); | 3242 EXPECT_TRUE(response.headers != NULL); |
3234 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3243 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
3235 } | 3244 } |
3236 | 3245 |
3237 TEST_P(SpdyNetworkTransactionTest, ServerPushInvalidAssociatedStreamID9) { | 3246 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushInvalidAssociatedStreamID9) { |
3238 scoped_ptr<spdy::SpdyFrame> | 3247 scoped_ptr<spdy::SpdyFrame> |
3239 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 3248 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
3240 scoped_ptr<spdy::SpdyFrame> | 3249 scoped_ptr<spdy::SpdyFrame> |
3241 stream1_body(ConstructSpdyBodyFrame(1, true)); | 3250 stream1_body(ConstructSpdyBodyFrame(1, true)); |
3242 scoped_ptr<spdy::SpdyFrame> | 3251 scoped_ptr<spdy::SpdyFrame> |
3243 stream2_rst(ConstructSpdyRstStream(2, spdy::INVALID_ASSOCIATED_STREAM)); | 3252 stream2_rst(ConstructSpdyRstStream(2, spdy::INVALID_ASSOCIATED_STREAM)); |
3244 MockWrite writes[] = { | 3253 MockWrite writes[] = { |
3245 CreateMockWrite(*stream1_syn, 1), | 3254 CreateMockWrite(*stream1_syn, 1), |
3246 CreateMockWrite(*stream2_rst, 4), | 3255 CreateMockWrite(*stream2_rst, 4), |
3247 }; | 3256 }; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3289 << data->write_count() | 3298 << data->write_count() |
3290 << " Write index: " | 3299 << " Write index: " |
3291 << data->write_index(); | 3300 << data->write_index(); |
3292 | 3301 |
3293 // Verify the SYN_REPLY. | 3302 // Verify the SYN_REPLY. |
3294 HttpResponseInfo response = *trans->GetResponseInfo(); | 3303 HttpResponseInfo response = *trans->GetResponseInfo(); |
3295 EXPECT_TRUE(response.headers != NULL); | 3304 EXPECT_TRUE(response.headers != NULL); |
3296 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3305 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
3297 } | 3306 } |
3298 | 3307 |
3299 TEST_P(SpdyNetworkTransactionTest, ServerPushNoURL) { | 3308 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushNoURL) { |
3300 scoped_ptr<spdy::SpdyFrame> | 3309 scoped_ptr<spdy::SpdyFrame> |
3301 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 3310 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
3302 scoped_ptr<spdy::SpdyFrame> | 3311 scoped_ptr<spdy::SpdyFrame> |
3303 stream1_body(ConstructSpdyBodyFrame(1, true)); | 3312 stream1_body(ConstructSpdyBodyFrame(1, true)); |
3304 scoped_ptr<spdy::SpdyFrame> | 3313 scoped_ptr<spdy::SpdyFrame> |
3305 stream2_rst(ConstructSpdyRstStream(2, spdy::PROTOCOL_ERROR)); | 3314 stream2_rst(ConstructSpdyRstStream(2, spdy::PROTOCOL_ERROR)); |
3306 MockWrite writes[] = { | 3315 MockWrite writes[] = { |
3307 CreateMockWrite(*stream1_syn, 1), | 3316 CreateMockWrite(*stream1_syn, 1), |
3308 CreateMockWrite(*stream2_rst, 4), | 3317 CreateMockWrite(*stream2_rst, 4), |
3309 }; | 3318 }; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3348 << data->write_index(); | 3357 << data->write_index(); |
3349 | 3358 |
3350 // Verify the SYN_REPLY. | 3359 // Verify the SYN_REPLY. |
3351 HttpResponseInfo response = *trans->GetResponseInfo(); | 3360 HttpResponseInfo response = *trans->GetResponseInfo(); |
3352 EXPECT_TRUE(response.headers != NULL); | 3361 EXPECT_TRUE(response.headers != NULL); |
3353 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 3362 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
3354 } | 3363 } |
3355 | 3364 |
3356 // Verify that various SynReply headers parse correctly through the | 3365 // Verify that various SynReply headers parse correctly through the |
3357 // HTTP layer. | 3366 // HTTP layer. |
3358 TEST_P(SpdyNetworkTransactionTest, SynReplyHeaders) { | 3367 TEST_P(SpdyNetworkTransactionSpdy2Test, SynReplyHeaders) { |
3359 struct SynReplyHeadersTests { | 3368 struct SynReplyHeadersTests { |
3360 int num_headers; | 3369 int num_headers; |
3361 const char* extra_headers[5]; | 3370 const char* extra_headers[5]; |
3362 const char* expected_headers; | 3371 const char* expected_headers; |
3363 } test_cases[] = { | 3372 } test_cases[] = { |
3364 // This uses a multi-valued cookie header. | 3373 // This uses a multi-valued cookie header. |
3365 { 2, | 3374 { 2, |
3366 { "cookie", "val1", | 3375 { "cookie", "val1", |
3367 "cookie", "val2", // will get appended separated by NULL | 3376 "cookie", "val2", // will get appended separated by NULL |
3368 NULL | 3377 NULL |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3429 lines.append(": "); | 3438 lines.append(": "); |
3430 lines.append(value); | 3439 lines.append(value); |
3431 lines.append("\n"); | 3440 lines.append("\n"); |
3432 } | 3441 } |
3433 EXPECT_EQ(std::string(test_cases[i].expected_headers), lines); | 3442 EXPECT_EQ(std::string(test_cases[i].expected_headers), lines); |
3434 } | 3443 } |
3435 } | 3444 } |
3436 | 3445 |
3437 // Verify that various SynReply headers parse vary fields correctly | 3446 // Verify that various SynReply headers parse vary fields correctly |
3438 // through the HTTP layer, and the response matches the request. | 3447 // through the HTTP layer, and the response matches the request. |
3439 TEST_P(SpdyNetworkTransactionTest, SynReplyHeadersVary) { | 3448 TEST_P(SpdyNetworkTransactionSpdy2Test, SynReplyHeadersVary) { |
3440 static const SpdyHeaderInfo syn_reply_info = { | 3449 static const SpdyHeaderInfo syn_reply_info = { |
3441 spdy::SYN_REPLY, // Syn Reply | 3450 spdy::SYN_REPLY, // Syn Reply |
3442 1, // Stream ID | 3451 1, // Stream ID |
3443 0, // Associated Stream ID | 3452 0, // Associated Stream ID |
3444 net::ConvertRequestPriorityToSpdyPriority(LOWEST), | 3453 net::ConvertRequestPriorityToSpdyPriority(LOWEST), |
3445 // Priority | 3454 // Priority |
3446 spdy::CONTROL_FLAG_NONE, // Control Flags | 3455 spdy::CONTROL_FLAG_NONE, // Control Flags |
3447 false, // Compressed | 3456 false, // Compressed |
3448 spdy::INVALID, // Status | 3457 spdy::INVALID, // Status |
3449 NULL, // Data | 3458 NULL, // Data |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3598 ConstructSpdyReplyString(test_cases[i].extra_headers[1], | 3607 ConstructSpdyReplyString(test_cases[i].extra_headers[1], |
3599 test_cases[i].num_headers[1], | 3608 test_cases[i].num_headers[1], |
3600 reply_buffer, | 3609 reply_buffer, |
3601 256); | 3610 256); |
3602 | 3611 |
3603 EXPECT_EQ(std::string(reply_buffer), lines) << i; | 3612 EXPECT_EQ(std::string(reply_buffer), lines) << i; |
3604 } | 3613 } |
3605 } | 3614 } |
3606 | 3615 |
3607 // Verify that we don't crash on invalid SynReply responses. | 3616 // Verify that we don't crash on invalid SynReply responses. |
3608 TEST_P(SpdyNetworkTransactionTest, InvalidSynReply) { | 3617 TEST_P(SpdyNetworkTransactionSpdy2Test, InvalidSynReply) { |
3609 const SpdyHeaderInfo kSynStartHeader = { | 3618 const SpdyHeaderInfo kSynStartHeader = { |
3610 spdy::SYN_REPLY, // Kind = SynReply | 3619 spdy::SYN_REPLY, // Kind = SynReply |
3611 1, // Stream ID | 3620 1, // Stream ID |
3612 0, // Associated stream ID | 3621 0, // Associated stream ID |
3613 net::ConvertRequestPriorityToSpdyPriority(LOWEST), | 3622 net::ConvertRequestPriorityToSpdyPriority(LOWEST), |
3614 // Priority | 3623 // Priority |
3615 spdy::CONTROL_FLAG_NONE, // Control Flags | 3624 spdy::CONTROL_FLAG_NONE, // Control Flags |
3616 false, // Compressed | 3625 false, // Compressed |
3617 spdy::INVALID, // Status | 3626 spdy::INVALID, // Status |
3618 NULL, // Data | 3627 NULL, // Data |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3668 writes, arraysize(writes))); | 3677 writes, arraysize(writes))); |
3669 NormalSpdyTransactionHelper helper(CreateGetRequest(), | 3678 NormalSpdyTransactionHelper helper(CreateGetRequest(), |
3670 BoundNetLog(), GetParam()); | 3679 BoundNetLog(), GetParam()); |
3671 helper.RunToCompletion(data.get()); | 3680 helper.RunToCompletion(data.get()); |
3672 TransactionHelperResult out = helper.output(); | 3681 TransactionHelperResult out = helper.output(); |
3673 EXPECT_EQ(ERR_INCOMPLETE_SPDY_HEADERS, out.rv); | 3682 EXPECT_EQ(ERR_INCOMPLETE_SPDY_HEADERS, out.rv); |
3674 } | 3683 } |
3675 } | 3684 } |
3676 | 3685 |
3677 // Verify that we don't crash on some corrupt frames. | 3686 // Verify that we don't crash on some corrupt frames. |
3678 TEST_P(SpdyNetworkTransactionTest, CorruptFrameSessionError) { | 3687 TEST_P(SpdyNetworkTransactionSpdy2Test, CorruptFrameSessionError) { |
3679 // This is the length field that's too short. | 3688 // This is the length field that's too short. |
3680 scoped_ptr<spdy::SpdyFrame> syn_reply_wrong_length( | 3689 scoped_ptr<spdy::SpdyFrame> syn_reply_wrong_length( |
3681 ConstructSpdyGetSynReply(NULL, 0, 1)); | 3690 ConstructSpdyGetSynReply(NULL, 0, 1)); |
3682 syn_reply_wrong_length->set_length(syn_reply_wrong_length->length() - 4); | 3691 syn_reply_wrong_length->set_length(syn_reply_wrong_length->length() - 4); |
3683 | 3692 |
3684 struct SynReplyTests { | 3693 struct SynReplyTests { |
3685 const spdy::SpdyFrame* syn_reply; | 3694 const spdy::SpdyFrame* syn_reply; |
3686 } test_cases[] = { | 3695 } test_cases[] = { |
3687 { syn_reply_wrong_length.get(), }, | 3696 { syn_reply_wrong_length.get(), }, |
3688 }; | 3697 }; |
(...skipping 18 matching lines...) Expand all Loading... |
3707 writes, arraysize(writes))); | 3716 writes, arraysize(writes))); |
3708 NormalSpdyTransactionHelper helper(CreateGetRequest(), | 3717 NormalSpdyTransactionHelper helper(CreateGetRequest(), |
3709 BoundNetLog(), GetParam()); | 3718 BoundNetLog(), GetParam()); |
3710 helper.RunToCompletion(data.get()); | 3719 helper.RunToCompletion(data.get()); |
3711 TransactionHelperResult out = helper.output(); | 3720 TransactionHelperResult out = helper.output(); |
3712 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); | 3721 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); |
3713 } | 3722 } |
3714 } | 3723 } |
3715 | 3724 |
3716 // Test that we shutdown correctly on write errors. | 3725 // Test that we shutdown correctly on write errors. |
3717 TEST_P(SpdyNetworkTransactionTest, WriteError) { | 3726 TEST_P(SpdyNetworkTransactionSpdy2Test, WriteError) { |
3718 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 3727 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
3719 MockWrite writes[] = { | 3728 MockWrite writes[] = { |
3720 // We'll write 10 bytes successfully | 3729 // We'll write 10 bytes successfully |
3721 MockWrite(ASYNC, req->data(), 10), | 3730 MockWrite(ASYNC, req->data(), 10), |
3722 // Followed by ERROR! | 3731 // Followed by ERROR! |
3723 MockWrite(ASYNC, ERR_FAILED), | 3732 MockWrite(ASYNC, ERR_FAILED), |
3724 }; | 3733 }; |
3725 | 3734 |
3726 scoped_ptr<DelayedSocketData> data( | 3735 scoped_ptr<DelayedSocketData> data( |
3727 new DelayedSocketData(2, NULL, 0, | 3736 new DelayedSocketData(2, NULL, 0, |
3728 writes, arraysize(writes))); | 3737 writes, arraysize(writes))); |
3729 NormalSpdyTransactionHelper helper(CreateGetRequest(), | 3738 NormalSpdyTransactionHelper helper(CreateGetRequest(), |
3730 BoundNetLog(), GetParam()); | 3739 BoundNetLog(), GetParam()); |
3731 helper.RunToCompletion(data.get()); | 3740 helper.RunToCompletion(data.get()); |
3732 TransactionHelperResult out = helper.output(); | 3741 TransactionHelperResult out = helper.output(); |
3733 EXPECT_EQ(ERR_FAILED, out.rv); | 3742 EXPECT_EQ(ERR_FAILED, out.rv); |
3734 data->Reset(); | 3743 data->Reset(); |
3735 } | 3744 } |
3736 | 3745 |
3737 // Test that partial writes work. | 3746 // Test that partial writes work. |
3738 TEST_P(SpdyNetworkTransactionTest, PartialWrite) { | 3747 TEST_P(SpdyNetworkTransactionSpdy2Test, PartialWrite) { |
3739 // Chop the SYN_STREAM frame into 5 chunks. | 3748 // Chop the SYN_STREAM frame into 5 chunks. |
3740 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 3749 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
3741 const int kChunks = 5; | 3750 const int kChunks = 5; |
3742 scoped_array<MockWrite> writes(ChopWriteFrame(*req.get(), kChunks)); | 3751 scoped_array<MockWrite> writes(ChopWriteFrame(*req.get(), kChunks)); |
3743 | 3752 |
3744 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 3753 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
3745 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); | 3754 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); |
3746 MockRead reads[] = { | 3755 MockRead reads[] = { |
3747 CreateMockRead(*resp), | 3756 CreateMockRead(*resp), |
3748 CreateMockRead(*body), | 3757 CreateMockRead(*body), |
3749 MockRead(ASYNC, 0, 0) // EOF | 3758 MockRead(ASYNC, 0, 0) // EOF |
3750 }; | 3759 }; |
3751 | 3760 |
3752 scoped_ptr<DelayedSocketData> data( | 3761 scoped_ptr<DelayedSocketData> data( |
3753 new DelayedSocketData(kChunks, reads, arraysize(reads), | 3762 new DelayedSocketData(kChunks, reads, arraysize(reads), |
3754 writes.get(), kChunks)); | 3763 writes.get(), kChunks)); |
3755 NormalSpdyTransactionHelper helper(CreateGetRequest(), | 3764 NormalSpdyTransactionHelper helper(CreateGetRequest(), |
3756 BoundNetLog(), GetParam()); | 3765 BoundNetLog(), GetParam()); |
3757 helper.RunToCompletion(data.get()); | 3766 helper.RunToCompletion(data.get()); |
3758 TransactionHelperResult out = helper.output(); | 3767 TransactionHelperResult out = helper.output(); |
3759 EXPECT_EQ(OK, out.rv); | 3768 EXPECT_EQ(OK, out.rv); |
3760 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 3769 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
3761 EXPECT_EQ("hello!", out.response_data); | 3770 EXPECT_EQ("hello!", out.response_data); |
3762 } | 3771 } |
3763 | 3772 |
3764 // In this test, we enable compression, but get a uncompressed SynReply from | 3773 // In this test, we enable compression, but get a uncompressed SynReply from |
3765 // the server. Verify that teardown is all clean. | 3774 // the server. Verify that teardown is all clean. |
3766 TEST_P(SpdyNetworkTransactionTest, DecompressFailureOnSynReply) { | 3775 TEST_P(SpdyNetworkTransactionSpdy2Test, DecompressFailureOnSynReply) { |
3767 // For this test, we turn on the normal compression. | 3776 // For this test, we turn on the normal compression. |
3768 EnableCompression(true); | 3777 EnableCompression(true); |
3769 | 3778 |
3770 scoped_ptr<spdy::SpdyFrame> compressed( | 3779 scoped_ptr<spdy::SpdyFrame> compressed( |
3771 ConstructSpdyGet(NULL, 0, true, 1, LOWEST)); | 3780 ConstructSpdyGet(NULL, 0, true, 1, LOWEST)); |
3772 scoped_ptr<spdy::SpdyFrame> rst( | 3781 scoped_ptr<spdy::SpdyFrame> rst( |
3773 ConstructSpdyRstStream(1, spdy::PROTOCOL_ERROR)); | 3782 ConstructSpdyRstStream(1, spdy::PROTOCOL_ERROR)); |
3774 MockWrite writes[] = { | 3783 MockWrite writes[] = { |
3775 CreateMockWrite(*compressed), | 3784 CreateMockWrite(*compressed), |
3776 }; | 3785 }; |
(...skipping 11 matching lines...) Expand all Loading... |
3788 BoundNetLog(), GetParam()); | 3797 BoundNetLog(), GetParam()); |
3789 helper.RunToCompletion(data.get()); | 3798 helper.RunToCompletion(data.get()); |
3790 TransactionHelperResult out = helper.output(); | 3799 TransactionHelperResult out = helper.output(); |
3791 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); | 3800 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); |
3792 data->Reset(); | 3801 data->Reset(); |
3793 | 3802 |
3794 EnableCompression(false); | 3803 EnableCompression(false); |
3795 } | 3804 } |
3796 | 3805 |
3797 // Test that the NetLog contains good data for a simple GET request. | 3806 // Test that the NetLog contains good data for a simple GET request. |
3798 TEST_P(SpdyNetworkTransactionTest, NetLog) { | 3807 TEST_P(SpdyNetworkTransactionSpdy2Test, NetLog) { |
3799 static const char* const kExtraHeaders[] = { | 3808 static const char* const kExtraHeaders[] = { |
3800 "user-agent", "Chrome", | 3809 "user-agent", "Chrome", |
3801 }; | 3810 }; |
3802 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(kExtraHeaders, 1, false, 1, | 3811 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(kExtraHeaders, 1, false, 1, |
3803 LOWEST)); | 3812 LOWEST)); |
3804 MockWrite writes[] = { CreateMockWrite(*req) }; | 3813 MockWrite writes[] = { CreateMockWrite(*req) }; |
3805 | 3814 |
3806 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 3815 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
3807 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); | 3816 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); |
3808 MockRead reads[] = { | 3817 MockRead reads[] = { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3876 it != end; | 3885 it != end; |
3877 ++it) { | 3886 ++it) { |
3878 EXPECT_EQ(it->second, (*headers)[it->first]); | 3887 EXPECT_EQ(it->second, (*headers)[it->first]); |
3879 } | 3888 } |
3880 } | 3889 } |
3881 | 3890 |
3882 // Since we buffer the IO from the stream to the renderer, this test verifies | 3891 // Since we buffer the IO from the stream to the renderer, this test verifies |
3883 // that when we read out the maximum amount of data (e.g. we received 50 bytes | 3892 // that when we read out the maximum amount of data (e.g. we received 50 bytes |
3884 // on the network, but issued a Read for only 5 of those bytes) that the data | 3893 // on the network, but issued a Read for only 5 of those bytes) that the data |
3885 // flow still works correctly. | 3894 // flow still works correctly. |
3886 TEST_P(SpdyNetworkTransactionTest, BufferFull) { | 3895 TEST_P(SpdyNetworkTransactionSpdy2Test, BufferFull) { |
3887 SpdySession::set_use_flow_control(SpdySession::kDisableFlowControl); | 3896 SpdySession::set_use_flow_control(SpdySession::kDisableFlowControl); |
3888 | 3897 |
3889 spdy::SpdyFramer framer; | 3898 spdy::SpdyFramer framer; |
3890 | 3899 |
3891 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 3900 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
3892 MockWrite writes[] = { CreateMockWrite(*req) }; | 3901 MockWrite writes[] = { CreateMockWrite(*req) }; |
3893 | 3902 |
3894 // 2 data frames in a single read. | 3903 // 2 data frames in a single read. |
3895 scoped_ptr<spdy::SpdyFrame> data_frame_1( | 3904 scoped_ptr<spdy::SpdyFrame> data_frame_1( |
3896 framer.CreateDataFrame(1, "goodby", 6, spdy::DATA_FLAG_NONE)); | 3905 framer.CreateDataFrame(1, "goodby", 6, spdy::DATA_FLAG_NONE)); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3975 EXPECT_EQ(OK, out.rv); | 3984 EXPECT_EQ(OK, out.rv); |
3976 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 3985 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
3977 EXPECT_EQ("goodbye world", out.response_data); | 3986 EXPECT_EQ("goodbye world", out.response_data); |
3978 | 3987 |
3979 SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); | 3988 SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); |
3980 } | 3989 } |
3981 | 3990 |
3982 // Verify that basic buffering works; when multiple data frames arrive | 3991 // Verify that basic buffering works; when multiple data frames arrive |
3983 // at the same time, ensure that we don't notify a read completion for | 3992 // at the same time, ensure that we don't notify a read completion for |
3984 // each data frame individually. | 3993 // each data frame individually. |
3985 TEST_P(SpdyNetworkTransactionTest, Buffering) { | 3994 TEST_P(SpdyNetworkTransactionSpdy2Test, Buffering) { |
3986 SpdySession::set_use_flow_control(SpdySession::kDisableFlowControl); | 3995 SpdySession::set_use_flow_control(SpdySession::kDisableFlowControl); |
3987 | 3996 |
3988 spdy::SpdyFramer framer; | 3997 spdy::SpdyFramer framer; |
3989 | 3998 |
3990 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 3999 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
3991 MockWrite writes[] = { CreateMockWrite(*req) }; | 4000 MockWrite writes[] = { CreateMockWrite(*req) }; |
3992 | 4001 |
3993 // 4 data frames in a single read. | 4002 // 4 data frames in a single read. |
3994 scoped_ptr<spdy::SpdyFrame> data_frame( | 4003 scoped_ptr<spdy::SpdyFrame> data_frame( |
3995 framer.CreateDataFrame(1, "message", 7, spdy::DATA_FLAG_NONE)); | 4004 framer.CreateDataFrame(1, "message", 7, spdy::DATA_FLAG_NONE)); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4074 helper.VerifyDataConsumed(); | 4083 helper.VerifyDataConsumed(); |
4075 | 4084 |
4076 EXPECT_EQ(OK, out.rv); | 4085 EXPECT_EQ(OK, out.rv); |
4077 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 4086 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
4078 EXPECT_EQ("messagemessagemessagemessage", out.response_data); | 4087 EXPECT_EQ("messagemessagemessagemessage", out.response_data); |
4079 | 4088 |
4080 SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); | 4089 SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); |
4081 } | 4090 } |
4082 | 4091 |
4083 // Verify the case where we buffer data but read it after it has been buffered. | 4092 // Verify the case where we buffer data but read it after it has been buffered. |
4084 TEST_P(SpdyNetworkTransactionTest, BufferedAll) { | 4093 TEST_P(SpdyNetworkTransactionSpdy2Test, BufferedAll) { |
4085 spdy::SpdyFramer framer; | 4094 spdy::SpdyFramer framer; |
4086 | 4095 |
4087 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 4096 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
4088 MockWrite writes[] = { CreateMockWrite(*req) }; | 4097 MockWrite writes[] = { CreateMockWrite(*req) }; |
4089 | 4098 |
4090 // 5 data frames in a single read. | 4099 // 5 data frames in a single read. |
4091 scoped_ptr<spdy::SpdyFrame> syn_reply( | 4100 scoped_ptr<spdy::SpdyFrame> syn_reply( |
4092 ConstructSpdyGetSynReply(NULL, 0, 1)); | 4101 ConstructSpdyGetSynReply(NULL, 0, 1)); |
4093 syn_reply->set_flags(spdy::CONTROL_FLAG_NONE); // turn off FIN bit | 4102 syn_reply->set_flags(spdy::CONTROL_FLAG_NONE); // turn off FIN bit |
4094 scoped_ptr<spdy::SpdyFrame> data_frame( | 4103 scoped_ptr<spdy::SpdyFrame> data_frame( |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4166 | 4175 |
4167 // Verify that we consumed all test data. | 4176 // Verify that we consumed all test data. |
4168 helper.VerifyDataConsumed(); | 4177 helper.VerifyDataConsumed(); |
4169 | 4178 |
4170 EXPECT_EQ(OK, out.rv); | 4179 EXPECT_EQ(OK, out.rv); |
4171 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 4180 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
4172 EXPECT_EQ("messagemessagemessagemessage", out.response_data); | 4181 EXPECT_EQ("messagemessagemessagemessage", out.response_data); |
4173 } | 4182 } |
4174 | 4183 |
4175 // Verify the case where we buffer data and close the connection. | 4184 // Verify the case where we buffer data and close the connection. |
4176 TEST_P(SpdyNetworkTransactionTest, BufferedClosed) { | 4185 TEST_P(SpdyNetworkTransactionSpdy2Test, BufferedClosed) { |
4177 spdy::SpdyFramer framer; | 4186 spdy::SpdyFramer framer; |
4178 | 4187 |
4179 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 4188 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
4180 MockWrite writes[] = { CreateMockWrite(*req) }; | 4189 MockWrite writes[] = { CreateMockWrite(*req) }; |
4181 | 4190 |
4182 // All data frames in a single read. | 4191 // All data frames in a single read. |
4183 // NOTE: We don't FIN the stream. | 4192 // NOTE: We don't FIN the stream. |
4184 scoped_ptr<spdy::SpdyFrame> data_frame( | 4193 scoped_ptr<spdy::SpdyFrame> data_frame( |
4185 framer.CreateDataFrame(1, "message", 7, spdy::DATA_FLAG_NONE)); | 4194 framer.CreateDataFrame(1, "message", 7, spdy::DATA_FLAG_NONE)); |
4186 const spdy::SpdyFrame* data_frames[4] = { | 4195 const spdy::SpdyFrame* data_frames[4] = { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4257 | 4266 |
4258 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the | 4267 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the |
4259 // MockClientSocketFactory) are still alive. | 4268 // MockClientSocketFactory) are still alive. |
4260 MessageLoop::current()->RunAllPending(); | 4269 MessageLoop::current()->RunAllPending(); |
4261 | 4270 |
4262 // Verify that we consumed all test data. | 4271 // Verify that we consumed all test data. |
4263 helper.VerifyDataConsumed(); | 4272 helper.VerifyDataConsumed(); |
4264 } | 4273 } |
4265 | 4274 |
4266 // Verify the case where we buffer data and cancel the transaction. | 4275 // Verify the case where we buffer data and cancel the transaction. |
4267 TEST_P(SpdyNetworkTransactionTest, BufferedCancelled) { | 4276 TEST_P(SpdyNetworkTransactionSpdy2Test, BufferedCancelled) { |
4268 spdy::SpdyFramer framer; | 4277 spdy::SpdyFramer framer; |
4269 | 4278 |
4270 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 4279 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
4271 MockWrite writes[] = { CreateMockWrite(*req) }; | 4280 MockWrite writes[] = { CreateMockWrite(*req) }; |
4272 | 4281 |
4273 // NOTE: We don't FIN the stream. | 4282 // NOTE: We don't FIN the stream. |
4274 scoped_ptr<spdy::SpdyFrame> data_frame( | 4283 scoped_ptr<spdy::SpdyFrame> data_frame( |
4275 framer.CreateDataFrame(1, "message", 7, spdy::DATA_FLAG_NONE)); | 4284 framer.CreateDataFrame(1, "message", 7, spdy::DATA_FLAG_NONE)); |
4276 | 4285 |
4277 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 4286 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4329 // Flush the MessageLoop; this will cause the buffered IO task | 4338 // Flush the MessageLoop; this will cause the buffered IO task |
4330 // to run for the final time. | 4339 // to run for the final time. |
4331 MessageLoop::current()->RunAllPending(); | 4340 MessageLoop::current()->RunAllPending(); |
4332 | 4341 |
4333 // Verify that we consumed all test data. | 4342 // Verify that we consumed all test data. |
4334 helper.VerifyDataConsumed(); | 4343 helper.VerifyDataConsumed(); |
4335 } | 4344 } |
4336 | 4345 |
4337 // Test that if the server requests persistence of settings, that we save | 4346 // Test that if the server requests persistence of settings, that we save |
4338 // the settings in the SpdySettingsStorage. | 4347 // the settings in the SpdySettingsStorage. |
4339 TEST_P(SpdyNetworkTransactionTest, SettingsSaved) { | 4348 TEST_P(SpdyNetworkTransactionSpdy2Test, SettingsSaved) { |
4340 static const SpdyHeaderInfo kSynReplyInfo = { | 4349 static const SpdyHeaderInfo kSynReplyInfo = { |
4341 spdy::SYN_REPLY, // Syn Reply | 4350 spdy::SYN_REPLY, // Syn Reply |
4342 1, // Stream ID | 4351 1, // Stream ID |
4343 0, // Associated Stream ID | 4352 0, // Associated Stream ID |
4344 net::ConvertRequestPriorityToSpdyPriority(LOWEST), | 4353 net::ConvertRequestPriorityToSpdyPriority(LOWEST), |
4345 // Priority | 4354 // Priority |
4346 spdy::CONTROL_FLAG_NONE, // Control Flags | 4355 spdy::CONTROL_FLAG_NONE, // Control Flags |
4347 false, // Compressed | 4356 false, // Compressed |
4348 spdy::INVALID, // Status | 4357 spdy::INVALID, // Status |
4349 NULL, // Data | 4358 NULL, // Data |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4440 setting = saved_settings.front(); | 4449 setting = saved_settings.front(); |
4441 saved_settings.pop_front(); | 4450 saved_settings.pop_front(); |
4442 EXPECT_EQ(spdy::SETTINGS_FLAG_PERSISTED, setting.first.flags()); | 4451 EXPECT_EQ(spdy::SETTINGS_FLAG_PERSISTED, setting.first.flags()); |
4443 EXPECT_EQ(kSampleId3, setting.first.id()); | 4452 EXPECT_EQ(kSampleId3, setting.first.id()); |
4444 EXPECT_EQ(kSampleValue3, setting.second); | 4453 EXPECT_EQ(kSampleValue3, setting.second); |
4445 } | 4454 } |
4446 } | 4455 } |
4447 | 4456 |
4448 // Test that when there are settings saved that they are sent back to the | 4457 // Test that when there are settings saved that they are sent back to the |
4449 // server upon session establishment. | 4458 // server upon session establishment. |
4450 TEST_P(SpdyNetworkTransactionTest, SettingsPlayback) { | 4459 TEST_P(SpdyNetworkTransactionSpdy2Test, SettingsPlayback) { |
4451 static const SpdyHeaderInfo kSynReplyInfo = { | 4460 static const SpdyHeaderInfo kSynReplyInfo = { |
4452 spdy::SYN_REPLY, // Syn Reply | 4461 spdy::SYN_REPLY, // Syn Reply |
4453 1, // Stream ID | 4462 1, // Stream ID |
4454 0, // Associated Stream ID | 4463 0, // Associated Stream ID |
4455 net::ConvertRequestPriorityToSpdyPriority(LOWEST), | 4464 net::ConvertRequestPriorityToSpdyPriority(LOWEST), |
4456 // Priority | 4465 // Priority |
4457 spdy::CONTROL_FLAG_NONE, // Control Flags | 4466 spdy::CONTROL_FLAG_NONE, // Control Flags |
4458 false, // Compressed | 4467 false, // Compressed |
4459 spdy::INVALID, // Status | 4468 spdy::INVALID, // Status |
4460 NULL, // Data | 4469 NULL, // Data |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4556 | 4565 |
4557 // Verify the second persisted setting. | 4566 // Verify the second persisted setting. |
4558 setting = saved_settings.front(); | 4567 setting = saved_settings.front(); |
4559 saved_settings.pop_front(); | 4568 saved_settings.pop_front(); |
4560 EXPECT_EQ(spdy::SETTINGS_FLAG_PERSISTED, setting.first.flags()); | 4569 EXPECT_EQ(spdy::SETTINGS_FLAG_PERSISTED, setting.first.flags()); |
4561 EXPECT_EQ(kSampleId2, setting.first.id()); | 4570 EXPECT_EQ(kSampleId2, setting.first.id()); |
4562 EXPECT_EQ(kSampleValue2, setting.second); | 4571 EXPECT_EQ(kSampleValue2, setting.second); |
4563 } | 4572 } |
4564 } | 4573 } |
4565 | 4574 |
4566 TEST_P(SpdyNetworkTransactionTest, GoAwayWithActiveStream) { | 4575 TEST_P(SpdyNetworkTransactionSpdy2Test, GoAwayWithActiveStream) { |
4567 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 4576 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
4568 MockWrite writes[] = { CreateMockWrite(*req) }; | 4577 MockWrite writes[] = { CreateMockWrite(*req) }; |
4569 | 4578 |
4570 scoped_ptr<spdy::SpdyFrame> go_away(ConstructSpdyGoAway()); | 4579 scoped_ptr<spdy::SpdyFrame> go_away(ConstructSpdyGoAway()); |
4571 MockRead reads[] = { | 4580 MockRead reads[] = { |
4572 CreateMockRead(*go_away), | 4581 CreateMockRead(*go_away), |
4573 MockRead(ASYNC, 0, 0), // EOF | 4582 MockRead(ASYNC, 0, 0), // EOF |
4574 }; | 4583 }; |
4575 | 4584 |
4576 scoped_ptr<DelayedSocketData> data( | 4585 scoped_ptr<DelayedSocketData> data( |
4577 new DelayedSocketData(1, reads, arraysize(reads), | 4586 new DelayedSocketData(1, reads, arraysize(reads), |
4578 writes, arraysize(writes))); | 4587 writes, arraysize(writes))); |
4579 NormalSpdyTransactionHelper helper(CreateGetRequest(), | 4588 NormalSpdyTransactionHelper helper(CreateGetRequest(), |
4580 BoundNetLog(), GetParam()); | 4589 BoundNetLog(), GetParam()); |
4581 helper.AddData(data.get()); | 4590 helper.AddData(data.get()); |
4582 helper.RunToCompletion(data.get()); | 4591 helper.RunToCompletion(data.get()); |
4583 TransactionHelperResult out = helper.output(); | 4592 TransactionHelperResult out = helper.output(); |
4584 EXPECT_EQ(ERR_ABORTED, out.rv); | 4593 EXPECT_EQ(ERR_ABORTED, out.rv); |
4585 } | 4594 } |
4586 | 4595 |
4587 TEST_P(SpdyNetworkTransactionTest, CloseWithActiveStream) { | 4596 TEST_P(SpdyNetworkTransactionSpdy2Test, CloseWithActiveStream) { |
4588 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 4597 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
4589 MockWrite writes[] = { CreateMockWrite(*req) }; | 4598 MockWrite writes[] = { CreateMockWrite(*req) }; |
4590 | 4599 |
4591 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 4600 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
4592 MockRead reads[] = { | 4601 MockRead reads[] = { |
4593 CreateMockRead(*resp), | 4602 CreateMockRead(*resp), |
4594 MockRead(SYNCHRONOUS, 0, 0) // EOF | 4603 MockRead(SYNCHRONOUS, 0, 0) // EOF |
4595 }; | 4604 }; |
4596 | 4605 |
4597 scoped_ptr<DelayedSocketData> data( | 4606 scoped_ptr<DelayedSocketData> data( |
(...skipping 18 matching lines...) Expand all Loading... |
4616 EXPECT_TRUE(response->headers != NULL); | 4625 EXPECT_TRUE(response->headers != NULL); |
4617 EXPECT_TRUE(response->was_fetched_via_spdy); | 4626 EXPECT_TRUE(response->was_fetched_via_spdy); |
4618 out.rv = ReadTransaction(trans, &out.response_data); | 4627 out.rv = ReadTransaction(trans, &out.response_data); |
4619 EXPECT_EQ(ERR_CONNECTION_CLOSED, out.rv); | 4628 EXPECT_EQ(ERR_CONNECTION_CLOSED, out.rv); |
4620 | 4629 |
4621 // Verify that we consumed all test data. | 4630 // Verify that we consumed all test data. |
4622 helper.VerifyDataConsumed(); | 4631 helper.VerifyDataConsumed(); |
4623 } | 4632 } |
4624 | 4633 |
4625 // Test to make sure we can correctly connect through a proxy. | 4634 // Test to make sure we can correctly connect through a proxy. |
4626 TEST_P(SpdyNetworkTransactionTest, ProxyConnect) { | 4635 TEST_P(SpdyNetworkTransactionSpdy2Test, ProxyConnect) { |
4627 NormalSpdyTransactionHelper helper(CreateGetRequest(), | 4636 NormalSpdyTransactionHelper helper(CreateGetRequest(), |
4628 BoundNetLog(), GetParam()); | 4637 BoundNetLog(), GetParam()); |
4629 helper.session_deps().reset(new SpdySessionDependencies( | 4638 helper.session_deps().reset(new SpdySessionDependencies( |
4630 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70"))); | 4639 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70"))); |
4631 helper.SetSession(make_scoped_refptr( | 4640 helper.SetSession(make_scoped_refptr( |
4632 SpdySessionDependencies::SpdyCreateSession(helper.session_deps().get()))); | 4641 SpdySessionDependencies::SpdyCreateSession(helper.session_deps().get()))); |
4633 helper.RunPreTestSetup(); | 4642 helper.RunPreTestSetup(); |
4634 HttpNetworkTransaction* trans = helper.trans(); | 4643 HttpNetworkTransaction* trans = helper.trans(); |
4635 | 4644 |
4636 const char kConnect443[] = {"CONNECT www.google.com:443 HTTP/1.1\r\n" | 4645 const char kConnect443[] = {"CONNECT www.google.com:443 HTTP/1.1\r\n" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4717 | 4726 |
4718 std::string response_data; | 4727 std::string response_data; |
4719 ASSERT_EQ(OK, ReadTransaction(trans, &response_data)); | 4728 ASSERT_EQ(OK, ReadTransaction(trans, &response_data)); |
4720 EXPECT_EQ("hello!", response_data); | 4729 EXPECT_EQ("hello!", response_data); |
4721 helper.VerifyDataConsumed(); | 4730 helper.VerifyDataConsumed(); |
4722 } | 4731 } |
4723 | 4732 |
4724 // Test to make sure we can correctly connect through a proxy to www.google.com, | 4733 // Test to make sure we can correctly connect through a proxy to www.google.com, |
4725 // if there already exists a direct spdy connection to www.google.com. See | 4734 // if there already exists a direct spdy connection to www.google.com. See |
4726 // http://crbug.com/49874 | 4735 // http://crbug.com/49874 |
4727 TEST_P(SpdyNetworkTransactionTest, DirectConnectProxyReconnect) { | 4736 TEST_P(SpdyNetworkTransactionSpdy2Test, DirectConnectProxyReconnect) { |
4728 // When setting up the first transaction, we store the SpdySessionPool so that | 4737 // When setting up the first transaction, we store the SpdySessionPool so that |
4729 // we can use the same pool in the second transaction. | 4738 // we can use the same pool in the second transaction. |
4730 NormalSpdyTransactionHelper helper(CreateGetRequest(), | 4739 NormalSpdyTransactionHelper helper(CreateGetRequest(), |
4731 BoundNetLog(), GetParam()); | 4740 BoundNetLog(), GetParam()); |
4732 | 4741 |
4733 // Use a proxy service which returns a proxy fallback list from DIRECT to | 4742 // Use a proxy service which returns a proxy fallback list from DIRECT to |
4734 // myproxy:70. For this test there will be no fallback, so it is equivalent | 4743 // myproxy:70. For this test there will be no fallback, so it is equivalent |
4735 // to simply DIRECT. The reason for appending the second proxy is to verify | 4744 // to simply DIRECT. The reason for appending the second proxy is to verify |
4736 // that the session pool key used does is just "DIRECT". | 4745 // that the session pool key used does is just "DIRECT". |
4737 helper.session_deps().reset(new SpdySessionDependencies( | 4746 helper.session_deps().reset(new SpdySessionDependencies( |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4895 EXPECT_EQ("hello!", response_data); | 4904 EXPECT_EQ("hello!", response_data); |
4896 | 4905 |
4897 data->CompleteRead(); | 4906 data->CompleteRead(); |
4898 helper_proxy.VerifyDataConsumed(); | 4907 helper_proxy.VerifyDataConsumed(); |
4899 } | 4908 } |
4900 | 4909 |
4901 // When we get a TCP-level RST, we need to retry a HttpNetworkTransaction | 4910 // When we get a TCP-level RST, we need to retry a HttpNetworkTransaction |
4902 // on a new connection, if the connection was previously known to be good. | 4911 // on a new connection, if the connection was previously known to be good. |
4903 // This can happen when a server reboots without saying goodbye, or when | 4912 // This can happen when a server reboots without saying goodbye, or when |
4904 // we're behind a NAT that masked the RST. | 4913 // we're behind a NAT that masked the RST. |
4905 TEST_P(SpdyNetworkTransactionTest, VerifyRetryOnConnectionReset) { | 4914 TEST_P(SpdyNetworkTransactionSpdy2Test, VerifyRetryOnConnectionReset) { |
4906 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 4915 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
4907 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); | 4916 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); |
4908 MockRead reads[] = { | 4917 MockRead reads[] = { |
4909 CreateMockRead(*resp), | 4918 CreateMockRead(*resp), |
4910 CreateMockRead(*body), | 4919 CreateMockRead(*body), |
4911 MockRead(ASYNC, ERR_IO_PENDING), | 4920 MockRead(ASYNC, ERR_IO_PENDING), |
4912 MockRead(ASYNC, ERR_CONNECTION_RESET), | 4921 MockRead(ASYNC, ERR_CONNECTION_RESET), |
4913 }; | 4922 }; |
4914 | 4923 |
4915 MockRead reads2[] = { | 4924 MockRead reads2[] = { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4977 EXPECT_EQ(OK, rv); | 4986 EXPECT_EQ(OK, rv); |
4978 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 4987 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
4979 EXPECT_EQ("hello!", response_data); | 4988 EXPECT_EQ("hello!", response_data); |
4980 } | 4989 } |
4981 | 4990 |
4982 helper.VerifyDataConsumed(); | 4991 helper.VerifyDataConsumed(); |
4983 } | 4992 } |
4984 } | 4993 } |
4985 | 4994 |
4986 // Test that turning SPDY on and off works properly. | 4995 // Test that turning SPDY on and off works properly. |
4987 TEST_P(SpdyNetworkTransactionTest, SpdyOnOffToggle) { | 4996 TEST_P(SpdyNetworkTransactionSpdy2Test, SpdyOnOffToggle) { |
4988 net::HttpStreamFactory::set_spdy_enabled(true); | 4997 net::HttpStreamFactory::set_spdy_enabled(true); |
4989 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 4998 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
4990 MockWrite spdy_writes[] = { CreateMockWrite(*req) }; | 4999 MockWrite spdy_writes[] = { CreateMockWrite(*req) }; |
4991 | 5000 |
4992 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 5001 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
4993 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); | 5002 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); |
4994 MockRead spdy_reads[] = { | 5003 MockRead spdy_reads[] = { |
4995 CreateMockRead(*resp), | 5004 CreateMockRead(*resp), |
4996 CreateMockRead(*body), | 5005 CreateMockRead(*body), |
4997 MockRead(ASYNC, 0, 0) // EOF | 5006 MockRead(ASYNC, 0, 0) // EOF |
(...skipping 26 matching lines...) Expand all Loading... |
5024 helper2.RunToCompletion(data2.get()); | 5033 helper2.RunToCompletion(data2.get()); |
5025 TransactionHelperResult out2 = helper2.output(); | 5034 TransactionHelperResult out2 = helper2.output(); |
5026 EXPECT_EQ(OK, out2.rv); | 5035 EXPECT_EQ(OK, out2.rv); |
5027 EXPECT_EQ("HTTP/1.1 200 OK", out2.status_line); | 5036 EXPECT_EQ("HTTP/1.1 200 OK", out2.status_line); |
5028 EXPECT_EQ("hello from http", out2.response_data); | 5037 EXPECT_EQ("hello from http", out2.response_data); |
5029 | 5038 |
5030 net::HttpStreamFactory::set_spdy_enabled(true); | 5039 net::HttpStreamFactory::set_spdy_enabled(true); |
5031 } | 5040 } |
5032 | 5041 |
5033 // Tests that Basic authentication works over SPDY | 5042 // Tests that Basic authentication works over SPDY |
5034 TEST_P(SpdyNetworkTransactionTest, SpdyBasicAuth) { | 5043 TEST_P(SpdyNetworkTransactionSpdy2Test, SpdyBasicAuth) { |
5035 net::HttpStreamFactory::set_spdy_enabled(true); | 5044 net::HttpStreamFactory::set_spdy_enabled(true); |
5036 | 5045 |
5037 // The first request will be a bare GET, the second request will be a | 5046 // The first request will be a bare GET, the second request will be a |
5038 // GET with an Authorization header. | 5047 // GET with an Authorization header. |
5039 scoped_ptr<spdy::SpdyFrame> req_get( | 5048 scoped_ptr<spdy::SpdyFrame> req_get( |
5040 ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 5049 ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
5041 const char* const kExtraAuthorizationHeaders[] = { | 5050 const char* const kExtraAuthorizationHeaders[] = { |
5042 "authorization", | 5051 "authorization", |
5043 "Basic Zm9vOmJhcg==", | 5052 "Basic Zm9vOmJhcg==", |
5044 }; | 5053 }; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5115 EXPECT_EQ(OK, rv_restart_complete); | 5124 EXPECT_EQ(OK, rv_restart_complete); |
5116 // TODO(cbentzel): This is actually the same response object as before, but | 5125 // TODO(cbentzel): This is actually the same response object as before, but |
5117 // data has changed. | 5126 // data has changed. |
5118 const HttpResponseInfo* const response_restart = trans->GetResponseInfo(); | 5127 const HttpResponseInfo* const response_restart = trans->GetResponseInfo(); |
5119 ASSERT_TRUE(response_restart != NULL); | 5128 ASSERT_TRUE(response_restart != NULL); |
5120 ASSERT_TRUE(response_restart->headers != NULL); | 5129 ASSERT_TRUE(response_restart->headers != NULL); |
5121 EXPECT_EQ(200, response_restart->headers->response_code()); | 5130 EXPECT_EQ(200, response_restart->headers->response_code()); |
5122 EXPECT_TRUE(response_restart->auth_challenge.get() == NULL); | 5131 EXPECT_TRUE(response_restart->auth_challenge.get() == NULL); |
5123 } | 5132 } |
5124 | 5133 |
5125 TEST_P(SpdyNetworkTransactionTest, ServerPushWithHeaders) { | 5134 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushWithHeaders) { |
5126 static const unsigned char kPushBodyFrame[] = { | 5135 static const unsigned char kPushBodyFrame[] = { |
5127 0x00, 0x00, 0x00, 0x02, // header, ID | 5136 0x00, 0x00, 0x00, 0x02, // header, ID |
5128 0x01, 0x00, 0x00, 0x06, // FIN, length | 5137 0x01, 0x00, 0x00, 0x06, // FIN, length |
5129 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | 5138 'p', 'u', 's', 'h', 'e', 'd' // "pushed" |
5130 }; | 5139 }; |
5131 scoped_ptr<spdy::SpdyFrame> | 5140 scoped_ptr<spdy::SpdyFrame> |
5132 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 5141 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
5133 scoped_ptr<spdy::SpdyFrame> | 5142 scoped_ptr<spdy::SpdyFrame> |
5134 stream1_body(ConstructSpdyBodyFrame(1, true)); | 5143 stream1_body(ConstructSpdyBodyFrame(1, true)); |
5135 MockWrite writes[] = { | 5144 MockWrite writes[] = { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5198 | 5207 |
5199 // Verify the SYN_REPLY. | 5208 // Verify the SYN_REPLY. |
5200 EXPECT_TRUE(response.headers != NULL); | 5209 EXPECT_TRUE(response.headers != NULL); |
5201 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5210 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
5202 | 5211 |
5203 // Verify the pushed stream. | 5212 // Verify the pushed stream. |
5204 EXPECT_TRUE(response2.headers != NULL); | 5213 EXPECT_TRUE(response2.headers != NULL); |
5205 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 5214 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
5206 } | 5215 } |
5207 | 5216 |
5208 TEST_P(SpdyNetworkTransactionTest, ServerPushClaimBeforeHeaders) { | 5217 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushClaimBeforeHeaders) { |
5209 // We push a stream and attempt to claim it before the headers come down. | 5218 // We push a stream and attempt to claim it before the headers come down. |
5210 static const unsigned char kPushBodyFrame[] = { | 5219 static const unsigned char kPushBodyFrame[] = { |
5211 0x00, 0x00, 0x00, 0x02, // header, ID | 5220 0x00, 0x00, 0x00, 0x02, // header, ID |
5212 0x01, 0x00, 0x00, 0x06, // FIN, length | 5221 0x01, 0x00, 0x00, 0x06, // FIN, length |
5213 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | 5222 'p', 'u', 's', 'h', 'e', 'd' // "pushed" |
5214 }; | 5223 }; |
5215 scoped_ptr<spdy::SpdyFrame> | 5224 scoped_ptr<spdy::SpdyFrame> |
5216 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 5225 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
5217 scoped_ptr<spdy::SpdyFrame> | 5226 scoped_ptr<spdy::SpdyFrame> |
5218 stream1_body(ConstructSpdyBodyFrame(1, true)); | 5227 stream1_body(ConstructSpdyBodyFrame(1, true)); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5335 | 5344 |
5336 // Verify the SYN_REPLY. | 5345 // Verify the SYN_REPLY. |
5337 EXPECT_TRUE(response.headers != NULL); | 5346 EXPECT_TRUE(response.headers != NULL); |
5338 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5347 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
5339 | 5348 |
5340 // Verify the pushed stream. | 5349 // Verify the pushed stream. |
5341 EXPECT_TRUE(response2.headers != NULL); | 5350 EXPECT_TRUE(response2.headers != NULL); |
5342 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); | 5351 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); |
5343 } | 5352 } |
5344 | 5353 |
5345 TEST_P(SpdyNetworkTransactionTest, ServerPushWithTwoHeaderFrames) { | 5354 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushWithTwoHeaderFrames) { |
5346 // We push a stream and attempt to claim it before the headers come down. | 5355 // We push a stream and attempt to claim it before the headers come down. |
5347 static const unsigned char kPushBodyFrame[] = { | 5356 static const unsigned char kPushBodyFrame[] = { |
5348 0x00, 0x00, 0x00, 0x02, // header, ID | 5357 0x00, 0x00, 0x00, 0x02, // header, ID |
5349 0x01, 0x00, 0x00, 0x06, // FIN, length | 5358 0x01, 0x00, 0x00, 0x06, // FIN, length |
5350 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | 5359 'p', 'u', 's', 'h', 'e', 'd' // "pushed" |
5351 }; | 5360 }; |
5352 scoped_ptr<spdy::SpdyFrame> | 5361 scoped_ptr<spdy::SpdyFrame> |
5353 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 5362 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
5354 scoped_ptr<spdy::SpdyFrame> | 5363 scoped_ptr<spdy::SpdyFrame> |
5355 stream1_body(ConstructSpdyBodyFrame(1, true)); | 5364 stream1_body(ConstructSpdyBodyFrame(1, true)); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5494 | 5503 |
5495 // Verify we got all the headers | 5504 // Verify we got all the headers |
5496 EXPECT_TRUE(response2.headers->HasHeaderValue( | 5505 EXPECT_TRUE(response2.headers->HasHeaderValue( |
5497 "url", | 5506 "url", |
5498 "http://www.google.com/foo.dat")); | 5507 "http://www.google.com/foo.dat")); |
5499 EXPECT_TRUE(response2.headers->HasHeaderValue("hello", "bye")); | 5508 EXPECT_TRUE(response2.headers->HasHeaderValue("hello", "bye")); |
5500 EXPECT_TRUE(response2.headers->HasHeaderValue("status", "200")); | 5509 EXPECT_TRUE(response2.headers->HasHeaderValue("status", "200")); |
5501 EXPECT_TRUE(response2.headers->HasHeaderValue("version", "HTTP/1.1")); | 5510 EXPECT_TRUE(response2.headers->HasHeaderValue("version", "HTTP/1.1")); |
5502 } | 5511 } |
5503 | 5512 |
5504 TEST_P(SpdyNetworkTransactionTest, SynReplyWithHeaders) { | 5513 TEST_P(SpdyNetworkTransactionSpdy2Test, SynReplyWithHeaders) { |
5505 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 5514 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
5506 MockWrite writes[] = { CreateMockWrite(*req) }; | 5515 MockWrite writes[] = { CreateMockWrite(*req) }; |
5507 | 5516 |
5508 static const char* const kInitialHeaders[] = { | 5517 static const char* const kInitialHeaders[] = { |
5509 "status", | 5518 "status", |
5510 "200 OK", | 5519 "200 OK", |
5511 "version", | 5520 "version", |
5512 "HTTP/1.1" | 5521 "HTTP/1.1" |
5513 }; | 5522 }; |
5514 static const char* const kLateHeaders[] = { | 5523 static const char* const kLateHeaders[] = { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5550 writes, arraysize(writes))); | 5559 writes, arraysize(writes))); |
5551 NormalSpdyTransactionHelper helper(CreateGetRequest(), | 5560 NormalSpdyTransactionHelper helper(CreateGetRequest(), |
5552 BoundNetLog(), GetParam()); | 5561 BoundNetLog(), GetParam()); |
5553 helper.RunToCompletion(data.get()); | 5562 helper.RunToCompletion(data.get()); |
5554 TransactionHelperResult out = helper.output(); | 5563 TransactionHelperResult out = helper.output(); |
5555 EXPECT_EQ(OK, out.rv); | 5564 EXPECT_EQ(OK, out.rv); |
5556 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 5565 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
5557 EXPECT_EQ("hello!", out.response_data); | 5566 EXPECT_EQ("hello!", out.response_data); |
5558 } | 5567 } |
5559 | 5568 |
5560 TEST_P(SpdyNetworkTransactionTest, SynReplyWithLateHeaders) { | 5569 TEST_P(SpdyNetworkTransactionSpdy2Test, SynReplyWithLateHeaders) { |
5561 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 5570 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
5562 MockWrite writes[] = { CreateMockWrite(*req) }; | 5571 MockWrite writes[] = { CreateMockWrite(*req) }; |
5563 | 5572 |
5564 static const char* const kInitialHeaders[] = { | 5573 static const char* const kInitialHeaders[] = { |
5565 "status", | 5574 "status", |
5566 "200 OK", | 5575 "200 OK", |
5567 "version", | 5576 "version", |
5568 "HTTP/1.1" | 5577 "HTTP/1.1" |
5569 }; | 5578 }; |
5570 static const char* const kLateHeaders[] = { | 5579 static const char* const kLateHeaders[] = { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5608 writes, arraysize(writes))); | 5617 writes, arraysize(writes))); |
5609 NormalSpdyTransactionHelper helper(CreateGetRequest(), | 5618 NormalSpdyTransactionHelper helper(CreateGetRequest(), |
5610 BoundNetLog(), GetParam()); | 5619 BoundNetLog(), GetParam()); |
5611 helper.RunToCompletion(data.get()); | 5620 helper.RunToCompletion(data.get()); |
5612 TransactionHelperResult out = helper.output(); | 5621 TransactionHelperResult out = helper.output(); |
5613 EXPECT_EQ(OK, out.rv); | 5622 EXPECT_EQ(OK, out.rv); |
5614 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 5623 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
5615 EXPECT_EQ("hello!hello!", out.response_data); | 5624 EXPECT_EQ("hello!hello!", out.response_data); |
5616 } | 5625 } |
5617 | 5626 |
5618 TEST_P(SpdyNetworkTransactionTest, SynReplyWithDuplicateLateHeaders) { | 5627 TEST_P(SpdyNetworkTransactionSpdy2Test, SynReplyWithDuplicateLateHeaders) { |
5619 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 5628 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
5620 MockWrite writes[] = { CreateMockWrite(*req) }; | 5629 MockWrite writes[] = { CreateMockWrite(*req) }; |
5621 | 5630 |
5622 static const char* const kInitialHeaders[] = { | 5631 static const char* const kInitialHeaders[] = { |
5623 "status", | 5632 "status", |
5624 "200 OK", | 5633 "200 OK", |
5625 "version", | 5634 "version", |
5626 "HTTP/1.1" | 5635 "HTTP/1.1" |
5627 }; | 5636 }; |
5628 static const char* const kLateHeaders[] = { | 5637 static const char* const kLateHeaders[] = { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5664 scoped_ptr<DelayedSocketData> data( | 5673 scoped_ptr<DelayedSocketData> data( |
5665 new DelayedSocketData(1, reads, arraysize(reads), | 5674 new DelayedSocketData(1, reads, arraysize(reads), |
5666 writes, arraysize(writes))); | 5675 writes, arraysize(writes))); |
5667 NormalSpdyTransactionHelper helper(CreateGetRequest(), | 5676 NormalSpdyTransactionHelper helper(CreateGetRequest(), |
5668 BoundNetLog(), GetParam()); | 5677 BoundNetLog(), GetParam()); |
5669 helper.RunToCompletion(data.get()); | 5678 helper.RunToCompletion(data.get()); |
5670 TransactionHelperResult out = helper.output(); | 5679 TransactionHelperResult out = helper.output(); |
5671 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); | 5680 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); |
5672 } | 5681 } |
5673 | 5682 |
5674 TEST_P(SpdyNetworkTransactionTest, ServerPushCrossOriginCorrectness) { | 5683 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushCrossOriginCorrectness) { |
5675 // In this test we want to verify that we can't accidentally push content | 5684 // In this test we want to verify that we can't accidentally push content |
5676 // which can't be pushed by this content server. | 5685 // which can't be pushed by this content server. |
5677 // This test assumes that: | 5686 // This test assumes that: |
5678 // - if we're requesting http://www.foo.com/barbaz | 5687 // - if we're requesting http://www.foo.com/barbaz |
5679 // - the browser has made a connection to "www.foo.com". | 5688 // - the browser has made a connection to "www.foo.com". |
5680 | 5689 |
5681 // A list of the URL to fetch, followed by the URL being pushed. | 5690 // A list of the URL to fetch, followed by the URL being pushed. |
5682 static const char* const kTestCases[] = { | 5691 static const char* const kTestCases[] = { |
5683 "http://www.google.com/foo.html", | 5692 "http://www.google.com/foo.html", |
5684 "http://www.google.com:81/foo.js", // Bad port | 5693 "http://www.google.com:81/foo.js", // Bad port |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5776 response = *trans->GetResponseInfo(); | 5785 response = *trans->GetResponseInfo(); |
5777 | 5786 |
5778 VerifyStreamsClosed(helper); | 5787 VerifyStreamsClosed(helper); |
5779 | 5788 |
5780 // Verify the SYN_REPLY. | 5789 // Verify the SYN_REPLY. |
5781 EXPECT_TRUE(response.headers != NULL); | 5790 EXPECT_TRUE(response.headers != NULL); |
5782 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5791 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
5783 } | 5792 } |
5784 } | 5793 } |
5785 | 5794 |
5786 TEST_P(SpdyNetworkTransactionTest, RetryAfterRefused) { | 5795 TEST_P(SpdyNetworkTransactionSpdy2Test, RetryAfterRefused) { |
5787 // Construct the request. | 5796 // Construct the request. |
5788 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 5797 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
5789 scoped_ptr<spdy::SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST)); | 5798 scoped_ptr<spdy::SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST)); |
5790 MockWrite writes[] = { | 5799 MockWrite writes[] = { |
5791 CreateMockWrite(*req, 1), | 5800 CreateMockWrite(*req, 1), |
5792 CreateMockWrite(*req2, 3), | 5801 CreateMockWrite(*req2, 3), |
5793 }; | 5802 }; |
5794 | 5803 |
5795 scoped_ptr<spdy::SpdyFrame> refused( | 5804 scoped_ptr<spdy::SpdyFrame> refused( |
5796 ConstructSpdyRstStream(1, spdy::REFUSED_STREAM)); | 5805 ConstructSpdyRstStream(1, spdy::REFUSED_STREAM)); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5832 << " Write index: " | 5841 << " Write index: " |
5833 << data->write_index(); | 5842 << data->write_index(); |
5834 | 5843 |
5835 // Verify the SYN_REPLY. | 5844 // Verify the SYN_REPLY. |
5836 HttpResponseInfo response = *trans->GetResponseInfo(); | 5845 HttpResponseInfo response = *trans->GetResponseInfo(); |
5837 EXPECT_TRUE(response.headers != NULL); | 5846 EXPECT_TRUE(response.headers != NULL); |
5838 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); | 5847 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); |
5839 } | 5848 } |
5840 | 5849 |
5841 } // namespace net | 5850 } // namespace net |
OLD | NEW |