Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(320)

Side by Side Diff: net/spdy/spdy_network_transaction_spdy21_unittest.cc

Issue 9582034: Fork SPDY/2 and SPDY/3 versions of our SPDY tests, in preparation for landing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fix merge bug Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 SpdyNetworkTransactionSpdy21TestTypes {
30 SPDYNPN, 32 SPDYNPN,
31 SPDYNOSSL, 33 SPDYNOSSL,
32 SPDYSSL, 34 SPDYSSL,
33 }; 35 };
34 class SpdyNetworkTransactionTest 36 class SpdyNetworkTransactionSpdy21Test
35 : public ::testing::TestWithParam<SpdyNetworkTransactionTestTypes> { 37 : public ::testing::TestWithParam<SpdyNetworkTransactionSpdy21TestTypes> {
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
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 SpdyNetworkTransactionSpdy21TestTypes 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_21);
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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 SpdyNetworkTransactionSpdy21TestTypes 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 SpdyNetworkTransactionSpdy21TestTypes 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
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 SpdyNetworkTransactionSpdy21Test,
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(SpdyNetworkTransactionSpdy21Test, 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(SpdyNetworkTransactionSpdy21Test, 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(SpdyNetworkTransactionSpdy21Test, 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
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(SpdyNetworkTransactionSpdy21Test, 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
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(SpdyNetworkTransactionSpdy21Test, 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
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(SpdyNetworkTransactionSpdy21Test, 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
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(SpdyNetworkTransactionSpdy21Test, 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
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(SpdyNetworkTransactionSpdy21Test, 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
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(SpdyNetworkTransactionSpdy21Test, 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
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(SpdyNetworkTransactionSpdy21Test,
1351 ThreeGetsWithMaxConcurrentSocketClose) {
1343 // Construct the request. 1352 // Construct the request.
1344 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 1353 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
1345 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); 1354 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1));
1346 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, false)); 1355 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, false));
1347 scoped_ptr<spdy::SpdyFrame> fin_body(ConstructSpdyBodyFrame(1, true)); 1356 scoped_ptr<spdy::SpdyFrame> fin_body(ConstructSpdyBodyFrame(1, true));
1348 1357
1349 scoped_ptr<spdy::SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST)); 1358 scoped_ptr<spdy::SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST));
1350 scoped_ptr<spdy::SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3)); 1359 scoped_ptr<spdy::SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3));
1351 1360
1352 spdy::SpdySettings settings; 1361 spdy::SpdySettings settings;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 ASSERT_TRUE(response2 != NULL); 1435 ASSERT_TRUE(response2 != NULL);
1427 out.status_line = response2->headers->GetStatusLine(); 1436 out.status_line = response2->headers->GetStatusLine();
1428 out.response_info = *response2; 1437 out.response_info = *response2;
1429 out.rv = ReadTransaction(&trans2, &out.response_data); 1438 out.rv = ReadTransaction(&trans2, &out.response_data);
1430 EXPECT_EQ(ERR_CONNECTION_RESET, out.rv); 1439 EXPECT_EQ(ERR_CONNECTION_RESET, out.rv);
1431 1440
1432 helper.VerifyDataConsumed(); 1441 helper.VerifyDataConsumed();
1433 } 1442 }
1434 1443
1435 // Test that a simple PUT request works. 1444 // Test that a simple PUT request works.
1436 TEST_P(SpdyNetworkTransactionTest, Put) { 1445 TEST_P(SpdyNetworkTransactionSpdy21Test, Put) {
1437 // Setup the request 1446 // Setup the request
1438 HttpRequestInfo request; 1447 HttpRequestInfo request;
1439 request.method = "PUT"; 1448 request.method = "PUT";
1440 request.url = GURL("http://www.google.com/"); 1449 request.url = GURL("http://www.google.com/");
1441 1450
1442 const SpdyHeaderInfo kSynStartHeader = { 1451 const SpdyHeaderInfo kSynStartHeader = {
1443 spdy::SYN_STREAM, // Kind = Syn 1452 spdy::SYN_STREAM, // Kind = Syn
1444 1, // Stream ID 1453 1, // Stream ID
1445 0, // Associated stream ID 1454 0, // Associated stream ID
1446 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority 1455 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1497 NormalSpdyTransactionHelper helper(request, 1506 NormalSpdyTransactionHelper helper(request,
1498 BoundNetLog(), GetParam()); 1507 BoundNetLog(), GetParam());
1499 helper.RunToCompletion(data.get()); 1508 helper.RunToCompletion(data.get());
1500 TransactionHelperResult out = helper.output(); 1509 TransactionHelperResult out = helper.output();
1501 1510
1502 EXPECT_EQ(OK, out.rv); 1511 EXPECT_EQ(OK, out.rv);
1503 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); 1512 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line);
1504 } 1513 }
1505 1514
1506 // Test that a simple HEAD request works. 1515 // Test that a simple HEAD request works.
1507 TEST_P(SpdyNetworkTransactionTest, Head) { 1516 TEST_P(SpdyNetworkTransactionSpdy21Test, Head) {
1508 // Setup the request 1517 // Setup the request
1509 HttpRequestInfo request; 1518 HttpRequestInfo request;
1510 request.method = "HEAD"; 1519 request.method = "HEAD";
1511 request.url = GURL("http://www.google.com/"); 1520 request.url = GURL("http://www.google.com/");
1512 1521
1513 const SpdyHeaderInfo kSynStartHeader = { 1522 const SpdyHeaderInfo kSynStartHeader = {
1514 spdy::SYN_STREAM, // Kind = Syn 1523 spdy::SYN_STREAM, // Kind = Syn
1515 1, // Stream ID 1524 1, // Stream ID
1516 0, // Associated stream ID 1525 0, // Associated stream ID
1517 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority 1526 net::ConvertRequestPriorityToSpdyPriority(LOWEST), // Priority
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 NormalSpdyTransactionHelper helper(request, 1577 NormalSpdyTransactionHelper helper(request,
1569 BoundNetLog(), GetParam()); 1578 BoundNetLog(), GetParam());
1570 helper.RunToCompletion(data.get()); 1579 helper.RunToCompletion(data.get());
1571 TransactionHelperResult out = helper.output(); 1580 TransactionHelperResult out = helper.output();
1572 1581
1573 EXPECT_EQ(OK, out.rv); 1582 EXPECT_EQ(OK, out.rv);
1574 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); 1583 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line);
1575 } 1584 }
1576 1585
1577 // Test that a simple POST works. 1586 // Test that a simple POST works.
1578 TEST_P(SpdyNetworkTransactionTest, Post) { 1587 TEST_P(SpdyNetworkTransactionSpdy21Test, Post) {
1579 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyPost(kUploadDataSize, NULL, 0)); 1588 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyPost(kUploadDataSize, NULL, 0));
1580 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); 1589 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true));
1581 MockWrite writes[] = { 1590 MockWrite writes[] = {
1582 CreateMockWrite(*req), 1591 CreateMockWrite(*req),
1583 CreateMockWrite(*body), // POST upload frame 1592 CreateMockWrite(*body), // POST upload frame
1584 }; 1593 };
1585 1594
1586 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0)); 1595 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0));
1587 MockRead reads[] = { 1596 MockRead reads[] = {
1588 CreateMockRead(*resp), 1597 CreateMockRead(*resp),
1589 CreateMockRead(*body), 1598 CreateMockRead(*body),
1590 MockRead(ASYNC, 0, 0) // EOF 1599 MockRead(ASYNC, 0, 0) // EOF
1591 }; 1600 };
1592 1601
1593 scoped_ptr<DelayedSocketData> data( 1602 scoped_ptr<DelayedSocketData> data(
1594 new DelayedSocketData(2, reads, arraysize(reads), 1603 new DelayedSocketData(2, reads, arraysize(reads),
1595 writes, arraysize(writes))); 1604 writes, arraysize(writes)));
1596 NormalSpdyTransactionHelper helper(CreatePostRequest(), 1605 NormalSpdyTransactionHelper helper(CreatePostRequest(),
1597 BoundNetLog(), GetParam()); 1606 BoundNetLog(), GetParam());
1598 helper.RunToCompletion(data.get()); 1607 helper.RunToCompletion(data.get());
1599 TransactionHelperResult out = helper.output(); 1608 TransactionHelperResult out = helper.output();
1600 EXPECT_EQ(OK, out.rv); 1609 EXPECT_EQ(OK, out.rv);
1601 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); 1610 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line);
1602 EXPECT_EQ("hello!", out.response_data); 1611 EXPECT_EQ("hello!", out.response_data);
1603 } 1612 }
1604 1613
1605 // Test that a chunked POST works. 1614 // Test that a chunked POST works.
1606 TEST_P(SpdyNetworkTransactionTest, ChunkedPost) { 1615 TEST_P(SpdyNetworkTransactionSpdy21Test, ChunkedPost) {
1607 UploadDataStream::set_merge_chunks(false); 1616 UploadDataStream::set_merge_chunks(false);
1608 scoped_ptr<spdy::SpdyFrame> req(ConstructChunkedSpdyPost(NULL, 0)); 1617 scoped_ptr<spdy::SpdyFrame> req(ConstructChunkedSpdyPost(NULL, 0));
1609 scoped_ptr<spdy::SpdyFrame> chunk1(ConstructSpdyBodyFrame(1, false)); 1618 scoped_ptr<spdy::SpdyFrame> chunk1(ConstructSpdyBodyFrame(1, false));
1610 scoped_ptr<spdy::SpdyFrame> chunk2(ConstructSpdyBodyFrame(1, true)); 1619 scoped_ptr<spdy::SpdyFrame> chunk2(ConstructSpdyBodyFrame(1, true));
1611 MockWrite writes[] = { 1620 MockWrite writes[] = {
1612 CreateMockWrite(*req), 1621 CreateMockWrite(*req),
1613 CreateMockWrite(*chunk1), 1622 CreateMockWrite(*chunk1),
1614 CreateMockWrite(*chunk2), 1623 CreateMockWrite(*chunk2),
1615 }; 1624 };
1616 1625
(...skipping 11 matching lines...) Expand all
1628 NormalSpdyTransactionHelper helper(CreateChunkedPostRequest(), 1637 NormalSpdyTransactionHelper helper(CreateChunkedPostRequest(),
1629 BoundNetLog(), GetParam()); 1638 BoundNetLog(), GetParam());
1630 helper.RunToCompletion(data.get()); 1639 helper.RunToCompletion(data.get());
1631 TransactionHelperResult out = helper.output(); 1640 TransactionHelperResult out = helper.output();
1632 EXPECT_EQ(OK, out.rv); 1641 EXPECT_EQ(OK, out.rv);
1633 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); 1642 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line);
1634 EXPECT_EQ("hello!hello!", out.response_data); 1643 EXPECT_EQ("hello!hello!", out.response_data);
1635 } 1644 }
1636 1645
1637 // Test that a POST without any post data works. 1646 // Test that a POST without any post data works.
1638 TEST_P(SpdyNetworkTransactionTest, NullPost) { 1647 TEST_P(SpdyNetworkTransactionSpdy21Test, NullPost) {
1639 // Setup the request 1648 // Setup the request
1640 HttpRequestInfo request; 1649 HttpRequestInfo request;
1641 request.method = "POST"; 1650 request.method = "POST";
1642 request.url = GURL("http://www.google.com/"); 1651 request.url = GURL("http://www.google.com/");
1643 // Create an empty UploadData. 1652 // Create an empty UploadData.
1644 request.upload_data = NULL; 1653 request.upload_data = NULL;
1645 1654
1646 // When request.upload_data is NULL for post, content-length is 1655 // When request.upload_data is NULL for post, content-length is
1647 // expected to be 0. 1656 // expected to be 0.
1648 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyPost(0, NULL, 0)); 1657 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyPost(0, NULL, 0));
(...skipping 18 matching lines...) Expand all
1667 NormalSpdyTransactionHelper helper(request, 1676 NormalSpdyTransactionHelper helper(request,
1668 BoundNetLog(), GetParam()); 1677 BoundNetLog(), GetParam());
1669 helper.RunToCompletion(data.get()); 1678 helper.RunToCompletion(data.get());
1670 TransactionHelperResult out = helper.output(); 1679 TransactionHelperResult out = helper.output();
1671 EXPECT_EQ(OK, out.rv); 1680 EXPECT_EQ(OK, out.rv);
1672 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); 1681 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line);
1673 EXPECT_EQ("hello!", out.response_data); 1682 EXPECT_EQ("hello!", out.response_data);
1674 } 1683 }
1675 1684
1676 // Test that a simple POST works. 1685 // Test that a simple POST works.
1677 TEST_P(SpdyNetworkTransactionTest, EmptyPost) { 1686 TEST_P(SpdyNetworkTransactionSpdy21Test, EmptyPost) {
1678 // Setup the request 1687 // Setup the request
1679 HttpRequestInfo request; 1688 HttpRequestInfo request;
1680 request.method = "POST"; 1689 request.method = "POST";
1681 request.url = GURL("http://www.google.com/"); 1690 request.url = GURL("http://www.google.com/");
1682 // Create an empty UploadData. 1691 // Create an empty UploadData.
1683 request.upload_data = new UploadData(); 1692 request.upload_data = new UploadData();
1684 1693
1685 // Http POST Content-Length is using UploadDataStream::size(). 1694 // Http POST Content-Length is using UploadDataStream::size().
1686 // It is the same as request.upload_data->GetContentLengthSync(). 1695 // It is the same as request.upload_data->GetContentLengthSync().
1687 scoped_ptr<UploadDataStream> stream( 1696 scoped_ptr<UploadDataStream> stream(
(...skipping 26 matching lines...) Expand all
1714 NormalSpdyTransactionHelper helper(request, 1723 NormalSpdyTransactionHelper helper(request,
1715 BoundNetLog(), GetParam()); 1724 BoundNetLog(), GetParam());
1716 helper.RunToCompletion(data.get()); 1725 helper.RunToCompletion(data.get());
1717 TransactionHelperResult out = helper.output(); 1726 TransactionHelperResult out = helper.output();
1718 EXPECT_EQ(OK, out.rv); 1727 EXPECT_EQ(OK, out.rv);
1719 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); 1728 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line);
1720 EXPECT_EQ("hello!", out.response_data); 1729 EXPECT_EQ("hello!", out.response_data);
1721 } 1730 }
1722 1731
1723 // While we're doing a post, the server sends back a SYN_REPLY. 1732 // While we're doing a post, the server sends back a SYN_REPLY.
1724 TEST_P(SpdyNetworkTransactionTest, PostWithEarlySynReply) { 1733 TEST_P(SpdyNetworkTransactionSpdy21Test, PostWithEarlySynReply) {
1725 static const char upload[] = { "hello!" }; 1734 static const char upload[] = { "hello!" };
1726 1735
1727 // Setup the request 1736 // Setup the request
1728 HttpRequestInfo request; 1737 HttpRequestInfo request;
1729 request.method = "POST"; 1738 request.method = "POST";
1730 request.url = GURL("http://www.google.com/"); 1739 request.url = GURL("http://www.google.com/");
1731 request.upload_data = new UploadData(); 1740 request.upload_data = new UploadData();
1732 request.upload_data->AppendBytes(upload, sizeof(upload)); 1741 request.upload_data->AppendBytes(upload, sizeof(upload));
1733 1742
1734 // Http POST Content-Length is using UploadDataStream::size(). 1743 // Http POST Content-Length is using UploadDataStream::size().
(...skipping 20 matching lines...) Expand all
1755 helper.RunDefaultTest(); 1764 helper.RunDefaultTest();
1756 helper.VerifyDataConsumed(); 1765 helper.VerifyDataConsumed();
1757 1766
1758 TransactionHelperResult out = helper.output(); 1767 TransactionHelperResult out = helper.output();
1759 EXPECT_EQ(ERR_SYN_REPLY_NOT_RECEIVED, out.rv); 1768 EXPECT_EQ(ERR_SYN_REPLY_NOT_RECEIVED, out.rv);
1760 } 1769 }
1761 1770
1762 // The client upon cancellation tries to send a RST_STREAM frame. The mock 1771 // 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 1772 // socket causes the TCP write to return zero. This test checks that the client
1764 // tries to queue up the RST_STREAM frame again. 1773 // tries to queue up the RST_STREAM frame again.
1765 TEST_P(SpdyNetworkTransactionTest, SocketWriteReturnsZero) { 1774 TEST_P(SpdyNetworkTransactionSpdy21Test, SocketWriteReturnsZero) {
1766 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 1775 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
1767 scoped_ptr<spdy::SpdyFrame> rst( 1776 scoped_ptr<spdy::SpdyFrame> rst(
1768 ConstructSpdyRstStream(1, spdy::CANCEL)); 1777 ConstructSpdyRstStream(1, spdy::CANCEL));
1769 MockWrite writes[] = { 1778 MockWrite writes[] = {
1770 CreateMockWrite(*req.get(), 0, SYNCHRONOUS), 1779 CreateMockWrite(*req.get(), 0, SYNCHRONOUS),
1771 MockWrite(SYNCHRONOUS, 0, 0, 2), 1780 MockWrite(SYNCHRONOUS, 0, 0, 2),
1772 CreateMockWrite(*rst.get(), 3, SYNCHRONOUS), 1781 CreateMockWrite(*rst.get(), 3, SYNCHRONOUS),
1773 }; 1782 };
1774 1783
1775 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); 1784 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1));
(...skipping 20 matching lines...) Expand all
1796 data->SetStop(2); 1805 data->SetStop(2);
1797 data->Run(); 1806 data->Run();
1798 helper.ResetTrans(); 1807 helper.ResetTrans();
1799 data->SetStop(20); 1808 data->SetStop(20);
1800 data->Run(); 1809 data->Run();
1801 1810
1802 helper.VerifyDataConsumed(); 1811 helper.VerifyDataConsumed();
1803 } 1812 }
1804 1813
1805 // Test that the transaction doesn't crash when we don't have a reply. 1814 // Test that the transaction doesn't crash when we don't have a reply.
1806 TEST_P(SpdyNetworkTransactionTest, ResponseWithoutSynReply) { 1815 TEST_P(SpdyNetworkTransactionSpdy21Test, ResponseWithoutSynReply) {
1807 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); 1816 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true));
1808 MockRead reads[] = { 1817 MockRead reads[] = {
1809 CreateMockRead(*body), 1818 CreateMockRead(*body),
1810 MockRead(ASYNC, 0, 0) // EOF 1819 MockRead(ASYNC, 0, 0) // EOF
1811 }; 1820 };
1812 1821
1813 scoped_ptr<DelayedSocketData> data( 1822 scoped_ptr<DelayedSocketData> data(
1814 new DelayedSocketData(1, reads, arraysize(reads), NULL, 0)); 1823 new DelayedSocketData(1, reads, arraysize(reads), NULL, 0));
1815 NormalSpdyTransactionHelper helper(CreateGetRequest(), 1824 NormalSpdyTransactionHelper helper(CreateGetRequest(),
1816 BoundNetLog(), GetParam()); 1825 BoundNetLog(), GetParam());
1817 helper.RunToCompletion(data.get()); 1826 helper.RunToCompletion(data.get());
1818 TransactionHelperResult out = helper.output(); 1827 TransactionHelperResult out = helper.output();
1819 EXPECT_EQ(ERR_SYN_REPLY_NOT_RECEIVED, out.rv); 1828 EXPECT_EQ(ERR_SYN_REPLY_NOT_RECEIVED, out.rv);
1820 } 1829 }
1821 1830
1822 // Test that the transaction doesn't crash when we get two replies on the same 1831 // Test that the transaction doesn't crash when we get two replies on the same
1823 // stream ID. See http://crbug.com/45639. 1832 // stream ID. See http://crbug.com/45639.
1824 TEST_P(SpdyNetworkTransactionTest, ResponseWithTwoSynReplies) { 1833 TEST_P(SpdyNetworkTransactionSpdy21Test, ResponseWithTwoSynReplies) {
1825 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 1834 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
1826 MockWrite writes[] = { CreateMockWrite(*req) }; 1835 MockWrite writes[] = { CreateMockWrite(*req) };
1827 1836
1828 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); 1837 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1));
1829 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); 1838 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true));
1830 MockRead reads[] = { 1839 MockRead reads[] = {
1831 CreateMockRead(*resp), 1840 CreateMockRead(*resp),
1832 CreateMockRead(*resp), 1841 CreateMockRead(*resp),
1833 CreateMockRead(*body), 1842 CreateMockRead(*body),
1834 MockRead(ASYNC, 0, 0) // EOF 1843 MockRead(ASYNC, 0, 0) // EOF
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1876 // since request has not been completely written, therefore we feed 1885 // since request has not been completely written, therefore we feed
1877 // enough number of WINDOW_UPDATEs to finish the first read and cause a 1886 // 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 1887 // write, leading to a complete write of request body; after that we send
1879 // a reply with a body, to cause a graceful shutdown. 1888 // a reply with a body, to cause a graceful shutdown.
1880 1889
1881 // TODO(agayev): develop a socket data provider where both, reads and 1890 // 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 1891 // 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 1892 // all these tests using it. Right now we are working around the
1884 // limitations as described above and it's not deterministic, tests may 1893 // limitations as described above and it's not deterministic, tests may
1885 // fail under specific circumstances. 1894 // fail under specific circumstances.
1886 TEST_P(SpdyNetworkTransactionTest, WindowUpdateReceived) { 1895 TEST_P(SpdyNetworkTransactionSpdy21Test, WindowUpdateReceived) {
1887 SpdySession::set_use_flow_control(SpdySession::kEnableFlowControl); 1896 SpdySession::set_use_flow_control(SpdySession::kEnableFlowControl);
1888 1897
1889 static int kFrameCount = 2; 1898 static int kFrameCount = 2;
1890 scoped_ptr<std::string> content( 1899 scoped_ptr<std::string> content(
1891 new std::string(kMaxSpdyFrameChunkSize, 'a')); 1900 new std::string(kMaxSpdyFrameChunkSize, 'a'));
1892 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyPost( 1901 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyPost(
1893 kMaxSpdyFrameChunkSize * kFrameCount, NULL, 0)); 1902 kMaxSpdyFrameChunkSize * kFrameCount, NULL, 0));
1894 scoped_ptr<spdy::SpdyFrame> body( 1903 scoped_ptr<spdy::SpdyFrame> body(
1895 ConstructSpdyBodyFrame(1, content->c_str(), content->size(), false)); 1904 ConstructSpdyBodyFrame(1, content->c_str(), content->size(), false));
1896 scoped_ptr<spdy::SpdyFrame> body_end( 1905 scoped_ptr<spdy::SpdyFrame> body_end(
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1954 kDeltaWindowSize * kDeltaCount - 1963 kDeltaWindowSize * kDeltaCount -
1955 kMaxSpdyFrameChunkSize * kFrameCount, 1964 kMaxSpdyFrameChunkSize * kFrameCount,
1956 stream->stream()->send_window_size()); 1965 stream->stream()->send_window_size());
1957 helper.VerifyDataConsumed(); 1966 helper.VerifyDataConsumed();
1958 1967
1959 SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); 1968 SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN);
1960 } 1969 }
1961 1970
1962 // Test that received data frames and sent WINDOW_UPDATE frames change 1971 // Test that received data frames and sent WINDOW_UPDATE frames change
1963 // the recv_window_size_ correctly. 1972 // the recv_window_size_ correctly.
1964 TEST_P(SpdyNetworkTransactionTest, WindowUpdateSent) { 1973 TEST_P(SpdyNetworkTransactionSpdy21Test, WindowUpdateSent) {
1965 SpdySession::set_use_flow_control(SpdySession::kEnableFlowControl); 1974 SpdySession::set_use_flow_control(SpdySession::kEnableFlowControl);
1966 1975
1967 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 1976 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
1968 scoped_ptr<spdy::SpdyFrame> window_update( 1977 scoped_ptr<spdy::SpdyFrame> window_update(
1969 ConstructSpdyWindowUpdate(1, kUploadDataSize)); 1978 ConstructSpdyWindowUpdate(1, kUploadDataSize));
1970 1979
1971 MockWrite writes[] = { 1980 MockWrite writes[] = {
1972 CreateMockWrite(*req), 1981 CreateMockWrite(*req),
1973 CreateMockWrite(*window_update), 1982 CreateMockWrite(*window_update),
1974 }; 1983 };
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
2042 // Read EOF. 2051 // Read EOF.
2043 data->CompleteRead(); 2052 data->CompleteRead();
2044 2053
2045 helper.VerifyDataConsumed(); 2054 helper.VerifyDataConsumed();
2046 2055
2047 SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); 2056 SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN);
2048 } 2057 }
2049 2058
2050 // Test that WINDOW_UPDATE frame causing overflow is handled correctly. We 2059 // 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. 2060 // use the same trick as in the above test to enforce our scenario.
2052 TEST_P(SpdyNetworkTransactionTest, WindowUpdateOverflow) { 2061 TEST_P(SpdyNetworkTransactionSpdy21Test, WindowUpdateOverflow) {
2053 SpdySession::set_use_flow_control(SpdySession::kEnableFlowControl); 2062 SpdySession::set_use_flow_control(SpdySession::kEnableFlowControl);
2054 2063
2055 // number of full frames we hope to write (but will not, used to 2064 // number of full frames we hope to write (but will not, used to
2056 // set content-length header correctly) 2065 // set content-length header correctly)
2057 static int kFrameCount = 3; 2066 static int kFrameCount = 3;
2058 2067
2059 scoped_ptr<std::string> content( 2068 scoped_ptr<std::string> content(
2060 new std::string(kMaxSpdyFrameChunkSize, 'a')); 2069 new std::string(kMaxSpdyFrameChunkSize, 'a'));
2061 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyPost( 2070 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyPost(
2062 kMaxSpdyFrameChunkSize * kFrameCount, NULL, 0)); 2071 kMaxSpdyFrameChunkSize * kFrameCount, NULL, 0));
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
2134 // data frame containing default content (which is "hello!") and this frame 2143 // data frame containing default content (which is "hello!") and this frame
2135 // also contains a FIN flag. DelayedSocketData is used to enforce all 2144 // also contains a FIN flag. DelayedSocketData is used to enforce all
2136 // writes go through before a read could happen. However, the last frame 2145 // 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 2146 // ("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 2147 // arrives, window size is 0. At this point MessageLoop::Run() called via
2139 // callback would block. Therefore we call MessageLoop::RunAllPending() 2148 // callback would block. Therefore we call MessageLoop::RunAllPending()
2140 // which returns after performing all possible writes. We use DCHECKS to 2149 // which returns after performing all possible writes. We use DCHECKS to
2141 // ensure that last data frame is still there and stream has stalled. 2150 // ensure that last data frame is still there and stream has stalled.
2142 // After that, next read is artifically enforced, which causes a 2151 // After that, next read is artifically enforced, which causes a
2143 // WINDOW_UPDATE to be read and I/O process resumes. 2152 // WINDOW_UPDATE to be read and I/O process resumes.
2144 TEST_P(SpdyNetworkTransactionTest, FlowControlStallResume) { 2153 TEST_P(SpdyNetworkTransactionSpdy21Test, FlowControlStallResume) {
2145 SpdySession::set_use_flow_control(SpdySession::kEnableFlowControl); 2154 SpdySession::set_use_flow_control(SpdySession::kEnableFlowControl);
2146 2155
2147 // Number of frames we need to send to zero out the window size: data 2156 // 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 2157 // 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, 2158 // data frame that we will send once the WINDOW_UPDATE is received,
2150 // therefore +3. 2159 // therefore +3.
2151 size_t nwrites = 2160 size_t nwrites =
2152 spdy::kSpdyStreamInitialWindowSize / kMaxSpdyFrameChunkSize + 3; 2161 spdy::kSpdyStreamInitialWindowSize / kMaxSpdyFrameChunkSize + 3;
2153 2162
2154 // Calculate last frame's size; 0 size data frame is legal. 2163 // Calculate last frame's size; 0 size data frame is legal.
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
2234 // But the body is not yet fully sent ("hello!" is not yet sent). 2243 // But the body is not yet fully sent ("hello!" is not yet sent).
2235 EXPECT_FALSE(stream->stream()->body_sent()); 2244 EXPECT_FALSE(stream->stream()->body_sent());
2236 2245
2237 data->ForceNextRead(); // Read in WINDOW_UPDATE frame. 2246 data->ForceNextRead(); // Read in WINDOW_UPDATE frame.
2238 rv = callback.WaitForResult(); 2247 rv = callback.WaitForResult();
2239 helper.VerifyDataConsumed(); 2248 helper.VerifyDataConsumed();
2240 2249
2241 SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); 2250 SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN);
2242 } 2251 }
2243 2252
2244 TEST_P(SpdyNetworkTransactionTest, CancelledTransaction) { 2253 TEST_P(SpdyNetworkTransactionSpdy21Test, CancelledTransaction) {
2245 // Construct the request. 2254 // Construct the request.
2246 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 2255 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
2247 MockWrite writes[] = { 2256 MockWrite writes[] = {
2248 CreateMockWrite(*req), 2257 CreateMockWrite(*req),
2249 }; 2258 };
2250 2259
2251 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); 2260 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1));
2252 MockRead reads[] = { 2261 MockRead reads[] = {
2253 CreateMockRead(*resp), 2262 CreateMockRead(*resp),
2254 // This following read isn't used by the test, except during the 2263 // This following read isn't used by the test, except during the
(...skipping 18 matching lines...) Expand all
2273 EXPECT_EQ(ERR_IO_PENDING, rv); 2282 EXPECT_EQ(ERR_IO_PENDING, rv);
2274 helper.ResetTrans(); // Cancel the transaction. 2283 helper.ResetTrans(); // Cancel the transaction.
2275 2284
2276 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the 2285 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the
2277 // MockClientSocketFactory) are still alive. 2286 // MockClientSocketFactory) are still alive.
2278 MessageLoop::current()->RunAllPending(); 2287 MessageLoop::current()->RunAllPending();
2279 helper.VerifyDataNotConsumed(); 2288 helper.VerifyDataNotConsumed();
2280 } 2289 }
2281 2290
2282 // Verify that the client sends a Rst Frame upon cancelling the stream. 2291 // Verify that the client sends a Rst Frame upon cancelling the stream.
2283 TEST_P(SpdyNetworkTransactionTest, CancelledTransactionSendRst) { 2292 TEST_P(SpdyNetworkTransactionSpdy21Test, CancelledTransactionSendRst) {
2284 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 2293 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
2285 scoped_ptr<spdy::SpdyFrame> rst( 2294 scoped_ptr<spdy::SpdyFrame> rst(
2286 ConstructSpdyRstStream(1, spdy::CANCEL)); 2295 ConstructSpdyRstStream(1, spdy::CANCEL));
2287 MockWrite writes[] = { 2296 MockWrite writes[] = {
2288 CreateMockWrite(*req, 0, SYNCHRONOUS), 2297 CreateMockWrite(*req, 0, SYNCHRONOUS),
2289 CreateMockWrite(*rst, 2, SYNCHRONOUS), 2298 CreateMockWrite(*rst, 2, SYNCHRONOUS),
2290 }; 2299 };
2291 2300
2292 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); 2301 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1));
2293 MockRead reads[] = { 2302 MockRead reads[] = {
(...skipping 24 matching lines...) Expand all
2318 helper.ResetTrans(); 2327 helper.ResetTrans();
2319 data->SetStop(20); 2328 data->SetStop(20);
2320 data->Run(); 2329 data->Run();
2321 2330
2322 helper.VerifyDataConsumed(); 2331 helper.VerifyDataConsumed();
2323 } 2332 }
2324 2333
2325 // Verify that the client can correctly deal with the user callback attempting 2334 // 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 2335 // to start another transaction on a session that is closing down. See
2327 // http://crbug.com/47455 2336 // http://crbug.com/47455
2328 TEST_P(SpdyNetworkTransactionTest, StartTransactionOnReadCallback) { 2337 TEST_P(SpdyNetworkTransactionSpdy21Test, StartTransactionOnReadCallback) {
2329 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 2338 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
2330 MockWrite writes[] = { CreateMockWrite(*req) }; 2339 MockWrite writes[] = { CreateMockWrite(*req) };
2331 MockWrite writes2[] = { CreateMockWrite(*req) }; 2340 MockWrite writes2[] = { CreateMockWrite(*req) };
2332 2341
2333 // The indicated length of this packet is longer than its actual length. When 2342 // 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 2343 // the session receives an empty packet after this one, it shuts down the
2335 // session, and calls the read callback with the incomplete data. 2344 // session, and calls the read callback with the incomplete data.
2336 const uint8 kGetBodyFrame2[] = { 2345 const uint8 kGetBodyFrame2[] = {
2337 0x00, 0x00, 0x00, 0x01, 2346 0x00, 0x00, 0x00, 0x01,
2338 0x01, 0x00, 0x00, 0x07, 2347 0x01, 0x00, 0x00, 0x07,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2370 // Start the transaction with basic parameters. 2379 // Start the transaction with basic parameters.
2371 TestCompletionCallback callback; 2380 TestCompletionCallback callback;
2372 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); 2381 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog());
2373 EXPECT_EQ(ERR_IO_PENDING, rv); 2382 EXPECT_EQ(ERR_IO_PENDING, rv);
2374 rv = callback.WaitForResult(); 2383 rv = callback.WaitForResult();
2375 2384
2376 const int kSize = 3000; 2385 const int kSize = 3000;
2377 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSize)); 2386 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSize));
2378 rv = trans->Read( 2387 rv = trans->Read(
2379 buf, kSize, 2388 buf, kSize,
2380 base::Bind(&SpdyNetworkTransactionTest::StartTransactionCallback, 2389 base::Bind(&SpdyNetworkTransactionSpdy21Test::StartTransactionCallback,
2381 helper.session())); 2390 helper.session()));
2382 // This forces an err_IO_pending, which sets the callback. 2391 // This forces an err_IO_pending, which sets the callback.
2383 data->CompleteRead(); 2392 data->CompleteRead();
2384 // This finishes the read. 2393 // This finishes the read.
2385 data->CompleteRead(); 2394 data->CompleteRead();
2386 helper.VerifyDataConsumed(); 2395 helper.VerifyDataConsumed();
2387 } 2396 }
2388 2397
2389 // Verify that the client can correctly deal with the user callback deleting the 2398 // Verify that the client can correctly deal with the user callback deleting the
2390 // transaction. Failures will usually be valgrind errors. See 2399 // transaction. Failures will usually be valgrind errors. See
2391 // http://crbug.com/46925 2400 // http://crbug.com/46925
2392 TEST_P(SpdyNetworkTransactionTest, DeleteSessionOnReadCallback) { 2401 TEST_P(SpdyNetworkTransactionSpdy21Test, DeleteSessionOnReadCallback) {
2393 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 2402 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
2394 MockWrite writes[] = { CreateMockWrite(*req) }; 2403 MockWrite writes[] = { CreateMockWrite(*req) };
2395 2404
2396 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); 2405 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1));
2397 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); 2406 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true));
2398 MockRead reads[] = { 2407 MockRead reads[] = {
2399 CreateMockRead(*resp.get(), 2), 2408 CreateMockRead(*resp.get(), 2),
2400 MockRead(ASYNC, ERR_IO_PENDING, 3), // Force a pause 2409 MockRead(ASYNC, ERR_IO_PENDING, 3), // Force a pause
2401 CreateMockRead(*body.get(), 4), 2410 CreateMockRead(*body.get(), 4),
2402 MockRead(ASYNC, 0, 0, 5), // EOF 2411 MockRead(ASYNC, 0, 0, 5), // EOF
(...skipping 14 matching lines...) Expand all
2417 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog()); 2426 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog());
2418 EXPECT_EQ(ERR_IO_PENDING, rv); 2427 EXPECT_EQ(ERR_IO_PENDING, rv);
2419 rv = callback.WaitForResult(); 2428 rv = callback.WaitForResult();
2420 2429
2421 // Setup a user callback which will delete the session, and clear out the 2430 // 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. 2431 // memory holding the stream object. Note that the callback deletes trans.
2423 const int kSize = 3000; 2432 const int kSize = 3000;
2424 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSize)); 2433 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSize));
2425 rv = trans->Read( 2434 rv = trans->Read(
2426 buf, kSize, 2435 buf, kSize,
2427 base::Bind(&SpdyNetworkTransactionTest::DeleteSessionCallback, 2436 base::Bind(&SpdyNetworkTransactionSpdy21Test::DeleteSessionCallback,
2428 base::Unretained(&helper))); 2437 base::Unretained(&helper)));
2429 ASSERT_EQ(ERR_IO_PENDING, rv); 2438 ASSERT_EQ(ERR_IO_PENDING, rv);
2430 data->CompleteRead(); 2439 data->CompleteRead();
2431 2440
2432 // Finish running rest of tasks. 2441 // Finish running rest of tasks.
2433 MessageLoop::current()->RunAllPending(); 2442 MessageLoop::current()->RunAllPending();
2434 helper.VerifyDataConsumed(); 2443 helper.VerifyDataConsumed();
2435 } 2444 }
2436 2445
2437 // Send a spdy request to www.google.com that gets redirected to www.foo.com. 2446 // Send a spdy request to www.google.com that gets redirected to www.foo.com.
2438 TEST_P(SpdyNetworkTransactionTest, RedirectGetRequest) { 2447 TEST_P(SpdyNetworkTransactionSpdy21Test, RedirectGetRequest) {
2439 // These are headers which the net::URLRequest tacks on. 2448 // These are headers which the net::URLRequest tacks on.
2440 const char* const kExtraHeaders[] = { 2449 const char* const kExtraHeaders[] = {
2441 "accept-encoding", 2450 "accept-encoding",
2442 "gzip,deflate", 2451 "gzip,deflate",
2443 }; 2452 };
2444 const SpdyHeaderInfo kSynStartHeader = MakeSpdyHeader(spdy::SYN_STREAM); 2453 const SpdyHeaderInfo kSynStartHeader = MakeSpdyHeader(spdy::SYN_STREAM);
2445 const char* const kStandardGetHeaders[] = { 2454 const char* const kStandardGetHeaders[] = {
2446 "host", 2455 "host",
2447 "www.google.com", 2456 "www.google.com",
2448 "method", 2457 "method",
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
2533 std::string contents("hello!"); 2542 std::string contents("hello!");
2534 EXPECT_EQ(contents, d.data_received()); 2543 EXPECT_EQ(contents, d.data_received());
2535 } 2544 }
2536 EXPECT_TRUE(data->at_read_eof()); 2545 EXPECT_TRUE(data->at_read_eof());
2537 EXPECT_TRUE(data->at_write_eof()); 2546 EXPECT_TRUE(data->at_write_eof());
2538 EXPECT_TRUE(data2->at_read_eof()); 2547 EXPECT_TRUE(data2->at_read_eof());
2539 EXPECT_TRUE(data2->at_write_eof()); 2548 EXPECT_TRUE(data2->at_write_eof());
2540 } 2549 }
2541 2550
2542 // Detect response with upper case headers and reset the stream. 2551 // Detect response with upper case headers and reset the stream.
2543 TEST_P(SpdyNetworkTransactionTest, UpperCaseHeaders) { 2552 TEST_P(SpdyNetworkTransactionSpdy21Test, UpperCaseHeaders) {
2544 scoped_ptr<spdy::SpdyFrame> 2553 scoped_ptr<spdy::SpdyFrame>
2545 syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 2554 syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
2546 scoped_ptr<spdy::SpdyFrame> 2555 scoped_ptr<spdy::SpdyFrame>
2547 rst(ConstructSpdyRstStream(1, spdy::PROTOCOL_ERROR)); 2556 rst(ConstructSpdyRstStream(1, spdy::PROTOCOL_ERROR));
2548 MockWrite writes[] = { 2557 MockWrite writes[] = {
2549 CreateMockWrite(*syn, 0), 2558 CreateMockWrite(*syn, 0),
2550 CreateMockWrite(*rst, 2), 2559 CreateMockWrite(*rst, 2),
2551 }; 2560 };
2552 2561
2553 const char* const kExtraHeaders[] = {"X-UpperCase", "yes"}; 2562 const char* const kExtraHeaders[] = {"X-UpperCase", "yes"};
(...skipping 13 matching lines...) Expand all
2567 arraysize(writes))); 2576 arraysize(writes)));
2568 NormalSpdyTransactionHelper helper(CreateGetRequest(), 2577 NormalSpdyTransactionHelper helper(CreateGetRequest(),
2569 BoundNetLog(), GetParam()); 2578 BoundNetLog(), GetParam());
2570 helper.RunToCompletion(data.get()); 2579 helper.RunToCompletion(data.get());
2571 TransactionHelperResult out = helper.output(); 2580 TransactionHelperResult out = helper.output();
2572 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); 2581 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv);
2573 } 2582 }
2574 2583
2575 // Detect response with upper case headers in a HEADERS frame and reset the 2584 // Detect response with upper case headers in a HEADERS frame and reset the
2576 // stream. 2585 // stream.
2577 TEST_P(SpdyNetworkTransactionTest, UpperCaseHeadersInHeadersFrame) { 2586 TEST_P(SpdyNetworkTransactionSpdy21Test, UpperCaseHeadersInHeadersFrame) {
2578 scoped_ptr<spdy::SpdyFrame> 2587 scoped_ptr<spdy::SpdyFrame>
2579 syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 2588 syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
2580 scoped_ptr<spdy::SpdyFrame> 2589 scoped_ptr<spdy::SpdyFrame>
2581 rst(ConstructSpdyRstStream(1, spdy::PROTOCOL_ERROR)); 2590 rst(ConstructSpdyRstStream(1, spdy::PROTOCOL_ERROR));
2582 MockWrite writes[] = { 2591 MockWrite writes[] = {
2583 CreateMockWrite(*syn, 0), 2592 CreateMockWrite(*syn, 0),
2584 CreateMockWrite(*rst, 2), 2593 CreateMockWrite(*rst, 2),
2585 }; 2594 };
2586 2595
2587 static const char* const kInitialHeaders[] = { 2596 static const char* const kInitialHeaders[] = {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2625 new DelayedSocketData(1, reads, arraysize(reads), 2634 new DelayedSocketData(1, reads, arraysize(reads),
2626 writes, arraysize(writes))); 2635 writes, arraysize(writes)));
2627 NormalSpdyTransactionHelper helper(CreateGetRequest(), 2636 NormalSpdyTransactionHelper helper(CreateGetRequest(),
2628 BoundNetLog(), GetParam()); 2637 BoundNetLog(), GetParam());
2629 helper.RunToCompletion(data.get()); 2638 helper.RunToCompletion(data.get());
2630 TransactionHelperResult out = helper.output(); 2639 TransactionHelperResult out = helper.output();
2631 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); 2640 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv);
2632 } 2641 }
2633 2642
2634 // Detect push stream with upper case headers and reset the stream. 2643 // Detect push stream with upper case headers and reset the stream.
2635 TEST_P(SpdyNetworkTransactionTest, UpperCaseHeadersOnPush) { 2644 TEST_P(SpdyNetworkTransactionSpdy21Test, UpperCaseHeadersOnPush) {
2636 scoped_ptr<spdy::SpdyFrame> 2645 scoped_ptr<spdy::SpdyFrame>
2637 syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 2646 syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
2638 scoped_ptr<spdy::SpdyFrame> 2647 scoped_ptr<spdy::SpdyFrame>
2639 rst(ConstructSpdyRstStream(2, spdy::PROTOCOL_ERROR)); 2648 rst(ConstructSpdyRstStream(2, spdy::PROTOCOL_ERROR));
2640 MockWrite writes[] = { 2649 MockWrite writes[] = {
2641 CreateMockWrite(*syn, 0), 2650 CreateMockWrite(*syn, 0),
2642 CreateMockWrite(*rst, 2), 2651 CreateMockWrite(*rst, 2),
2643 }; 2652 };
2644 2653
2645 scoped_ptr<spdy::SpdyFrame> 2654 scoped_ptr<spdy::SpdyFrame>
(...skipping 18 matching lines...) Expand all
2664 arraysize(writes))); 2673 arraysize(writes)));
2665 NormalSpdyTransactionHelper helper(CreateGetRequest(), 2674 NormalSpdyTransactionHelper helper(CreateGetRequest(),
2666 BoundNetLog(), GetParam()); 2675 BoundNetLog(), GetParam());
2667 helper.RunToCompletion(data.get()); 2676 helper.RunToCompletion(data.get());
2668 TransactionHelperResult out = helper.output(); 2677 TransactionHelperResult out = helper.output();
2669 EXPECT_EQ(OK, out.rv); 2678 EXPECT_EQ(OK, out.rv);
2670 } 2679 }
2671 2680
2672 // Send a spdy request to www.google.com. Get a pushed stream that redirects to 2681 // Send a spdy request to www.google.com. Get a pushed stream that redirects to
2673 // www.foo.com. 2682 // www.foo.com.
2674 TEST_P(SpdyNetworkTransactionTest, RedirectServerPush) { 2683 TEST_P(SpdyNetworkTransactionSpdy21Test, RedirectServerPush) {
2675 // These are headers which the net::URLRequest tacks on. 2684 // These are headers which the net::URLRequest tacks on.
2676 const char* const kExtraHeaders[] = { 2685 const char* const kExtraHeaders[] = {
2677 "accept-encoding", 2686 "accept-encoding",
2678 "gzip,deflate", 2687 "gzip,deflate",
2679 }; 2688 };
2680 const SpdyHeaderInfo kSynStartHeader = MakeSpdyHeader(spdy::SYN_STREAM); 2689 const SpdyHeaderInfo kSynStartHeader = MakeSpdyHeader(spdy::SYN_STREAM);
2681 const char* const kStandardGetHeaders[] = { 2690 const char* const kStandardGetHeaders[] = {
2682 "host", 2691 "host",
2683 "www.google.com", 2692 "www.google.com",
2684 "method", 2693 "method",
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
2800 EXPECT_EQ(contents2, d2.data_received()); 2809 EXPECT_EQ(contents2, d2.data_received());
2801 } 2810 }
2802 data->CompleteRead(); 2811 data->CompleteRead();
2803 data2->CompleteRead(); 2812 data2->CompleteRead();
2804 EXPECT_TRUE(data->at_read_eof()); 2813 EXPECT_TRUE(data->at_read_eof());
2805 EXPECT_TRUE(data->at_write_eof()); 2814 EXPECT_TRUE(data->at_write_eof());
2806 EXPECT_TRUE(data2->at_read_eof()); 2815 EXPECT_TRUE(data2->at_read_eof());
2807 EXPECT_TRUE(data2->at_write_eof()); 2816 EXPECT_TRUE(data2->at_write_eof());
2808 } 2817 }
2809 2818
2810 TEST_P(SpdyNetworkTransactionTest, ServerPushSingleDataFrame) { 2819 TEST_P(SpdyNetworkTransactionSpdy21Test, ServerPushSingleDataFrame) {
2811 static const unsigned char kPushBodyFrame[] = { 2820 static const unsigned char kPushBodyFrame[] = {
2812 0x00, 0x00, 0x00, 0x02, // header, ID 2821 0x00, 0x00, 0x00, 0x02, // header, ID
2813 0x01, 0x00, 0x00, 0x06, // FIN, length 2822 0x01, 0x00, 0x00, 0x06, // FIN, length
2814 'p', 'u', 's', 'h', 'e', 'd' // "pushed" 2823 'p', 'u', 's', 'h', 'e', 'd' // "pushed"
2815 }; 2824 };
2816 scoped_ptr<spdy::SpdyFrame> 2825 scoped_ptr<spdy::SpdyFrame>
2817 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 2826 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
2818 scoped_ptr<spdy::SpdyFrame> 2827 scoped_ptr<spdy::SpdyFrame>
2819 stream1_body(ConstructSpdyBodyFrame(1, true)); 2828 stream1_body(ConstructSpdyBodyFrame(1, true));
2820 MockWrite writes[] = { 2829 MockWrite writes[] = {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2853 2862
2854 // Verify the SYN_REPLY. 2863 // Verify the SYN_REPLY.
2855 EXPECT_TRUE(response.headers != NULL); 2864 EXPECT_TRUE(response.headers != NULL);
2856 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 2865 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
2857 2866
2858 // Verify the pushed stream. 2867 // Verify the pushed stream.
2859 EXPECT_TRUE(response2.headers != NULL); 2868 EXPECT_TRUE(response2.headers != NULL);
2860 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); 2869 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine());
2861 } 2870 }
2862 2871
2863 TEST_P(SpdyNetworkTransactionTest, ServerPushSingleDataFrame2) { 2872 TEST_P(SpdyNetworkTransactionSpdy21Test, ServerPushSingleDataFrame2) {
2864 static const unsigned char kPushBodyFrame[] = { 2873 static const unsigned char kPushBodyFrame[] = {
2865 0x00, 0x00, 0x00, 0x02, // header, ID 2874 0x00, 0x00, 0x00, 0x02, // header, ID
2866 0x01, 0x00, 0x00, 0x06, // FIN, length 2875 0x01, 0x00, 0x00, 0x06, // FIN, length
2867 'p', 'u', 's', 'h', 'e', 'd' // "pushed" 2876 'p', 'u', 's', 'h', 'e', 'd' // "pushed"
2868 }; 2877 };
2869 scoped_ptr<spdy::SpdyFrame> 2878 scoped_ptr<spdy::SpdyFrame>
2870 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 2879 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
2871 MockWrite writes[] = { 2880 MockWrite writes[] = {
2872 CreateMockWrite(*stream1_syn, 1), 2881 CreateMockWrite(*stream1_syn, 1),
2873 }; 2882 };
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2906 2915
2907 // Verify the SYN_REPLY. 2916 // Verify the SYN_REPLY.
2908 EXPECT_TRUE(response.headers != NULL); 2917 EXPECT_TRUE(response.headers != NULL);
2909 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 2918 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
2910 2919
2911 // Verify the pushed stream. 2920 // Verify the pushed stream.
2912 EXPECT_TRUE(response2.headers != NULL); 2921 EXPECT_TRUE(response2.headers != NULL);
2913 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); 2922 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine());
2914 } 2923 }
2915 2924
2916 TEST_P(SpdyNetworkTransactionTest, ServerPushServerAborted) { 2925 TEST_P(SpdyNetworkTransactionSpdy21Test, ServerPushServerAborted) {
2917 scoped_ptr<spdy::SpdyFrame> 2926 scoped_ptr<spdy::SpdyFrame>
2918 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 2927 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
2919 scoped_ptr<spdy::SpdyFrame> 2928 scoped_ptr<spdy::SpdyFrame>
2920 stream1_body(ConstructSpdyBodyFrame(1, true)); 2929 stream1_body(ConstructSpdyBodyFrame(1, true));
2921 MockWrite writes[] = { 2930 MockWrite writes[] = {
2922 CreateMockWrite(*stream1_syn, 1), 2931 CreateMockWrite(*stream1_syn, 1),
2923 }; 2932 };
2924 2933
2925 scoped_ptr<spdy::SpdyFrame> 2934 scoped_ptr<spdy::SpdyFrame>
2926 stream1_reply(ConstructSpdyGetSynReply(NULL, 0, 1)); 2935 stream1_reply(ConstructSpdyGetSynReply(NULL, 0, 1));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2968 << data->write_count() 2977 << data->write_count()
2969 << " Write index: " 2978 << " Write index: "
2970 << data->write_index(); 2979 << data->write_index();
2971 2980
2972 // Verify the SYN_REPLY. 2981 // Verify the SYN_REPLY.
2973 HttpResponseInfo response = *trans->GetResponseInfo(); 2982 HttpResponseInfo response = *trans->GetResponseInfo();
2974 EXPECT_TRUE(response.headers != NULL); 2983 EXPECT_TRUE(response.headers != NULL);
2975 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 2984 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
2976 } 2985 }
2977 2986
2978 TEST_P(SpdyNetworkTransactionTest, ServerPushDuplicate) { 2987 TEST_P(SpdyNetworkTransactionSpdy21Test, ServerPushDuplicate) {
2979 // Verify that we don't leak streams and that we properly send a reset 2988 // Verify that we don't leak streams and that we properly send a reset
2980 // if the server pushes the same stream twice. 2989 // if the server pushes the same stream twice.
2981 static const unsigned char kPushBodyFrame[] = { 2990 static const unsigned char kPushBodyFrame[] = {
2982 0x00, 0x00, 0x00, 0x02, // header, ID 2991 0x00, 0x00, 0x00, 0x02, // header, ID
2983 0x01, 0x00, 0x00, 0x06, // FIN, length 2992 0x01, 0x00, 0x00, 0x06, // FIN, length
2984 'p', 'u', 's', 'h', 'e', 'd' // "pushed" 2993 'p', 'u', 's', 'h', 'e', 'd' // "pushed"
2985 }; 2994 };
2986 2995
2987 scoped_ptr<spdy::SpdyFrame> 2996 scoped_ptr<spdy::SpdyFrame>
2988 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 2997 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
3034 3043
3035 // Verify the SYN_REPLY. 3044 // Verify the SYN_REPLY.
3036 EXPECT_TRUE(response.headers != NULL); 3045 EXPECT_TRUE(response.headers != NULL);
3037 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 3046 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
3038 3047
3039 // Verify the pushed stream. 3048 // Verify the pushed stream.
3040 EXPECT_TRUE(response2.headers != NULL); 3049 EXPECT_TRUE(response2.headers != NULL);
3041 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); 3050 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine());
3042 } 3051 }
3043 3052
3044 TEST_P(SpdyNetworkTransactionTest, ServerPushMultipleDataFrame) { 3053 TEST_P(SpdyNetworkTransactionSpdy21Test, ServerPushMultipleDataFrame) {
3045 static const unsigned char kPushBodyFrame1[] = { 3054 static const unsigned char kPushBodyFrame1[] = {
3046 0x00, 0x00, 0x00, 0x02, // header, ID 3055 0x00, 0x00, 0x00, 0x02, // header, ID
3047 0x01, 0x00, 0x00, 0x1F, // FIN, length 3056 0x01, 0x00, 0x00, 0x1F, // FIN, length
3048 'p', 'u', 's', 'h', 'e', 'd' // "pushed" 3057 'p', 'u', 's', 'h', 'e', 'd' // "pushed"
3049 }; 3058 };
3050 static const char kPushBodyFrame2[] = " my darling"; 3059 static const char kPushBodyFrame2[] = " my darling";
3051 static const char kPushBodyFrame3[] = " hello"; 3060 static const char kPushBodyFrame3[] = " hello";
3052 static const char kPushBodyFrame4[] = " my baby"; 3061 static const char kPushBodyFrame4[] = " my baby";
3053 3062
3054 scoped_ptr<spdy::SpdyFrame> 3063 scoped_ptr<spdy::SpdyFrame>
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
3097 3106
3098 // Verify the SYN_REPLY. 3107 // Verify the SYN_REPLY.
3099 EXPECT_TRUE(response.headers != NULL); 3108 EXPECT_TRUE(response.headers != NULL);
3100 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 3109 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
3101 3110
3102 // Verify the pushed stream. 3111 // Verify the pushed stream.
3103 EXPECT_TRUE(response2.headers != NULL); 3112 EXPECT_TRUE(response2.headers != NULL);
3104 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); 3113 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine());
3105 } 3114 }
3106 3115
3107 TEST_P(SpdyNetworkTransactionTest, ServerPushMultipleDataFrameInterrupted) { 3116 TEST_P(SpdyNetworkTransactionSpdy21Test,
3117 ServerPushMultipleDataFrameInterrupted) {
3108 SpdySession::set_use_flow_control(SpdySession::kDisableFlowControl); 3118 SpdySession::set_use_flow_control(SpdySession::kDisableFlowControl);
3109 3119
3110 static const unsigned char kPushBodyFrame1[] = { 3120 static const unsigned char kPushBodyFrame1[] = {
3111 0x00, 0x00, 0x00, 0x02, // header, ID 3121 0x00, 0x00, 0x00, 0x02, // header, ID
3112 0x01, 0x00, 0x00, 0x1F, // FIN, length 3122 0x01, 0x00, 0x00, 0x1F, // FIN, length
3113 'p', 'u', 's', 'h', 'e', 'd' // "pushed" 3123 'p', 'u', 's', 'h', 'e', 'd' // "pushed"
3114 }; 3124 };
3115 static const char kPushBodyFrame2[] = " my darling"; 3125 static const char kPushBodyFrame2[] = " my darling";
3116 static const char kPushBodyFrame3[] = " hello"; 3126 static const char kPushBodyFrame3[] = " hello";
3117 static const char kPushBodyFrame4[] = " my baby"; 3127 static const char kPushBodyFrame4[] = " my baby";
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
3165 EXPECT_TRUE(response.headers != NULL); 3175 EXPECT_TRUE(response.headers != NULL);
3166 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 3176 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
3167 3177
3168 // Verify the pushed stream. 3178 // Verify the pushed stream.
3169 EXPECT_TRUE(response2.headers != NULL); 3179 EXPECT_TRUE(response2.headers != NULL);
3170 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); 3180 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine());
3171 3181
3172 SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); 3182 SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN);
3173 } 3183 }
3174 3184
3175 TEST_P(SpdyNetworkTransactionTest, ServerPushInvalidAssociatedStreamID0) { 3185 TEST_P(SpdyNetworkTransactionSpdy21Test, ServerPushInvalidAssociatedStreamID0) {
3176 scoped_ptr<spdy::SpdyFrame> 3186 scoped_ptr<spdy::SpdyFrame>
3177 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 3187 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
3178 scoped_ptr<spdy::SpdyFrame> 3188 scoped_ptr<spdy::SpdyFrame>
3179 stream1_body(ConstructSpdyBodyFrame(1, true)); 3189 stream1_body(ConstructSpdyBodyFrame(1, true));
3180 scoped_ptr<spdy::SpdyFrame> 3190 scoped_ptr<spdy::SpdyFrame>
3181 stream2_rst(ConstructSpdyRstStream(2, spdy::INVALID_STREAM)); 3191 stream2_rst(ConstructSpdyRstStream(2, spdy::INVALID_STREAM));
3182 MockWrite writes[] = { 3192 MockWrite writes[] = {
3183 CreateMockWrite(*stream1_syn, 1), 3193 CreateMockWrite(*stream1_syn, 1),
3184 CreateMockWrite(*stream2_rst, 4), 3194 CreateMockWrite(*stream2_rst, 4),
3185 }; 3195 };
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
3227 << data->write_count() 3237 << data->write_count()
3228 << " Write index: " 3238 << " Write index: "
3229 << data->write_index(); 3239 << data->write_index();
3230 3240
3231 // Verify the SYN_REPLY. 3241 // Verify the SYN_REPLY.
3232 HttpResponseInfo response = *trans->GetResponseInfo(); 3242 HttpResponseInfo response = *trans->GetResponseInfo();
3233 EXPECT_TRUE(response.headers != NULL); 3243 EXPECT_TRUE(response.headers != NULL);
3234 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 3244 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
3235 } 3245 }
3236 3246
3237 TEST_P(SpdyNetworkTransactionTest, ServerPushInvalidAssociatedStreamID9) { 3247 TEST_P(SpdyNetworkTransactionSpdy21Test, ServerPushInvalidAssociatedStreamID9) {
3238 scoped_ptr<spdy::SpdyFrame> 3248 scoped_ptr<spdy::SpdyFrame>
3239 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 3249 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
3240 scoped_ptr<spdy::SpdyFrame> 3250 scoped_ptr<spdy::SpdyFrame>
3241 stream1_body(ConstructSpdyBodyFrame(1, true)); 3251 stream1_body(ConstructSpdyBodyFrame(1, true));
3242 scoped_ptr<spdy::SpdyFrame> 3252 scoped_ptr<spdy::SpdyFrame>
3243 stream2_rst(ConstructSpdyRstStream(2, spdy::INVALID_ASSOCIATED_STREAM)); 3253 stream2_rst(ConstructSpdyRstStream(2, spdy::INVALID_ASSOCIATED_STREAM));
3244 MockWrite writes[] = { 3254 MockWrite writes[] = {
3245 CreateMockWrite(*stream1_syn, 1), 3255 CreateMockWrite(*stream1_syn, 1),
3246 CreateMockWrite(*stream2_rst, 4), 3256 CreateMockWrite(*stream2_rst, 4),
3247 }; 3257 };
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
3289 << data->write_count() 3299 << data->write_count()
3290 << " Write index: " 3300 << " Write index: "
3291 << data->write_index(); 3301 << data->write_index();
3292 3302
3293 // Verify the SYN_REPLY. 3303 // Verify the SYN_REPLY.
3294 HttpResponseInfo response = *trans->GetResponseInfo(); 3304 HttpResponseInfo response = *trans->GetResponseInfo();
3295 EXPECT_TRUE(response.headers != NULL); 3305 EXPECT_TRUE(response.headers != NULL);
3296 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 3306 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
3297 } 3307 }
3298 3308
3299 TEST_P(SpdyNetworkTransactionTest, ServerPushNoURL) { 3309 TEST_P(SpdyNetworkTransactionSpdy21Test, ServerPushNoURL) {
3300 scoped_ptr<spdy::SpdyFrame> 3310 scoped_ptr<spdy::SpdyFrame>
3301 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 3311 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
3302 scoped_ptr<spdy::SpdyFrame> 3312 scoped_ptr<spdy::SpdyFrame>
3303 stream1_body(ConstructSpdyBodyFrame(1, true)); 3313 stream1_body(ConstructSpdyBodyFrame(1, true));
3304 scoped_ptr<spdy::SpdyFrame> 3314 scoped_ptr<spdy::SpdyFrame>
3305 stream2_rst(ConstructSpdyRstStream(2, spdy::PROTOCOL_ERROR)); 3315 stream2_rst(ConstructSpdyRstStream(2, spdy::PROTOCOL_ERROR));
3306 MockWrite writes[] = { 3316 MockWrite writes[] = {
3307 CreateMockWrite(*stream1_syn, 1), 3317 CreateMockWrite(*stream1_syn, 1),
3308 CreateMockWrite(*stream2_rst, 4), 3318 CreateMockWrite(*stream2_rst, 4),
3309 }; 3319 };
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
3348 << data->write_index(); 3358 << data->write_index();
3349 3359
3350 // Verify the SYN_REPLY. 3360 // Verify the SYN_REPLY.
3351 HttpResponseInfo response = *trans->GetResponseInfo(); 3361 HttpResponseInfo response = *trans->GetResponseInfo();
3352 EXPECT_TRUE(response.headers != NULL); 3362 EXPECT_TRUE(response.headers != NULL);
3353 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 3363 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
3354 } 3364 }
3355 3365
3356 // Verify that various SynReply headers parse correctly through the 3366 // Verify that various SynReply headers parse correctly through the
3357 // HTTP layer. 3367 // HTTP layer.
3358 TEST_P(SpdyNetworkTransactionTest, SynReplyHeaders) { 3368 TEST_P(SpdyNetworkTransactionSpdy21Test, SynReplyHeaders) {
3359 struct SynReplyHeadersTests { 3369 struct SynReplyHeadersTests {
3360 int num_headers; 3370 int num_headers;
3361 const char* extra_headers[5]; 3371 const char* extra_headers[5];
3362 const char* expected_headers; 3372 const char* expected_headers;
3363 } test_cases[] = { 3373 } test_cases[] = {
3364 // This uses a multi-valued cookie header. 3374 // This uses a multi-valued cookie header.
3365 { 2, 3375 { 2,
3366 { "cookie", "val1", 3376 { "cookie", "val1",
3367 "cookie", "val2", // will get appended separated by NULL 3377 "cookie", "val2", // will get appended separated by NULL
3368 NULL 3378 NULL
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
3429 lines.append(": "); 3439 lines.append(": ");
3430 lines.append(value); 3440 lines.append(value);
3431 lines.append("\n"); 3441 lines.append("\n");
3432 } 3442 }
3433 EXPECT_EQ(std::string(test_cases[i].expected_headers), lines); 3443 EXPECT_EQ(std::string(test_cases[i].expected_headers), lines);
3434 } 3444 }
3435 } 3445 }
3436 3446
3437 // Verify that various SynReply headers parse vary fields correctly 3447 // Verify that various SynReply headers parse vary fields correctly
3438 // through the HTTP layer, and the response matches the request. 3448 // through the HTTP layer, and the response matches the request.
3439 TEST_P(SpdyNetworkTransactionTest, SynReplyHeadersVary) { 3449 TEST_P(SpdyNetworkTransactionSpdy21Test, SynReplyHeadersVary) {
3440 static const SpdyHeaderInfo syn_reply_info = { 3450 static const SpdyHeaderInfo syn_reply_info = {
3441 spdy::SYN_REPLY, // Syn Reply 3451 spdy::SYN_REPLY, // Syn Reply
3442 1, // Stream ID 3452 1, // Stream ID
3443 0, // Associated Stream ID 3453 0, // Associated Stream ID
3444 net::ConvertRequestPriorityToSpdyPriority(LOWEST), 3454 net::ConvertRequestPriorityToSpdyPriority(LOWEST),
3445 // Priority 3455 // Priority
3446 spdy::CONTROL_FLAG_NONE, // Control Flags 3456 spdy::CONTROL_FLAG_NONE, // Control Flags
3447 false, // Compressed 3457 false, // Compressed
3448 spdy::INVALID, // Status 3458 spdy::INVALID, // Status
3449 NULL, // Data 3459 NULL, // Data
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
3598 ConstructSpdyReplyString(test_cases[i].extra_headers[1], 3608 ConstructSpdyReplyString(test_cases[i].extra_headers[1],
3599 test_cases[i].num_headers[1], 3609 test_cases[i].num_headers[1],
3600 reply_buffer, 3610 reply_buffer,
3601 256); 3611 256);
3602 3612
3603 EXPECT_EQ(std::string(reply_buffer), lines) << i; 3613 EXPECT_EQ(std::string(reply_buffer), lines) << i;
3604 } 3614 }
3605 } 3615 }
3606 3616
3607 // Verify that we don't crash on invalid SynReply responses. 3617 // Verify that we don't crash on invalid SynReply responses.
3608 TEST_P(SpdyNetworkTransactionTest, InvalidSynReply) { 3618 TEST_P(SpdyNetworkTransactionSpdy21Test, InvalidSynReply) {
3609 const SpdyHeaderInfo kSynStartHeader = { 3619 const SpdyHeaderInfo kSynStartHeader = {
3610 spdy::SYN_REPLY, // Kind = SynReply 3620 spdy::SYN_REPLY, // Kind = SynReply
3611 1, // Stream ID 3621 1, // Stream ID
3612 0, // Associated stream ID 3622 0, // Associated stream ID
3613 net::ConvertRequestPriorityToSpdyPriority(LOWEST), 3623 net::ConvertRequestPriorityToSpdyPriority(LOWEST),
3614 // Priority 3624 // Priority
3615 spdy::CONTROL_FLAG_NONE, // Control Flags 3625 spdy::CONTROL_FLAG_NONE, // Control Flags
3616 false, // Compressed 3626 false, // Compressed
3617 spdy::INVALID, // Status 3627 spdy::INVALID, // Status
3618 NULL, // Data 3628 NULL, // Data
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
3668 writes, arraysize(writes))); 3678 writes, arraysize(writes)));
3669 NormalSpdyTransactionHelper helper(CreateGetRequest(), 3679 NormalSpdyTransactionHelper helper(CreateGetRequest(),
3670 BoundNetLog(), GetParam()); 3680 BoundNetLog(), GetParam());
3671 helper.RunToCompletion(data.get()); 3681 helper.RunToCompletion(data.get());
3672 TransactionHelperResult out = helper.output(); 3682 TransactionHelperResult out = helper.output();
3673 EXPECT_EQ(ERR_INCOMPLETE_SPDY_HEADERS, out.rv); 3683 EXPECT_EQ(ERR_INCOMPLETE_SPDY_HEADERS, out.rv);
3674 } 3684 }
3675 } 3685 }
3676 3686
3677 // Verify that we don't crash on some corrupt frames. 3687 // Verify that we don't crash on some corrupt frames.
3678 TEST_P(SpdyNetworkTransactionTest, CorruptFrameSessionError) { 3688 TEST_P(SpdyNetworkTransactionSpdy21Test, CorruptFrameSessionError) {
3679 // This is the length field that's too short. 3689 // This is the length field that's too short.
3680 scoped_ptr<spdy::SpdyFrame> syn_reply_wrong_length( 3690 scoped_ptr<spdy::SpdyFrame> syn_reply_wrong_length(
3681 ConstructSpdyGetSynReply(NULL, 0, 1)); 3691 ConstructSpdyGetSynReply(NULL, 0, 1));
3682 syn_reply_wrong_length->set_length(syn_reply_wrong_length->length() - 4); 3692 syn_reply_wrong_length->set_length(syn_reply_wrong_length->length() - 4);
3683 3693
3684 struct SynReplyTests { 3694 struct SynReplyTests {
3685 const spdy::SpdyFrame* syn_reply; 3695 const spdy::SpdyFrame* syn_reply;
3686 } test_cases[] = { 3696 } test_cases[] = {
3687 { syn_reply_wrong_length.get(), }, 3697 { syn_reply_wrong_length.get(), },
3688 }; 3698 };
(...skipping 18 matching lines...) Expand all
3707 writes, arraysize(writes))); 3717 writes, arraysize(writes)));
3708 NormalSpdyTransactionHelper helper(CreateGetRequest(), 3718 NormalSpdyTransactionHelper helper(CreateGetRequest(),
3709 BoundNetLog(), GetParam()); 3719 BoundNetLog(), GetParam());
3710 helper.RunToCompletion(data.get()); 3720 helper.RunToCompletion(data.get());
3711 TransactionHelperResult out = helper.output(); 3721 TransactionHelperResult out = helper.output();
3712 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); 3722 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv);
3713 } 3723 }
3714 } 3724 }
3715 3725
3716 // Test that we shutdown correctly on write errors. 3726 // Test that we shutdown correctly on write errors.
3717 TEST_P(SpdyNetworkTransactionTest, WriteError) { 3727 TEST_P(SpdyNetworkTransactionSpdy21Test, WriteError) {
3718 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 3728 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
3719 MockWrite writes[] = { 3729 MockWrite writes[] = {
3720 // We'll write 10 bytes successfully 3730 // We'll write 10 bytes successfully
3721 MockWrite(ASYNC, req->data(), 10), 3731 MockWrite(ASYNC, req->data(), 10),
3722 // Followed by ERROR! 3732 // Followed by ERROR!
3723 MockWrite(ASYNC, ERR_FAILED), 3733 MockWrite(ASYNC, ERR_FAILED),
3724 }; 3734 };
3725 3735
3726 scoped_ptr<DelayedSocketData> data( 3736 scoped_ptr<DelayedSocketData> data(
3727 new DelayedSocketData(2, NULL, 0, 3737 new DelayedSocketData(2, NULL, 0,
3728 writes, arraysize(writes))); 3738 writes, arraysize(writes)));
3729 NormalSpdyTransactionHelper helper(CreateGetRequest(), 3739 NormalSpdyTransactionHelper helper(CreateGetRequest(),
3730 BoundNetLog(), GetParam()); 3740 BoundNetLog(), GetParam());
3731 helper.RunToCompletion(data.get()); 3741 helper.RunToCompletion(data.get());
3732 TransactionHelperResult out = helper.output(); 3742 TransactionHelperResult out = helper.output();
3733 EXPECT_EQ(ERR_FAILED, out.rv); 3743 EXPECT_EQ(ERR_FAILED, out.rv);
3734 data->Reset(); 3744 data->Reset();
3735 } 3745 }
3736 3746
3737 // Test that partial writes work. 3747 // Test that partial writes work.
3738 TEST_P(SpdyNetworkTransactionTest, PartialWrite) { 3748 TEST_P(SpdyNetworkTransactionSpdy21Test, PartialWrite) {
3739 // Chop the SYN_STREAM frame into 5 chunks. 3749 // Chop the SYN_STREAM frame into 5 chunks.
3740 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 3750 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
3741 const int kChunks = 5; 3751 const int kChunks = 5;
3742 scoped_array<MockWrite> writes(ChopWriteFrame(*req.get(), kChunks)); 3752 scoped_array<MockWrite> writes(ChopWriteFrame(*req.get(), kChunks));
3743 3753
3744 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); 3754 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1));
3745 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); 3755 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true));
3746 MockRead reads[] = { 3756 MockRead reads[] = {
3747 CreateMockRead(*resp), 3757 CreateMockRead(*resp),
3748 CreateMockRead(*body), 3758 CreateMockRead(*body),
3749 MockRead(ASYNC, 0, 0) // EOF 3759 MockRead(ASYNC, 0, 0) // EOF
3750 }; 3760 };
3751 3761
3752 scoped_ptr<DelayedSocketData> data( 3762 scoped_ptr<DelayedSocketData> data(
3753 new DelayedSocketData(kChunks, reads, arraysize(reads), 3763 new DelayedSocketData(kChunks, reads, arraysize(reads),
3754 writes.get(), kChunks)); 3764 writes.get(), kChunks));
3755 NormalSpdyTransactionHelper helper(CreateGetRequest(), 3765 NormalSpdyTransactionHelper helper(CreateGetRequest(),
3756 BoundNetLog(), GetParam()); 3766 BoundNetLog(), GetParam());
3757 helper.RunToCompletion(data.get()); 3767 helper.RunToCompletion(data.get());
3758 TransactionHelperResult out = helper.output(); 3768 TransactionHelperResult out = helper.output();
3759 EXPECT_EQ(OK, out.rv); 3769 EXPECT_EQ(OK, out.rv);
3760 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); 3770 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line);
3761 EXPECT_EQ("hello!", out.response_data); 3771 EXPECT_EQ("hello!", out.response_data);
3762 } 3772 }
3763 3773
3764 // In this test, we enable compression, but get a uncompressed SynReply from 3774 // In this test, we enable compression, but get a uncompressed SynReply from
3765 // the server. Verify that teardown is all clean. 3775 // the server. Verify that teardown is all clean.
3766 TEST_P(SpdyNetworkTransactionTest, DecompressFailureOnSynReply) { 3776 TEST_P(SpdyNetworkTransactionSpdy21Test, DecompressFailureOnSynReply) {
3767 // For this test, we turn on the normal compression. 3777 // For this test, we turn on the normal compression.
3768 EnableCompression(true); 3778 EnableCompression(true);
3769 3779
3770 scoped_ptr<spdy::SpdyFrame> compressed( 3780 scoped_ptr<spdy::SpdyFrame> compressed(
3771 ConstructSpdyGet(NULL, 0, true, 1, LOWEST)); 3781 ConstructSpdyGet(NULL, 0, true, 1, LOWEST));
3772 scoped_ptr<spdy::SpdyFrame> rst( 3782 scoped_ptr<spdy::SpdyFrame> rst(
3773 ConstructSpdyRstStream(1, spdy::PROTOCOL_ERROR)); 3783 ConstructSpdyRstStream(1, spdy::PROTOCOL_ERROR));
3774 MockWrite writes[] = { 3784 MockWrite writes[] = {
3775 CreateMockWrite(*compressed), 3785 CreateMockWrite(*compressed),
3776 }; 3786 };
(...skipping 11 matching lines...) Expand all
3788 BoundNetLog(), GetParam()); 3798 BoundNetLog(), GetParam());
3789 helper.RunToCompletion(data.get()); 3799 helper.RunToCompletion(data.get());
3790 TransactionHelperResult out = helper.output(); 3800 TransactionHelperResult out = helper.output();
3791 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); 3801 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv);
3792 data->Reset(); 3802 data->Reset();
3793 3803
3794 EnableCompression(false); 3804 EnableCompression(false);
3795 } 3805 }
3796 3806
3797 // Test that the NetLog contains good data for a simple GET request. 3807 // Test that the NetLog contains good data for a simple GET request.
3798 TEST_P(SpdyNetworkTransactionTest, NetLog) { 3808 TEST_P(SpdyNetworkTransactionSpdy21Test, NetLog) {
3799 static const char* const kExtraHeaders[] = { 3809 static const char* const kExtraHeaders[] = {
3800 "user-agent", "Chrome", 3810 "user-agent", "Chrome",
3801 }; 3811 };
3802 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(kExtraHeaders, 1, false, 1, 3812 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(kExtraHeaders, 1, false, 1,
3803 LOWEST)); 3813 LOWEST));
3804 MockWrite writes[] = { CreateMockWrite(*req) }; 3814 MockWrite writes[] = { CreateMockWrite(*req) };
3805 3815
3806 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); 3816 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1));
3807 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); 3817 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true));
3808 MockRead reads[] = { 3818 MockRead reads[] = {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
3876 it != end; 3886 it != end;
3877 ++it) { 3887 ++it) {
3878 EXPECT_EQ(it->second, (*headers)[it->first]); 3888 EXPECT_EQ(it->second, (*headers)[it->first]);
3879 } 3889 }
3880 } 3890 }
3881 3891
3882 // Since we buffer the IO from the stream to the renderer, this test verifies 3892 // 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 3893 // 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 3894 // on the network, but issued a Read for only 5 of those bytes) that the data
3885 // flow still works correctly. 3895 // flow still works correctly.
3886 TEST_P(SpdyNetworkTransactionTest, BufferFull) { 3896 TEST_P(SpdyNetworkTransactionSpdy21Test, BufferFull) {
3887 SpdySession::set_use_flow_control(SpdySession::kDisableFlowControl); 3897 SpdySession::set_use_flow_control(SpdySession::kDisableFlowControl);
3888 3898
3889 spdy::SpdyFramer framer; 3899 spdy::SpdyFramer framer;
3890 3900
3891 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 3901 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
3892 MockWrite writes[] = { CreateMockWrite(*req) }; 3902 MockWrite writes[] = { CreateMockWrite(*req) };
3893 3903
3894 // 2 data frames in a single read. 3904 // 2 data frames in a single read.
3895 scoped_ptr<spdy::SpdyFrame> data_frame_1( 3905 scoped_ptr<spdy::SpdyFrame> data_frame_1(
3896 framer.CreateDataFrame(1, "goodby", 6, spdy::DATA_FLAG_NONE)); 3906 framer.CreateDataFrame(1, "goodby", 6, spdy::DATA_FLAG_NONE));
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
3975 EXPECT_EQ(OK, out.rv); 3985 EXPECT_EQ(OK, out.rv);
3976 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); 3986 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line);
3977 EXPECT_EQ("goodbye world", out.response_data); 3987 EXPECT_EQ("goodbye world", out.response_data);
3978 3988
3979 SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); 3989 SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN);
3980 } 3990 }
3981 3991
3982 // Verify that basic buffering works; when multiple data frames arrive 3992 // 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 3993 // at the same time, ensure that we don't notify a read completion for
3984 // each data frame individually. 3994 // each data frame individually.
3985 TEST_P(SpdyNetworkTransactionTest, Buffering) { 3995 TEST_P(SpdyNetworkTransactionSpdy21Test, Buffering) {
3986 SpdySession::set_use_flow_control(SpdySession::kDisableFlowControl); 3996 SpdySession::set_use_flow_control(SpdySession::kDisableFlowControl);
3987 3997
3988 spdy::SpdyFramer framer; 3998 spdy::SpdyFramer framer;
3989 3999
3990 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 4000 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
3991 MockWrite writes[] = { CreateMockWrite(*req) }; 4001 MockWrite writes[] = { CreateMockWrite(*req) };
3992 4002
3993 // 4 data frames in a single read. 4003 // 4 data frames in a single read.
3994 scoped_ptr<spdy::SpdyFrame> data_frame( 4004 scoped_ptr<spdy::SpdyFrame> data_frame(
3995 framer.CreateDataFrame(1, "message", 7, spdy::DATA_FLAG_NONE)); 4005 framer.CreateDataFrame(1, "message", 7, spdy::DATA_FLAG_NONE));
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
4074 helper.VerifyDataConsumed(); 4084 helper.VerifyDataConsumed();
4075 4085
4076 EXPECT_EQ(OK, out.rv); 4086 EXPECT_EQ(OK, out.rv);
4077 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); 4087 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line);
4078 EXPECT_EQ("messagemessagemessagemessage", out.response_data); 4088 EXPECT_EQ("messagemessagemessagemessage", out.response_data);
4079 4089
4080 SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); 4090 SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN);
4081 } 4091 }
4082 4092
4083 // Verify the case where we buffer data but read it after it has been buffered. 4093 // Verify the case where we buffer data but read it after it has been buffered.
4084 TEST_P(SpdyNetworkTransactionTest, BufferedAll) { 4094 TEST_P(SpdyNetworkTransactionSpdy21Test, BufferedAll) {
4085 spdy::SpdyFramer framer; 4095 spdy::SpdyFramer framer;
4086 4096
4087 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 4097 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
4088 MockWrite writes[] = { CreateMockWrite(*req) }; 4098 MockWrite writes[] = { CreateMockWrite(*req) };
4089 4099
4090 // 5 data frames in a single read. 4100 // 5 data frames in a single read.
4091 scoped_ptr<spdy::SpdyFrame> syn_reply( 4101 scoped_ptr<spdy::SpdyFrame> syn_reply(
4092 ConstructSpdyGetSynReply(NULL, 0, 1)); 4102 ConstructSpdyGetSynReply(NULL, 0, 1));
4093 syn_reply->set_flags(spdy::CONTROL_FLAG_NONE); // turn off FIN bit 4103 syn_reply->set_flags(spdy::CONTROL_FLAG_NONE); // turn off FIN bit
4094 scoped_ptr<spdy::SpdyFrame> data_frame( 4104 scoped_ptr<spdy::SpdyFrame> data_frame(
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
4166 4176
4167 // Verify that we consumed all test data. 4177 // Verify that we consumed all test data.
4168 helper.VerifyDataConsumed(); 4178 helper.VerifyDataConsumed();
4169 4179
4170 EXPECT_EQ(OK, out.rv); 4180 EXPECT_EQ(OK, out.rv);
4171 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); 4181 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line);
4172 EXPECT_EQ("messagemessagemessagemessage", out.response_data); 4182 EXPECT_EQ("messagemessagemessagemessage", out.response_data);
4173 } 4183 }
4174 4184
4175 // Verify the case where we buffer data and close the connection. 4185 // Verify the case where we buffer data and close the connection.
4176 TEST_P(SpdyNetworkTransactionTest, BufferedClosed) { 4186 TEST_P(SpdyNetworkTransactionSpdy21Test, BufferedClosed) {
4177 spdy::SpdyFramer framer; 4187 spdy::SpdyFramer framer;
4178 4188
4179 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 4189 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
4180 MockWrite writes[] = { CreateMockWrite(*req) }; 4190 MockWrite writes[] = { CreateMockWrite(*req) };
4181 4191
4182 // All data frames in a single read. 4192 // All data frames in a single read.
4183 // NOTE: We don't FIN the stream. 4193 // NOTE: We don't FIN the stream.
4184 scoped_ptr<spdy::SpdyFrame> data_frame( 4194 scoped_ptr<spdy::SpdyFrame> data_frame(
4185 framer.CreateDataFrame(1, "message", 7, spdy::DATA_FLAG_NONE)); 4195 framer.CreateDataFrame(1, "message", 7, spdy::DATA_FLAG_NONE));
4186 const spdy::SpdyFrame* data_frames[4] = { 4196 const spdy::SpdyFrame* data_frames[4] = {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
4257 4267
4258 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the 4268 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the
4259 // MockClientSocketFactory) are still alive. 4269 // MockClientSocketFactory) are still alive.
4260 MessageLoop::current()->RunAllPending(); 4270 MessageLoop::current()->RunAllPending();
4261 4271
4262 // Verify that we consumed all test data. 4272 // Verify that we consumed all test data.
4263 helper.VerifyDataConsumed(); 4273 helper.VerifyDataConsumed();
4264 } 4274 }
4265 4275
4266 // Verify the case where we buffer data and cancel the transaction. 4276 // Verify the case where we buffer data and cancel the transaction.
4267 TEST_P(SpdyNetworkTransactionTest, BufferedCancelled) { 4277 TEST_P(SpdyNetworkTransactionSpdy21Test, BufferedCancelled) {
4268 spdy::SpdyFramer framer; 4278 spdy::SpdyFramer framer;
4269 4279
4270 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 4280 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
4271 MockWrite writes[] = { CreateMockWrite(*req) }; 4281 MockWrite writes[] = { CreateMockWrite(*req) };
4272 4282
4273 // NOTE: We don't FIN the stream. 4283 // NOTE: We don't FIN the stream.
4274 scoped_ptr<spdy::SpdyFrame> data_frame( 4284 scoped_ptr<spdy::SpdyFrame> data_frame(
4275 framer.CreateDataFrame(1, "message", 7, spdy::DATA_FLAG_NONE)); 4285 framer.CreateDataFrame(1, "message", 7, spdy::DATA_FLAG_NONE));
4276 4286
4277 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); 4287 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1));
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
4329 // Flush the MessageLoop; this will cause the buffered IO task 4339 // Flush the MessageLoop; this will cause the buffered IO task
4330 // to run for the final time. 4340 // to run for the final time.
4331 MessageLoop::current()->RunAllPending(); 4341 MessageLoop::current()->RunAllPending();
4332 4342
4333 // Verify that we consumed all test data. 4343 // Verify that we consumed all test data.
4334 helper.VerifyDataConsumed(); 4344 helper.VerifyDataConsumed();
4335 } 4345 }
4336 4346
4337 // Test that if the server requests persistence of settings, that we save 4347 // Test that if the server requests persistence of settings, that we save
4338 // the settings in the SpdySettingsStorage. 4348 // the settings in the SpdySettingsStorage.
4339 TEST_P(SpdyNetworkTransactionTest, SettingsSaved) { 4349 TEST_P(SpdyNetworkTransactionSpdy21Test, SettingsSaved) {
4340 static const SpdyHeaderInfo kSynReplyInfo = { 4350 static const SpdyHeaderInfo kSynReplyInfo = {
4341 spdy::SYN_REPLY, // Syn Reply 4351 spdy::SYN_REPLY, // Syn Reply
4342 1, // Stream ID 4352 1, // Stream ID
4343 0, // Associated Stream ID 4353 0, // Associated Stream ID
4344 net::ConvertRequestPriorityToSpdyPriority(LOWEST), 4354 net::ConvertRequestPriorityToSpdyPriority(LOWEST),
4345 // Priority 4355 // Priority
4346 spdy::CONTROL_FLAG_NONE, // Control Flags 4356 spdy::CONTROL_FLAG_NONE, // Control Flags
4347 false, // Compressed 4357 false, // Compressed
4348 spdy::INVALID, // Status 4358 spdy::INVALID, // Status
4349 NULL, // Data 4359 NULL, // Data
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
4440 setting = saved_settings.front(); 4450 setting = saved_settings.front();
4441 saved_settings.pop_front(); 4451 saved_settings.pop_front();
4442 EXPECT_EQ(spdy::SETTINGS_FLAG_PERSISTED, setting.first.flags()); 4452 EXPECT_EQ(spdy::SETTINGS_FLAG_PERSISTED, setting.first.flags());
4443 EXPECT_EQ(kSampleId3, setting.first.id()); 4453 EXPECT_EQ(kSampleId3, setting.first.id());
4444 EXPECT_EQ(kSampleValue3, setting.second); 4454 EXPECT_EQ(kSampleValue3, setting.second);
4445 } 4455 }
4446 } 4456 }
4447 4457
4448 // Test that when there are settings saved that they are sent back to the 4458 // Test that when there are settings saved that they are sent back to the
4449 // server upon session establishment. 4459 // server upon session establishment.
4450 TEST_P(SpdyNetworkTransactionTest, SettingsPlayback) { 4460 TEST_P(SpdyNetworkTransactionSpdy21Test, SettingsPlayback) {
4451 static const SpdyHeaderInfo kSynReplyInfo = { 4461 static const SpdyHeaderInfo kSynReplyInfo = {
4452 spdy::SYN_REPLY, // Syn Reply 4462 spdy::SYN_REPLY, // Syn Reply
4453 1, // Stream ID 4463 1, // Stream ID
4454 0, // Associated Stream ID 4464 0, // Associated Stream ID
4455 net::ConvertRequestPriorityToSpdyPriority(LOWEST), 4465 net::ConvertRequestPriorityToSpdyPriority(LOWEST),
4456 // Priority 4466 // Priority
4457 spdy::CONTROL_FLAG_NONE, // Control Flags 4467 spdy::CONTROL_FLAG_NONE, // Control Flags
4458 false, // Compressed 4468 false, // Compressed
4459 spdy::INVALID, // Status 4469 spdy::INVALID, // Status
4460 NULL, // Data 4470 NULL, // Data
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
4556 4566
4557 // Verify the second persisted setting. 4567 // Verify the second persisted setting.
4558 setting = saved_settings.front(); 4568 setting = saved_settings.front();
4559 saved_settings.pop_front(); 4569 saved_settings.pop_front();
4560 EXPECT_EQ(spdy::SETTINGS_FLAG_PERSISTED, setting.first.flags()); 4570 EXPECT_EQ(spdy::SETTINGS_FLAG_PERSISTED, setting.first.flags());
4561 EXPECT_EQ(kSampleId2, setting.first.id()); 4571 EXPECT_EQ(kSampleId2, setting.first.id());
4562 EXPECT_EQ(kSampleValue2, setting.second); 4572 EXPECT_EQ(kSampleValue2, setting.second);
4563 } 4573 }
4564 } 4574 }
4565 4575
4566 TEST_P(SpdyNetworkTransactionTest, GoAwayWithActiveStream) { 4576 TEST_P(SpdyNetworkTransactionSpdy21Test, GoAwayWithActiveStream) {
4567 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 4577 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
4568 MockWrite writes[] = { CreateMockWrite(*req) }; 4578 MockWrite writes[] = { CreateMockWrite(*req) };
4569 4579
4570 scoped_ptr<spdy::SpdyFrame> go_away(ConstructSpdyGoAway()); 4580 scoped_ptr<spdy::SpdyFrame> go_away(ConstructSpdyGoAway());
4571 MockRead reads[] = { 4581 MockRead reads[] = {
4572 CreateMockRead(*go_away), 4582 CreateMockRead(*go_away),
4573 MockRead(ASYNC, 0, 0), // EOF 4583 MockRead(ASYNC, 0, 0), // EOF
4574 }; 4584 };
4575 4585
4576 scoped_ptr<DelayedSocketData> data( 4586 scoped_ptr<DelayedSocketData> data(
4577 new DelayedSocketData(1, reads, arraysize(reads), 4587 new DelayedSocketData(1, reads, arraysize(reads),
4578 writes, arraysize(writes))); 4588 writes, arraysize(writes)));
4579 NormalSpdyTransactionHelper helper(CreateGetRequest(), 4589 NormalSpdyTransactionHelper helper(CreateGetRequest(),
4580 BoundNetLog(), GetParam()); 4590 BoundNetLog(), GetParam());
4581 helper.AddData(data.get()); 4591 helper.AddData(data.get());
4582 helper.RunToCompletion(data.get()); 4592 helper.RunToCompletion(data.get());
4583 TransactionHelperResult out = helper.output(); 4593 TransactionHelperResult out = helper.output();
4584 EXPECT_EQ(ERR_ABORTED, out.rv); 4594 EXPECT_EQ(ERR_ABORTED, out.rv);
4585 } 4595 }
4586 4596
4587 TEST_P(SpdyNetworkTransactionTest, CloseWithActiveStream) { 4597 TEST_P(SpdyNetworkTransactionSpdy21Test, CloseWithActiveStream) {
4588 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 4598 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
4589 MockWrite writes[] = { CreateMockWrite(*req) }; 4599 MockWrite writes[] = { CreateMockWrite(*req) };
4590 4600
4591 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); 4601 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1));
4592 MockRead reads[] = { 4602 MockRead reads[] = {
4593 CreateMockRead(*resp), 4603 CreateMockRead(*resp),
4594 MockRead(SYNCHRONOUS, 0, 0) // EOF 4604 MockRead(SYNCHRONOUS, 0, 0) // EOF
4595 }; 4605 };
4596 4606
4597 scoped_ptr<DelayedSocketData> data( 4607 scoped_ptr<DelayedSocketData> data(
(...skipping 18 matching lines...) Expand all
4616 EXPECT_TRUE(response->headers != NULL); 4626 EXPECT_TRUE(response->headers != NULL);
4617 EXPECT_TRUE(response->was_fetched_via_spdy); 4627 EXPECT_TRUE(response->was_fetched_via_spdy);
4618 out.rv = ReadTransaction(trans, &out.response_data); 4628 out.rv = ReadTransaction(trans, &out.response_data);
4619 EXPECT_EQ(ERR_CONNECTION_CLOSED, out.rv); 4629 EXPECT_EQ(ERR_CONNECTION_CLOSED, out.rv);
4620 4630
4621 // Verify that we consumed all test data. 4631 // Verify that we consumed all test data.
4622 helper.VerifyDataConsumed(); 4632 helper.VerifyDataConsumed();
4623 } 4633 }
4624 4634
4625 // Test to make sure we can correctly connect through a proxy. 4635 // Test to make sure we can correctly connect through a proxy.
4626 TEST_P(SpdyNetworkTransactionTest, ProxyConnect) { 4636 TEST_P(SpdyNetworkTransactionSpdy21Test, ProxyConnect) {
4627 NormalSpdyTransactionHelper helper(CreateGetRequest(), 4637 NormalSpdyTransactionHelper helper(CreateGetRequest(),
4628 BoundNetLog(), GetParam()); 4638 BoundNetLog(), GetParam());
4629 helper.session_deps().reset(new SpdySessionDependencies( 4639 helper.session_deps().reset(new SpdySessionDependencies(
4630 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70"))); 4640 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70")));
4631 helper.SetSession(make_scoped_refptr( 4641 helper.SetSession(make_scoped_refptr(
4632 SpdySessionDependencies::SpdyCreateSession(helper.session_deps().get()))); 4642 SpdySessionDependencies::SpdyCreateSession(helper.session_deps().get())));
4633 helper.RunPreTestSetup(); 4643 helper.RunPreTestSetup();
4634 HttpNetworkTransaction* trans = helper.trans(); 4644 HttpNetworkTransaction* trans = helper.trans();
4635 4645
4636 const char kConnect443[] = {"CONNECT www.google.com:443 HTTP/1.1\r\n" 4646 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
4717 4727
4718 std::string response_data; 4728 std::string response_data;
4719 ASSERT_EQ(OK, ReadTransaction(trans, &response_data)); 4729 ASSERT_EQ(OK, ReadTransaction(trans, &response_data));
4720 EXPECT_EQ("hello!", response_data); 4730 EXPECT_EQ("hello!", response_data);
4721 helper.VerifyDataConsumed(); 4731 helper.VerifyDataConsumed();
4722 } 4732 }
4723 4733
4724 // Test to make sure we can correctly connect through a proxy to www.google.com, 4734 // 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 4735 // if there already exists a direct spdy connection to www.google.com. See
4726 // http://crbug.com/49874 4736 // http://crbug.com/49874
4727 TEST_P(SpdyNetworkTransactionTest, DirectConnectProxyReconnect) { 4737 TEST_P(SpdyNetworkTransactionSpdy21Test, DirectConnectProxyReconnect) {
4728 // When setting up the first transaction, we store the SpdySessionPool so that 4738 // When setting up the first transaction, we store the SpdySessionPool so that
4729 // we can use the same pool in the second transaction. 4739 // we can use the same pool in the second transaction.
4730 NormalSpdyTransactionHelper helper(CreateGetRequest(), 4740 NormalSpdyTransactionHelper helper(CreateGetRequest(),
4731 BoundNetLog(), GetParam()); 4741 BoundNetLog(), GetParam());
4732 4742
4733 // Use a proxy service which returns a proxy fallback list from DIRECT to 4743 // 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 4744 // 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 4745 // to simply DIRECT. The reason for appending the second proxy is to verify
4736 // that the session pool key used does is just "DIRECT". 4746 // that the session pool key used does is just "DIRECT".
4737 helper.session_deps().reset(new SpdySessionDependencies( 4747 helper.session_deps().reset(new SpdySessionDependencies(
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
4895 EXPECT_EQ("hello!", response_data); 4905 EXPECT_EQ("hello!", response_data);
4896 4906
4897 data->CompleteRead(); 4907 data->CompleteRead();
4898 helper_proxy.VerifyDataConsumed(); 4908 helper_proxy.VerifyDataConsumed();
4899 } 4909 }
4900 4910
4901 // When we get a TCP-level RST, we need to retry a HttpNetworkTransaction 4911 // 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. 4912 // 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 4913 // This can happen when a server reboots without saying goodbye, or when
4904 // we're behind a NAT that masked the RST. 4914 // we're behind a NAT that masked the RST.
4905 TEST_P(SpdyNetworkTransactionTest, VerifyRetryOnConnectionReset) { 4915 TEST_P(SpdyNetworkTransactionSpdy21Test, VerifyRetryOnConnectionReset) {
4906 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); 4916 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1));
4907 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); 4917 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true));
4908 MockRead reads[] = { 4918 MockRead reads[] = {
4909 CreateMockRead(*resp), 4919 CreateMockRead(*resp),
4910 CreateMockRead(*body), 4920 CreateMockRead(*body),
4911 MockRead(ASYNC, ERR_IO_PENDING), 4921 MockRead(ASYNC, ERR_IO_PENDING),
4912 MockRead(ASYNC, ERR_CONNECTION_RESET), 4922 MockRead(ASYNC, ERR_CONNECTION_RESET),
4913 }; 4923 };
4914 4924
4915 MockRead reads2[] = { 4925 MockRead reads2[] = {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
4977 EXPECT_EQ(OK, rv); 4987 EXPECT_EQ(OK, rv);
4978 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 4988 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
4979 EXPECT_EQ("hello!", response_data); 4989 EXPECT_EQ("hello!", response_data);
4980 } 4990 }
4981 4991
4982 helper.VerifyDataConsumed(); 4992 helper.VerifyDataConsumed();
4983 } 4993 }
4984 } 4994 }
4985 4995
4986 // Test that turning SPDY on and off works properly. 4996 // Test that turning SPDY on and off works properly.
4987 TEST_P(SpdyNetworkTransactionTest, SpdyOnOffToggle) { 4997 TEST_P(SpdyNetworkTransactionSpdy21Test, SpdyOnOffToggle) {
4988 net::HttpStreamFactory::set_spdy_enabled(true); 4998 net::HttpStreamFactory::set_spdy_enabled(true);
4989 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 4999 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
4990 MockWrite spdy_writes[] = { CreateMockWrite(*req) }; 5000 MockWrite spdy_writes[] = { CreateMockWrite(*req) };
4991 5001
4992 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); 5002 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1));
4993 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); 5003 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true));
4994 MockRead spdy_reads[] = { 5004 MockRead spdy_reads[] = {
4995 CreateMockRead(*resp), 5005 CreateMockRead(*resp),
4996 CreateMockRead(*body), 5006 CreateMockRead(*body),
4997 MockRead(ASYNC, 0, 0) // EOF 5007 MockRead(ASYNC, 0, 0) // EOF
(...skipping 26 matching lines...) Expand all
5024 helper2.RunToCompletion(data2.get()); 5034 helper2.RunToCompletion(data2.get());
5025 TransactionHelperResult out2 = helper2.output(); 5035 TransactionHelperResult out2 = helper2.output();
5026 EXPECT_EQ(OK, out2.rv); 5036 EXPECT_EQ(OK, out2.rv);
5027 EXPECT_EQ("HTTP/1.1 200 OK", out2.status_line); 5037 EXPECT_EQ("HTTP/1.1 200 OK", out2.status_line);
5028 EXPECT_EQ("hello from http", out2.response_data); 5038 EXPECT_EQ("hello from http", out2.response_data);
5029 5039
5030 net::HttpStreamFactory::set_spdy_enabled(true); 5040 net::HttpStreamFactory::set_spdy_enabled(true);
5031 } 5041 }
5032 5042
5033 // Tests that Basic authentication works over SPDY 5043 // Tests that Basic authentication works over SPDY
5034 TEST_P(SpdyNetworkTransactionTest, SpdyBasicAuth) { 5044 TEST_P(SpdyNetworkTransactionSpdy21Test, SpdyBasicAuth) {
5035 net::HttpStreamFactory::set_spdy_enabled(true); 5045 net::HttpStreamFactory::set_spdy_enabled(true);
5036 5046
5037 // The first request will be a bare GET, the second request will be a 5047 // The first request will be a bare GET, the second request will be a
5038 // GET with an Authorization header. 5048 // GET with an Authorization header.
5039 scoped_ptr<spdy::SpdyFrame> req_get( 5049 scoped_ptr<spdy::SpdyFrame> req_get(
5040 ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 5050 ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
5041 const char* const kExtraAuthorizationHeaders[] = { 5051 const char* const kExtraAuthorizationHeaders[] = {
5042 "authorization", 5052 "authorization",
5043 "Basic Zm9vOmJhcg==", 5053 "Basic Zm9vOmJhcg==",
5044 }; 5054 };
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
5115 EXPECT_EQ(OK, rv_restart_complete); 5125 EXPECT_EQ(OK, rv_restart_complete);
5116 // TODO(cbentzel): This is actually the same response object as before, but 5126 // TODO(cbentzel): This is actually the same response object as before, but
5117 // data has changed. 5127 // data has changed.
5118 const HttpResponseInfo* const response_restart = trans->GetResponseInfo(); 5128 const HttpResponseInfo* const response_restart = trans->GetResponseInfo();
5119 ASSERT_TRUE(response_restart != NULL); 5129 ASSERT_TRUE(response_restart != NULL);
5120 ASSERT_TRUE(response_restart->headers != NULL); 5130 ASSERT_TRUE(response_restart->headers != NULL);
5121 EXPECT_EQ(200, response_restart->headers->response_code()); 5131 EXPECT_EQ(200, response_restart->headers->response_code());
5122 EXPECT_TRUE(response_restart->auth_challenge.get() == NULL); 5132 EXPECT_TRUE(response_restart->auth_challenge.get() == NULL);
5123 } 5133 }
5124 5134
5125 TEST_P(SpdyNetworkTransactionTest, ServerPushWithHeaders) { 5135 TEST_P(SpdyNetworkTransactionSpdy21Test, ServerPushWithHeaders) {
5126 static const unsigned char kPushBodyFrame[] = { 5136 static const unsigned char kPushBodyFrame[] = {
5127 0x00, 0x00, 0x00, 0x02, // header, ID 5137 0x00, 0x00, 0x00, 0x02, // header, ID
5128 0x01, 0x00, 0x00, 0x06, // FIN, length 5138 0x01, 0x00, 0x00, 0x06, // FIN, length
5129 'p', 'u', 's', 'h', 'e', 'd' // "pushed" 5139 'p', 'u', 's', 'h', 'e', 'd' // "pushed"
5130 }; 5140 };
5131 scoped_ptr<spdy::SpdyFrame> 5141 scoped_ptr<spdy::SpdyFrame>
5132 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 5142 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
5133 scoped_ptr<spdy::SpdyFrame> 5143 scoped_ptr<spdy::SpdyFrame>
5134 stream1_body(ConstructSpdyBodyFrame(1, true)); 5144 stream1_body(ConstructSpdyBodyFrame(1, true));
5135 MockWrite writes[] = { 5145 MockWrite writes[] = {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
5198 5208
5199 // Verify the SYN_REPLY. 5209 // Verify the SYN_REPLY.
5200 EXPECT_TRUE(response.headers != NULL); 5210 EXPECT_TRUE(response.headers != NULL);
5201 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 5211 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
5202 5212
5203 // Verify the pushed stream. 5213 // Verify the pushed stream.
5204 EXPECT_TRUE(response2.headers != NULL); 5214 EXPECT_TRUE(response2.headers != NULL);
5205 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); 5215 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine());
5206 } 5216 }
5207 5217
5208 TEST_P(SpdyNetworkTransactionTest, ServerPushClaimBeforeHeaders) { 5218 TEST_P(SpdyNetworkTransactionSpdy21Test, ServerPushClaimBeforeHeaders) {
5209 // We push a stream and attempt to claim it before the headers come down. 5219 // We push a stream and attempt to claim it before the headers come down.
5210 static const unsigned char kPushBodyFrame[] = { 5220 static const unsigned char kPushBodyFrame[] = {
5211 0x00, 0x00, 0x00, 0x02, // header, ID 5221 0x00, 0x00, 0x00, 0x02, // header, ID
5212 0x01, 0x00, 0x00, 0x06, // FIN, length 5222 0x01, 0x00, 0x00, 0x06, // FIN, length
5213 'p', 'u', 's', 'h', 'e', 'd' // "pushed" 5223 'p', 'u', 's', 'h', 'e', 'd' // "pushed"
5214 }; 5224 };
5215 scoped_ptr<spdy::SpdyFrame> 5225 scoped_ptr<spdy::SpdyFrame>
5216 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 5226 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
5217 scoped_ptr<spdy::SpdyFrame> 5227 scoped_ptr<spdy::SpdyFrame>
5218 stream1_body(ConstructSpdyBodyFrame(1, true)); 5228 stream1_body(ConstructSpdyBodyFrame(1, true));
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
5335 5345
5336 // Verify the SYN_REPLY. 5346 // Verify the SYN_REPLY.
5337 EXPECT_TRUE(response.headers != NULL); 5347 EXPECT_TRUE(response.headers != NULL);
5338 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 5348 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
5339 5349
5340 // Verify the pushed stream. 5350 // Verify the pushed stream.
5341 EXPECT_TRUE(response2.headers != NULL); 5351 EXPECT_TRUE(response2.headers != NULL);
5342 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); 5352 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine());
5343 } 5353 }
5344 5354
5345 TEST_P(SpdyNetworkTransactionTest, ServerPushWithTwoHeaderFrames) { 5355 TEST_P(SpdyNetworkTransactionSpdy21Test, ServerPushWithTwoHeaderFrames) {
5346 // We push a stream and attempt to claim it before the headers come down. 5356 // We push a stream and attempt to claim it before the headers come down.
5347 static const unsigned char kPushBodyFrame[] = { 5357 static const unsigned char kPushBodyFrame[] = {
5348 0x00, 0x00, 0x00, 0x02, // header, ID 5358 0x00, 0x00, 0x00, 0x02, // header, ID
5349 0x01, 0x00, 0x00, 0x06, // FIN, length 5359 0x01, 0x00, 0x00, 0x06, // FIN, length
5350 'p', 'u', 's', 'h', 'e', 'd' // "pushed" 5360 'p', 'u', 's', 'h', 'e', 'd' // "pushed"
5351 }; 5361 };
5352 scoped_ptr<spdy::SpdyFrame> 5362 scoped_ptr<spdy::SpdyFrame>
5353 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 5363 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
5354 scoped_ptr<spdy::SpdyFrame> 5364 scoped_ptr<spdy::SpdyFrame>
5355 stream1_body(ConstructSpdyBodyFrame(1, true)); 5365 stream1_body(ConstructSpdyBodyFrame(1, true));
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
5494 5504
5495 // Verify we got all the headers 5505 // Verify we got all the headers
5496 EXPECT_TRUE(response2.headers->HasHeaderValue( 5506 EXPECT_TRUE(response2.headers->HasHeaderValue(
5497 "url", 5507 "url",
5498 "http://www.google.com/foo.dat")); 5508 "http://www.google.com/foo.dat"));
5499 EXPECT_TRUE(response2.headers->HasHeaderValue("hello", "bye")); 5509 EXPECT_TRUE(response2.headers->HasHeaderValue("hello", "bye"));
5500 EXPECT_TRUE(response2.headers->HasHeaderValue("status", "200")); 5510 EXPECT_TRUE(response2.headers->HasHeaderValue("status", "200"));
5501 EXPECT_TRUE(response2.headers->HasHeaderValue("version", "HTTP/1.1")); 5511 EXPECT_TRUE(response2.headers->HasHeaderValue("version", "HTTP/1.1"));
5502 } 5512 }
5503 5513
5504 TEST_P(SpdyNetworkTransactionTest, SynReplyWithHeaders) { 5514 TEST_P(SpdyNetworkTransactionSpdy21Test, SynReplyWithHeaders) {
5505 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 5515 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
5506 MockWrite writes[] = { CreateMockWrite(*req) }; 5516 MockWrite writes[] = { CreateMockWrite(*req) };
5507 5517
5508 static const char* const kInitialHeaders[] = { 5518 static const char* const kInitialHeaders[] = {
5509 "status", 5519 "status",
5510 "200 OK", 5520 "200 OK",
5511 "version", 5521 "version",
5512 "HTTP/1.1" 5522 "HTTP/1.1"
5513 }; 5523 };
5514 static const char* const kLateHeaders[] = { 5524 static const char* const kLateHeaders[] = {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
5550 writes, arraysize(writes))); 5560 writes, arraysize(writes)));
5551 NormalSpdyTransactionHelper helper(CreateGetRequest(), 5561 NormalSpdyTransactionHelper helper(CreateGetRequest(),
5552 BoundNetLog(), GetParam()); 5562 BoundNetLog(), GetParam());
5553 helper.RunToCompletion(data.get()); 5563 helper.RunToCompletion(data.get());
5554 TransactionHelperResult out = helper.output(); 5564 TransactionHelperResult out = helper.output();
5555 EXPECT_EQ(OK, out.rv); 5565 EXPECT_EQ(OK, out.rv);
5556 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); 5566 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line);
5557 EXPECT_EQ("hello!", out.response_data); 5567 EXPECT_EQ("hello!", out.response_data);
5558 } 5568 }
5559 5569
5560 TEST_P(SpdyNetworkTransactionTest, SynReplyWithLateHeaders) { 5570 TEST_P(SpdyNetworkTransactionSpdy21Test, SynReplyWithLateHeaders) {
5561 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 5571 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
5562 MockWrite writes[] = { CreateMockWrite(*req) }; 5572 MockWrite writes[] = { CreateMockWrite(*req) };
5563 5573
5564 static const char* const kInitialHeaders[] = { 5574 static const char* const kInitialHeaders[] = {
5565 "status", 5575 "status",
5566 "200 OK", 5576 "200 OK",
5567 "version", 5577 "version",
5568 "HTTP/1.1" 5578 "HTTP/1.1"
5569 }; 5579 };
5570 static const char* const kLateHeaders[] = { 5580 static const char* const kLateHeaders[] = {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
5608 writes, arraysize(writes))); 5618 writes, arraysize(writes)));
5609 NormalSpdyTransactionHelper helper(CreateGetRequest(), 5619 NormalSpdyTransactionHelper helper(CreateGetRequest(),
5610 BoundNetLog(), GetParam()); 5620 BoundNetLog(), GetParam());
5611 helper.RunToCompletion(data.get()); 5621 helper.RunToCompletion(data.get());
5612 TransactionHelperResult out = helper.output(); 5622 TransactionHelperResult out = helper.output();
5613 EXPECT_EQ(OK, out.rv); 5623 EXPECT_EQ(OK, out.rv);
5614 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); 5624 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line);
5615 EXPECT_EQ("hello!hello!", out.response_data); 5625 EXPECT_EQ("hello!hello!", out.response_data);
5616 } 5626 }
5617 5627
5618 TEST_P(SpdyNetworkTransactionTest, SynReplyWithDuplicateLateHeaders) { 5628 TEST_P(SpdyNetworkTransactionSpdy21Test, SynReplyWithDuplicateLateHeaders) {
5619 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 5629 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
5620 MockWrite writes[] = { CreateMockWrite(*req) }; 5630 MockWrite writes[] = { CreateMockWrite(*req) };
5621 5631
5622 static const char* const kInitialHeaders[] = { 5632 static const char* const kInitialHeaders[] = {
5623 "status", 5633 "status",
5624 "200 OK", 5634 "200 OK",
5625 "version", 5635 "version",
5626 "HTTP/1.1" 5636 "HTTP/1.1"
5627 }; 5637 };
5628 static const char* const kLateHeaders[] = { 5638 static const char* const kLateHeaders[] = {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
5664 scoped_ptr<DelayedSocketData> data( 5674 scoped_ptr<DelayedSocketData> data(
5665 new DelayedSocketData(1, reads, arraysize(reads), 5675 new DelayedSocketData(1, reads, arraysize(reads),
5666 writes, arraysize(writes))); 5676 writes, arraysize(writes)));
5667 NormalSpdyTransactionHelper helper(CreateGetRequest(), 5677 NormalSpdyTransactionHelper helper(CreateGetRequest(),
5668 BoundNetLog(), GetParam()); 5678 BoundNetLog(), GetParam());
5669 helper.RunToCompletion(data.get()); 5679 helper.RunToCompletion(data.get());
5670 TransactionHelperResult out = helper.output(); 5680 TransactionHelperResult out = helper.output();
5671 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); 5681 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv);
5672 } 5682 }
5673 5683
5674 TEST_P(SpdyNetworkTransactionTest, ServerPushCrossOriginCorrectness) { 5684 TEST_P(SpdyNetworkTransactionSpdy21Test, ServerPushCrossOriginCorrectness) {
5675 // In this test we want to verify that we can't accidentally push content 5685 // In this test we want to verify that we can't accidentally push content
5676 // which can't be pushed by this content server. 5686 // which can't be pushed by this content server.
5677 // This test assumes that: 5687 // This test assumes that:
5678 // - if we're requesting http://www.foo.com/barbaz 5688 // - if we're requesting http://www.foo.com/barbaz
5679 // - the browser has made a connection to "www.foo.com". 5689 // - the browser has made a connection to "www.foo.com".
5680 5690
5681 // A list of the URL to fetch, followed by the URL being pushed. 5691 // A list of the URL to fetch, followed by the URL being pushed.
5682 static const char* const kTestCases[] = { 5692 static const char* const kTestCases[] = {
5683 "http://www.google.com/foo.html", 5693 "http://www.google.com/foo.html",
5684 "http://www.google.com:81/foo.js", // Bad port 5694 "http://www.google.com:81/foo.js", // Bad port
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
5776 response = *trans->GetResponseInfo(); 5786 response = *trans->GetResponseInfo();
5777 5787
5778 VerifyStreamsClosed(helper); 5788 VerifyStreamsClosed(helper);
5779 5789
5780 // Verify the SYN_REPLY. 5790 // Verify the SYN_REPLY.
5781 EXPECT_TRUE(response.headers != NULL); 5791 EXPECT_TRUE(response.headers != NULL);
5782 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 5792 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
5783 } 5793 }
5784 } 5794 }
5785 5795
5786 TEST_P(SpdyNetworkTransactionTest, RetryAfterRefused) { 5796 TEST_P(SpdyNetworkTransactionSpdy21Test, RetryAfterRefused) {
5787 // Construct the request. 5797 // Construct the request.
5788 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 5798 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
5789 scoped_ptr<spdy::SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST)); 5799 scoped_ptr<spdy::SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST));
5790 MockWrite writes[] = { 5800 MockWrite writes[] = {
5791 CreateMockWrite(*req, 1), 5801 CreateMockWrite(*req, 1),
5792 CreateMockWrite(*req2, 3), 5802 CreateMockWrite(*req2, 3),
5793 }; 5803 };
5794 5804
5795 scoped_ptr<spdy::SpdyFrame> refused( 5805 scoped_ptr<spdy::SpdyFrame> refused(
5796 ConstructSpdyRstStream(1, spdy::REFUSED_STREAM)); 5806 ConstructSpdyRstStream(1, spdy::REFUSED_STREAM));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
5832 << " Write index: " 5842 << " Write index: "
5833 << data->write_index(); 5843 << data->write_index();
5834 5844
5835 // Verify the SYN_REPLY. 5845 // Verify the SYN_REPLY.
5836 HttpResponseInfo response = *trans->GetResponseInfo(); 5846 HttpResponseInfo response = *trans->GetResponseInfo();
5837 EXPECT_TRUE(response.headers != NULL); 5847 EXPECT_TRUE(response.headers != NULL);
5838 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 5848 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
5839 } 5849 }
5840 5850
5841 } // namespace net 5851 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_http_stream_unittest.cc ('k') | net/spdy/spdy_network_transaction_spdy2_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698