OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/http/http_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
6 | 6 |
7 #include <math.h> // ceil | 7 #include <math.h> // ceil |
8 #include <stdarg.h> | 8 #include <stdarg.h> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "net/proxy/proxy_config_service_fixed.h" | 44 #include "net/proxy/proxy_config_service_fixed.h" |
45 #include "net/proxy/proxy_resolver.h" | 45 #include "net/proxy/proxy_resolver.h" |
46 #include "net/proxy/proxy_service.h" | 46 #include "net/proxy/proxy_service.h" |
47 #include "net/socket/client_socket_factory.h" | 47 #include "net/socket/client_socket_factory.h" |
48 #include "net/socket/mock_client_socket_pool_manager.h" | 48 #include "net/socket/mock_client_socket_pool_manager.h" |
49 #include "net/socket/socket_test_util.h" | 49 #include "net/socket/socket_test_util.h" |
50 #include "net/socket/ssl_client_socket.h" | 50 #include "net/socket/ssl_client_socket.h" |
51 #include "net/spdy/spdy_framer.h" | 51 #include "net/spdy/spdy_framer.h" |
52 #include "net/spdy/spdy_session.h" | 52 #include "net/spdy/spdy_session.h" |
53 #include "net/spdy/spdy_session_pool.h" | 53 #include "net/spdy/spdy_session_pool.h" |
54 #include "net/spdy/spdy_test_util.h" | 54 #include "net/spdy/spdy_test_util_spdy2.h" |
55 #include "testing/gtest/include/gtest/gtest.h" | 55 #include "testing/gtest/include/gtest/gtest.h" |
56 #include "testing/platform_test.h" | 56 #include "testing/platform_test.h" |
57 | 57 |
| 58 using namespace net::test_spdy2; |
| 59 |
58 //----------------------------------------------------------------------------- | 60 //----------------------------------------------------------------------------- |
59 | 61 |
60 namespace { | 62 namespace { |
61 | 63 |
62 const string16 kBar(ASCIIToUTF16("bar")); | 64 const string16 kBar(ASCIIToUTF16("bar")); |
63 const string16 kBar2(ASCIIToUTF16("bar2")); | 65 const string16 kBar2(ASCIIToUTF16("bar2")); |
64 const string16 kBar3(ASCIIToUTF16("bar3")); | 66 const string16 kBar3(ASCIIToUTF16("bar3")); |
65 const string16 kBaz(ASCIIToUTF16("baz")); | 67 const string16 kBaz(ASCIIToUTF16("baz")); |
66 const string16 kFirst(ASCIIToUTF16("first")); | 68 const string16 kFirst(ASCIIToUTF16("first")); |
67 const string16 kFoo(ASCIIToUTF16("foo")); | 69 const string16 kFoo(ASCIIToUTF16("foo")); |
(...skipping 20 matching lines...) Expand all Loading... |
88 ret.push_back(value); | 90 ret.push_back(value); |
89 } | 91 } |
90 va_end(args); | 92 va_end(args); |
91 | 93 |
92 return ret; | 94 return ret; |
93 } | 95 } |
94 | 96 |
95 // SpdyNextProtos returns a vector of NPN protocol strings for negotiating | 97 // SpdyNextProtos returns a vector of NPN protocol strings for negotiating |
96 // SPDY. | 98 // SPDY. |
97 std::vector<std::string> SpdyNextProtos() { | 99 std::vector<std::string> SpdyNextProtos() { |
98 return MakeNextProtos("http/1.1", "spdy/2", "spdy/2.1", NULL); | 100 return MakeNextProtos("http/1.1", "spdy/2", NULL); |
99 } | 101 } |
100 | 102 |
101 } // namespace | 103 } // namespace |
102 | 104 |
103 namespace net { | 105 namespace net { |
104 | 106 |
| 107 namespace { |
| 108 |
105 // Helper to manage the lifetimes of the dependencies for a | 109 // Helper to manage the lifetimes of the dependencies for a |
106 // HttpNetworkTransaction. | 110 // HttpNetworkTransaction. |
107 struct SessionDependencies { | 111 struct SessionDependencies { |
108 // Default set of dependencies -- "null" proxy service. | 112 // Default set of dependencies -- "null" proxy service. |
109 SessionDependencies() | 113 SessionDependencies() |
110 : host_resolver(new MockHostResolver), | 114 : host_resolver(new MockHostResolver), |
111 cert_verifier(new CertVerifier), | 115 cert_verifier(new CertVerifier), |
112 proxy_service(ProxyService::CreateDirect()), | 116 proxy_service(ProxyService::CreateDirect()), |
113 ssl_config_service(new SSLConfigServiceDefaults), | 117 ssl_config_service(new SSLConfigServiceDefaults), |
114 http_auth_handler_factory( | 118 http_auth_handler_factory( |
(...skipping 27 matching lines...) Expand all Loading... |
142 params.cert_verifier = session_deps->cert_verifier.get(); | 146 params.cert_verifier = session_deps->cert_verifier.get(); |
143 params.proxy_service = session_deps->proxy_service.get(); | 147 params.proxy_service = session_deps->proxy_service.get(); |
144 params.ssl_config_service = session_deps->ssl_config_service; | 148 params.ssl_config_service = session_deps->ssl_config_service; |
145 params.http_auth_handler_factory = | 149 params.http_auth_handler_factory = |
146 session_deps->http_auth_handler_factory.get(); | 150 session_deps->http_auth_handler_factory.get(); |
147 params.http_server_properties = &session_deps->http_server_properties; | 151 params.http_server_properties = &session_deps->http_server_properties; |
148 params.net_log = session_deps->net_log; | 152 params.net_log = session_deps->net_log; |
149 return new HttpNetworkSession(params); | 153 return new HttpNetworkSession(params); |
150 } | 154 } |
151 | 155 |
152 class HttpNetworkTransactionTest : public PlatformTest { | 156 } // namespace |
| 157 |
| 158 class HttpNetworkTransactionSpdy2Test : public PlatformTest { |
153 protected: | 159 protected: |
154 struct SimpleGetHelperResult { | 160 struct SimpleGetHelperResult { |
155 int rv; | 161 int rv; |
156 std::string status_line; | 162 std::string status_line; |
157 std::string response_data; | 163 std::string response_data; |
158 }; | 164 }; |
159 | 165 |
160 virtual void SetUp() { | 166 virtual void SetUp() { |
161 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); | 167 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); |
162 MessageLoop::current()->RunAllPending(); | 168 MessageLoop::current()->RunAllPending(); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 StaticSocketDataProvider* data[] = { &reads }; | 257 StaticSocketDataProvider* data[] = { &reads }; |
252 return SimpleGetHelperForData(data, 1); | 258 return SimpleGetHelperForData(data, 1); |
253 } | 259 } |
254 | 260 |
255 void ConnectStatusHelperWithExpectedStatus(const MockRead& status, | 261 void ConnectStatusHelperWithExpectedStatus(const MockRead& status, |
256 int expected_status); | 262 int expected_status); |
257 | 263 |
258 void ConnectStatusHelper(const MockRead& status); | 264 void ConnectStatusHelper(const MockRead& status); |
259 }; | 265 }; |
260 | 266 |
| 267 namespace { |
| 268 |
261 // Fill |str| with a long header list that consumes >= |size| bytes. | 269 // Fill |str| with a long header list that consumes >= |size| bytes. |
262 void FillLargeHeadersString(std::string* str, int size) { | 270 void FillLargeHeadersString(std::string* str, int size) { |
263 const char* row = | 271 const char* row = |
264 "SomeHeaderName: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\r\n"; | 272 "SomeHeaderName: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\r\n"; |
265 const int sizeof_row = strlen(row); | 273 const int sizeof_row = strlen(row); |
266 const int num_rows = static_cast<int>( | 274 const int num_rows = static_cast<int>( |
267 ceil(static_cast<float>(size) / sizeof_row)); | 275 ceil(static_cast<float>(size) / sizeof_row)); |
268 const int sizeof_data = num_rows * sizeof_row; | 276 const int sizeof_data = num_rows * sizeof_row; |
269 DCHECK(sizeof_data >= size); | 277 DCHECK(sizeof_data >= size); |
270 str->reserve(sizeof_data); | 278 str->reserve(sizeof_data); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 CaptureGroupNameSSLSocketPool::CaptureGroupNameSocketPool( | 378 CaptureGroupNameSSLSocketPool::CaptureGroupNameSocketPool( |
371 HostResolver* host_resolver, | 379 HostResolver* host_resolver, |
372 CertVerifier* cert_verifier) | 380 CertVerifier* cert_verifier) |
373 : SSLClientSocketPool(0, 0, NULL, host_resolver, cert_verifier, NULL, | 381 : SSLClientSocketPool(0, 0, NULL, host_resolver, cert_verifier, NULL, |
374 NULL, NULL, "", NULL, NULL, NULL, NULL, NULL, NULL) {} | 382 NULL, NULL, "", NULL, NULL, NULL, NULL, NULL, NULL) {} |
375 | 383 |
376 //----------------------------------------------------------------------------- | 384 //----------------------------------------------------------------------------- |
377 | 385 |
378 // This is the expected return from a current server advertising SPDY. | 386 // This is the expected return from a current server advertising SPDY. |
379 static const char kAlternateProtocolHttpHeader[] = | 387 static const char kAlternateProtocolHttpHeader[] = |
380 "Alternate-Protocol: 443:npn-spdy/2.1\r\n\r\n"; | 388 "Alternate-Protocol: 443:npn-spdy/2\r\n\r\n"; |
381 | 389 |
382 // Helper functions for validating that AuthChallengeInfo's are correctly | 390 // Helper functions for validating that AuthChallengeInfo's are correctly |
383 // configured for common cases. | 391 // configured for common cases. |
384 bool CheckBasicServerAuth(const AuthChallengeInfo* auth_challenge) { | 392 bool CheckBasicServerAuth(const AuthChallengeInfo* auth_challenge) { |
385 if (!auth_challenge) | 393 if (!auth_challenge) |
386 return false; | 394 return false; |
387 EXPECT_FALSE(auth_challenge->is_proxy); | 395 EXPECT_FALSE(auth_challenge->is_proxy); |
388 EXPECT_EQ("www.google.com:80", auth_challenge->challenger.ToString()); | 396 EXPECT_EQ("www.google.com:80", auth_challenge->challenger.ToString()); |
389 EXPECT_EQ("MyRealm1", auth_challenge->realm); | 397 EXPECT_EQ("MyRealm1", auth_challenge->realm); |
390 EXPECT_EQ("basic", auth_challenge->scheme); | 398 EXPECT_EQ("basic", auth_challenge->scheme); |
(...skipping 23 matching lines...) Expand all Loading... |
414 bool CheckNTLMServerAuth(const AuthChallengeInfo* auth_challenge) { | 422 bool CheckNTLMServerAuth(const AuthChallengeInfo* auth_challenge) { |
415 if (!auth_challenge) | 423 if (!auth_challenge) |
416 return false; | 424 return false; |
417 EXPECT_FALSE(auth_challenge->is_proxy); | 425 EXPECT_FALSE(auth_challenge->is_proxy); |
418 EXPECT_EQ("172.22.68.17:80", auth_challenge->challenger.ToString()); | 426 EXPECT_EQ("172.22.68.17:80", auth_challenge->challenger.ToString()); |
419 EXPECT_EQ(std::string(), auth_challenge->realm); | 427 EXPECT_EQ(std::string(), auth_challenge->realm); |
420 EXPECT_EQ("ntlm", auth_challenge->scheme); | 428 EXPECT_EQ("ntlm", auth_challenge->scheme); |
421 return true; | 429 return true; |
422 } | 430 } |
423 | 431 |
424 TEST_F(HttpNetworkTransactionTest, Basic) { | 432 } // namespace |
| 433 |
| 434 TEST_F(HttpNetworkTransactionSpdy2Test, Basic) { |
425 SessionDependencies session_deps; | 435 SessionDependencies session_deps; |
426 scoped_ptr<HttpTransaction> trans( | 436 scoped_ptr<HttpTransaction> trans( |
427 new HttpNetworkTransaction(CreateSession(&session_deps))); | 437 new HttpNetworkTransaction(CreateSession(&session_deps))); |
428 } | 438 } |
429 | 439 |
430 TEST_F(HttpNetworkTransactionTest, SimpleGET) { | 440 TEST_F(HttpNetworkTransactionSpdy2Test, SimpleGET) { |
431 MockRead data_reads[] = { | 441 MockRead data_reads[] = { |
432 MockRead("HTTP/1.0 200 OK\r\n\r\n"), | 442 MockRead("HTTP/1.0 200 OK\r\n\r\n"), |
433 MockRead("hello world"), | 443 MockRead("hello world"), |
434 MockRead(SYNCHRONOUS, OK), | 444 MockRead(SYNCHRONOUS, OK), |
435 }; | 445 }; |
436 SimpleGetHelperResult out = SimpleGetHelper(data_reads, | 446 SimpleGetHelperResult out = SimpleGetHelper(data_reads, |
437 arraysize(data_reads)); | 447 arraysize(data_reads)); |
438 EXPECT_EQ(OK, out.rv); | 448 EXPECT_EQ(OK, out.rv); |
439 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line); | 449 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line); |
440 EXPECT_EQ("hello world", out.response_data); | 450 EXPECT_EQ("hello world", out.response_data); |
441 } | 451 } |
442 | 452 |
443 // Response with no status line. | 453 // Response with no status line. |
444 TEST_F(HttpNetworkTransactionTest, SimpleGETNoHeaders) { | 454 TEST_F(HttpNetworkTransactionSpdy2Test, SimpleGETNoHeaders) { |
445 MockRead data_reads[] = { | 455 MockRead data_reads[] = { |
446 MockRead("hello world"), | 456 MockRead("hello world"), |
447 MockRead(SYNCHRONOUS, OK), | 457 MockRead(SYNCHRONOUS, OK), |
448 }; | 458 }; |
449 SimpleGetHelperResult out = SimpleGetHelper(data_reads, | 459 SimpleGetHelperResult out = SimpleGetHelper(data_reads, |
450 arraysize(data_reads)); | 460 arraysize(data_reads)); |
451 EXPECT_EQ(OK, out.rv); | 461 EXPECT_EQ(OK, out.rv); |
452 EXPECT_EQ("HTTP/0.9 200 OK", out.status_line); | 462 EXPECT_EQ("HTTP/0.9 200 OK", out.status_line); |
453 EXPECT_EQ("hello world", out.response_data); | 463 EXPECT_EQ("hello world", out.response_data); |
454 } | 464 } |
455 | 465 |
456 // Allow up to 4 bytes of junk to precede status line. | 466 // Allow up to 4 bytes of junk to precede status line. |
457 TEST_F(HttpNetworkTransactionTest, StatusLineJunk2Bytes) { | 467 TEST_F(HttpNetworkTransactionSpdy2Test, StatusLineJunk2Bytes) { |
458 MockRead data_reads[] = { | 468 MockRead data_reads[] = { |
459 MockRead("xxxHTTP/1.0 404 Not Found\nServer: blah\n\nDATA"), | 469 MockRead("xxxHTTP/1.0 404 Not Found\nServer: blah\n\nDATA"), |
460 MockRead(SYNCHRONOUS, OK), | 470 MockRead(SYNCHRONOUS, OK), |
461 }; | 471 }; |
462 SimpleGetHelperResult out = SimpleGetHelper(data_reads, | 472 SimpleGetHelperResult out = SimpleGetHelper(data_reads, |
463 arraysize(data_reads)); | 473 arraysize(data_reads)); |
464 EXPECT_EQ(OK, out.rv); | 474 EXPECT_EQ(OK, out.rv); |
465 EXPECT_EQ("HTTP/1.0 404 Not Found", out.status_line); | 475 EXPECT_EQ("HTTP/1.0 404 Not Found", out.status_line); |
466 EXPECT_EQ("DATA", out.response_data); | 476 EXPECT_EQ("DATA", out.response_data); |
467 } | 477 } |
468 | 478 |
469 // Allow up to 4 bytes of junk to precede status line. | 479 // Allow up to 4 bytes of junk to precede status line. |
470 TEST_F(HttpNetworkTransactionTest, StatusLineJunk4Bytes) { | 480 TEST_F(HttpNetworkTransactionSpdy2Test, StatusLineJunk4Bytes) { |
471 MockRead data_reads[] = { | 481 MockRead data_reads[] = { |
472 MockRead("\n\nQJHTTP/1.0 404 Not Found\nServer: blah\n\nDATA"), | 482 MockRead("\n\nQJHTTP/1.0 404 Not Found\nServer: blah\n\nDATA"), |
473 MockRead(SYNCHRONOUS, OK), | 483 MockRead(SYNCHRONOUS, OK), |
474 }; | 484 }; |
475 SimpleGetHelperResult out = SimpleGetHelper(data_reads, | 485 SimpleGetHelperResult out = SimpleGetHelper(data_reads, |
476 arraysize(data_reads)); | 486 arraysize(data_reads)); |
477 EXPECT_EQ(OK, out.rv); | 487 EXPECT_EQ(OK, out.rv); |
478 EXPECT_EQ("HTTP/1.0 404 Not Found", out.status_line); | 488 EXPECT_EQ("HTTP/1.0 404 Not Found", out.status_line); |
479 EXPECT_EQ("DATA", out.response_data); | 489 EXPECT_EQ("DATA", out.response_data); |
480 } | 490 } |
481 | 491 |
482 // Beyond 4 bytes of slop and it should fail to find a status line. | 492 // Beyond 4 bytes of slop and it should fail to find a status line. |
483 TEST_F(HttpNetworkTransactionTest, StatusLineJunk5Bytes) { | 493 TEST_F(HttpNetworkTransactionSpdy2Test, StatusLineJunk5Bytes) { |
484 MockRead data_reads[] = { | 494 MockRead data_reads[] = { |
485 MockRead("xxxxxHTTP/1.1 404 Not Found\nServer: blah"), | 495 MockRead("xxxxxHTTP/1.1 404 Not Found\nServer: blah"), |
486 MockRead(SYNCHRONOUS, OK), | 496 MockRead(SYNCHRONOUS, OK), |
487 }; | 497 }; |
488 SimpleGetHelperResult out = SimpleGetHelper(data_reads, | 498 SimpleGetHelperResult out = SimpleGetHelper(data_reads, |
489 arraysize(data_reads)); | 499 arraysize(data_reads)); |
490 EXPECT_EQ(OK, out.rv); | 500 EXPECT_EQ(OK, out.rv); |
491 EXPECT_EQ("HTTP/0.9 200 OK", out.status_line); | 501 EXPECT_EQ("HTTP/0.9 200 OK", out.status_line); |
492 EXPECT_EQ("xxxxxHTTP/1.1 404 Not Found\nServer: blah", out.response_data); | 502 EXPECT_EQ("xxxxxHTTP/1.1 404 Not Found\nServer: blah", out.response_data); |
493 } | 503 } |
494 | 504 |
495 // Same as StatusLineJunk4Bytes, except the read chunks are smaller. | 505 // Same as StatusLineJunk4Bytes, except the read chunks are smaller. |
496 TEST_F(HttpNetworkTransactionTest, StatusLineJunk4Bytes_Slow) { | 506 TEST_F(HttpNetworkTransactionSpdy2Test, StatusLineJunk4Bytes_Slow) { |
497 MockRead data_reads[] = { | 507 MockRead data_reads[] = { |
498 MockRead("\n"), | 508 MockRead("\n"), |
499 MockRead("\n"), | 509 MockRead("\n"), |
500 MockRead("Q"), | 510 MockRead("Q"), |
501 MockRead("J"), | 511 MockRead("J"), |
502 MockRead("HTTP/1.0 404 Not Found\nServer: blah\n\nDATA"), | 512 MockRead("HTTP/1.0 404 Not Found\nServer: blah\n\nDATA"), |
503 MockRead(SYNCHRONOUS, OK), | 513 MockRead(SYNCHRONOUS, OK), |
504 }; | 514 }; |
505 SimpleGetHelperResult out = SimpleGetHelper(data_reads, | 515 SimpleGetHelperResult out = SimpleGetHelper(data_reads, |
506 arraysize(data_reads)); | 516 arraysize(data_reads)); |
507 EXPECT_EQ(OK, out.rv); | 517 EXPECT_EQ(OK, out.rv); |
508 EXPECT_EQ("HTTP/1.0 404 Not Found", out.status_line); | 518 EXPECT_EQ("HTTP/1.0 404 Not Found", out.status_line); |
509 EXPECT_EQ("DATA", out.response_data); | 519 EXPECT_EQ("DATA", out.response_data); |
510 } | 520 } |
511 | 521 |
512 // Close the connection before enough bytes to have a status line. | 522 // Close the connection before enough bytes to have a status line. |
513 TEST_F(HttpNetworkTransactionTest, StatusLinePartial) { | 523 TEST_F(HttpNetworkTransactionSpdy2Test, StatusLinePartial) { |
514 MockRead data_reads[] = { | 524 MockRead data_reads[] = { |
515 MockRead("HTT"), | 525 MockRead("HTT"), |
516 MockRead(SYNCHRONOUS, OK), | 526 MockRead(SYNCHRONOUS, OK), |
517 }; | 527 }; |
518 SimpleGetHelperResult out = SimpleGetHelper(data_reads, | 528 SimpleGetHelperResult out = SimpleGetHelper(data_reads, |
519 arraysize(data_reads)); | 529 arraysize(data_reads)); |
520 EXPECT_EQ(OK, out.rv); | 530 EXPECT_EQ(OK, out.rv); |
521 EXPECT_EQ("HTTP/0.9 200 OK", out.status_line); | 531 EXPECT_EQ("HTTP/0.9 200 OK", out.status_line); |
522 EXPECT_EQ("HTT", out.response_data); | 532 EXPECT_EQ("HTT", out.response_data); |
523 } | 533 } |
524 | 534 |
525 // Simulate a 204 response, lacking a Content-Length header, sent over a | 535 // Simulate a 204 response, lacking a Content-Length header, sent over a |
526 // persistent connection. The response should still terminate since a 204 | 536 // persistent connection. The response should still terminate since a 204 |
527 // cannot have a response body. | 537 // cannot have a response body. |
528 TEST_F(HttpNetworkTransactionTest, StopsReading204) { | 538 TEST_F(HttpNetworkTransactionSpdy2Test, StopsReading204) { |
529 MockRead data_reads[] = { | 539 MockRead data_reads[] = { |
530 MockRead("HTTP/1.1 204 No Content\r\n\r\n"), | 540 MockRead("HTTP/1.1 204 No Content\r\n\r\n"), |
531 MockRead("junk"), // Should not be read!! | 541 MockRead("junk"), // Should not be read!! |
532 MockRead(SYNCHRONOUS, OK), | 542 MockRead(SYNCHRONOUS, OK), |
533 }; | 543 }; |
534 SimpleGetHelperResult out = SimpleGetHelper(data_reads, | 544 SimpleGetHelperResult out = SimpleGetHelper(data_reads, |
535 arraysize(data_reads)); | 545 arraysize(data_reads)); |
536 EXPECT_EQ(OK, out.rv); | 546 EXPECT_EQ(OK, out.rv); |
537 EXPECT_EQ("HTTP/1.1 204 No Content", out.status_line); | 547 EXPECT_EQ("HTTP/1.1 204 No Content", out.status_line); |
538 EXPECT_EQ("", out.response_data); | 548 EXPECT_EQ("", out.response_data); |
539 } | 549 } |
540 | 550 |
541 // A simple request using chunked encoding with some extra data after. | 551 // A simple request using chunked encoding with some extra data after. |
542 // (Like might be seen in a pipelined response.) | 552 // (Like might be seen in a pipelined response.) |
543 TEST_F(HttpNetworkTransactionTest, ChunkedEncoding) { | 553 TEST_F(HttpNetworkTransactionSpdy2Test, ChunkedEncoding) { |
544 MockRead data_reads[] = { | 554 MockRead data_reads[] = { |
545 MockRead("HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n"), | 555 MockRead("HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n"), |
546 MockRead("5\r\nHello\r\n"), | 556 MockRead("5\r\nHello\r\n"), |
547 MockRead("1\r\n"), | 557 MockRead("1\r\n"), |
548 MockRead(" \r\n"), | 558 MockRead(" \r\n"), |
549 MockRead("5\r\nworld\r\n"), | 559 MockRead("5\r\nworld\r\n"), |
550 MockRead("0\r\n\r\nHTTP/1.1 200 OK\r\n"), | 560 MockRead("0\r\n\r\nHTTP/1.1 200 OK\r\n"), |
551 MockRead(SYNCHRONOUS, OK), | 561 MockRead(SYNCHRONOUS, OK), |
552 }; | 562 }; |
553 SimpleGetHelperResult out = SimpleGetHelper(data_reads, | 563 SimpleGetHelperResult out = SimpleGetHelper(data_reads, |
554 arraysize(data_reads)); | 564 arraysize(data_reads)); |
555 EXPECT_EQ(OK, out.rv); | 565 EXPECT_EQ(OK, out.rv); |
556 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 566 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
557 EXPECT_EQ("Hello world", out.response_data); | 567 EXPECT_EQ("Hello world", out.response_data); |
558 } | 568 } |
559 | 569 |
560 // Next tests deal with http://crbug.com/56344. | 570 // Next tests deal with http://crbug.com/56344. |
561 | 571 |
562 TEST_F(HttpNetworkTransactionTest, | 572 TEST_F(HttpNetworkTransactionSpdy2Test, |
563 MultipleContentLengthHeadersNoTransferEncoding) { | 573 MultipleContentLengthHeadersNoTransferEncoding) { |
564 MockRead data_reads[] = { | 574 MockRead data_reads[] = { |
565 MockRead("HTTP/1.1 200 OK\r\n"), | 575 MockRead("HTTP/1.1 200 OK\r\n"), |
566 MockRead("Content-Length: 10\r\n"), | 576 MockRead("Content-Length: 10\r\n"), |
567 MockRead("Content-Length: 5\r\n\r\n"), | 577 MockRead("Content-Length: 5\r\n\r\n"), |
568 }; | 578 }; |
569 SimpleGetHelperResult out = SimpleGetHelper(data_reads, | 579 SimpleGetHelperResult out = SimpleGetHelper(data_reads, |
570 arraysize(data_reads)); | 580 arraysize(data_reads)); |
571 EXPECT_EQ(ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_LENGTH, out.rv); | 581 EXPECT_EQ(ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_LENGTH, out.rv); |
572 } | 582 } |
573 | 583 |
574 TEST_F(HttpNetworkTransactionTest, | 584 TEST_F(HttpNetworkTransactionSpdy2Test, |
575 DuplicateContentLengthHeadersNoTransferEncoding) { | 585 DuplicateContentLengthHeadersNoTransferEncoding) { |
576 MockRead data_reads[] = { | 586 MockRead data_reads[] = { |
577 MockRead("HTTP/1.1 200 OK\r\n"), | 587 MockRead("HTTP/1.1 200 OK\r\n"), |
578 MockRead("Content-Length: 5\r\n"), | 588 MockRead("Content-Length: 5\r\n"), |
579 MockRead("Content-Length: 5\r\n\r\n"), | 589 MockRead("Content-Length: 5\r\n\r\n"), |
580 MockRead("Hello"), | 590 MockRead("Hello"), |
581 }; | 591 }; |
582 SimpleGetHelperResult out = SimpleGetHelper(data_reads, | 592 SimpleGetHelperResult out = SimpleGetHelper(data_reads, |
583 arraysize(data_reads)); | 593 arraysize(data_reads)); |
584 EXPECT_EQ(OK, out.rv); | 594 EXPECT_EQ(OK, out.rv); |
585 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 595 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
586 EXPECT_EQ("Hello", out.response_data); | 596 EXPECT_EQ("Hello", out.response_data); |
587 } | 597 } |
588 | 598 |
589 TEST_F(HttpNetworkTransactionTest, | 599 TEST_F(HttpNetworkTransactionSpdy2Test, |
590 ComplexContentLengthHeadersNoTransferEncoding) { | 600 ComplexContentLengthHeadersNoTransferEncoding) { |
591 // More than 2 dupes. | 601 // More than 2 dupes. |
592 { | 602 { |
593 MockRead data_reads[] = { | 603 MockRead data_reads[] = { |
594 MockRead("HTTP/1.1 200 OK\r\n"), | 604 MockRead("HTTP/1.1 200 OK\r\n"), |
595 MockRead("Content-Length: 5\r\n"), | 605 MockRead("Content-Length: 5\r\n"), |
596 MockRead("Content-Length: 5\r\n"), | 606 MockRead("Content-Length: 5\r\n"), |
597 MockRead("Content-Length: 5\r\n\r\n"), | 607 MockRead("Content-Length: 5\r\n\r\n"), |
598 MockRead("Hello"), | 608 MockRead("Hello"), |
599 }; | 609 }; |
(...skipping 25 matching lines...) Expand all Loading... |
625 MockRead("Content-Length: 10\r\n"), | 635 MockRead("Content-Length: 10\r\n"), |
626 MockRead("Content-Length: 10\r\n"), | 636 MockRead("Content-Length: 10\r\n"), |
627 MockRead("Content-Length: 5\r\n\r\n"), | 637 MockRead("Content-Length: 5\r\n\r\n"), |
628 }; | 638 }; |
629 SimpleGetHelperResult out = SimpleGetHelper(data_reads, | 639 SimpleGetHelperResult out = SimpleGetHelper(data_reads, |
630 arraysize(data_reads)); | 640 arraysize(data_reads)); |
631 EXPECT_EQ(ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_LENGTH, out.rv); | 641 EXPECT_EQ(ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_LENGTH, out.rv); |
632 } | 642 } |
633 } | 643 } |
634 | 644 |
635 TEST_F(HttpNetworkTransactionTest, | 645 TEST_F(HttpNetworkTransactionSpdy2Test, |
636 MultipleContentLengthHeadersTransferEncoding) { | 646 MultipleContentLengthHeadersTransferEncoding) { |
637 MockRead data_reads[] = { | 647 MockRead data_reads[] = { |
638 MockRead("HTTP/1.1 200 OK\r\n"), | 648 MockRead("HTTP/1.1 200 OK\r\n"), |
639 MockRead("Content-Length: 666\r\n"), | 649 MockRead("Content-Length: 666\r\n"), |
640 MockRead("Content-Length: 1337\r\n"), | 650 MockRead("Content-Length: 1337\r\n"), |
641 MockRead("Transfer-Encoding: chunked\r\n\r\n"), | 651 MockRead("Transfer-Encoding: chunked\r\n\r\n"), |
642 MockRead("5\r\nHello\r\n"), | 652 MockRead("5\r\nHello\r\n"), |
643 MockRead("1\r\n"), | 653 MockRead("1\r\n"), |
644 MockRead(" \r\n"), | 654 MockRead(" \r\n"), |
645 MockRead("5\r\nworld\r\n"), | 655 MockRead("5\r\nworld\r\n"), |
646 MockRead("0\r\n\r\nHTTP/1.1 200 OK\r\n"), | 656 MockRead("0\r\n\r\nHTTP/1.1 200 OK\r\n"), |
647 MockRead(SYNCHRONOUS, OK), | 657 MockRead(SYNCHRONOUS, OK), |
648 }; | 658 }; |
649 SimpleGetHelperResult out = SimpleGetHelper(data_reads, | 659 SimpleGetHelperResult out = SimpleGetHelper(data_reads, |
650 arraysize(data_reads)); | 660 arraysize(data_reads)); |
651 EXPECT_EQ(OK, out.rv); | 661 EXPECT_EQ(OK, out.rv); |
652 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 662 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
653 EXPECT_EQ("Hello world", out.response_data); | 663 EXPECT_EQ("Hello world", out.response_data); |
654 } | 664 } |
655 | 665 |
656 // Next tests deal with http://crbug.com/98895. | 666 // Next tests deal with http://crbug.com/98895. |
657 | 667 |
658 // Checks that a single Content-Disposition header results in no error. | 668 // Checks that a single Content-Disposition header results in no error. |
659 TEST_F(HttpNetworkTransactionTest, SingleContentDispositionHeader) { | 669 TEST_F(HttpNetworkTransactionSpdy2Test, SingleContentDispositionHeader) { |
660 MockRead data_reads[] = { | 670 MockRead data_reads[] = { |
661 MockRead("HTTP/1.1 200 OK\r\n"), | 671 MockRead("HTTP/1.1 200 OK\r\n"), |
662 MockRead("Content-Disposition: attachment;filename=\"salutations.txt\"r\n"), | 672 MockRead("Content-Disposition: attachment;filename=\"salutations.txt\"r\n"), |
663 MockRead("Content-Length: 5\r\n\r\n"), | 673 MockRead("Content-Length: 5\r\n\r\n"), |
664 MockRead("Hello"), | 674 MockRead("Hello"), |
665 }; | 675 }; |
666 SimpleGetHelperResult out = SimpleGetHelper(data_reads, | 676 SimpleGetHelperResult out = SimpleGetHelper(data_reads, |
667 arraysize(data_reads)); | 677 arraysize(data_reads)); |
668 EXPECT_EQ(OK, out.rv); | 678 EXPECT_EQ(OK, out.rv); |
669 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 679 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
670 EXPECT_EQ("Hello", out.response_data); | 680 EXPECT_EQ("Hello", out.response_data); |
671 } | 681 } |
672 | 682 |
673 // Checks that two identical Content-Disposition headers result in an error. | 683 // Checks that two identical Content-Disposition headers result in an error. |
674 TEST_F(HttpNetworkTransactionTest, | 684 TEST_F(HttpNetworkTransactionSpdy2Test, |
675 DuplicateIdenticalContentDispositionHeaders) { | 685 DuplicateIdenticalContentDispositionHeaders) { |
676 MockRead data_reads[] = { | 686 MockRead data_reads[] = { |
677 MockRead("HTTP/1.1 200 OK\r\n"), | 687 MockRead("HTTP/1.1 200 OK\r\n"), |
678 MockRead("Content-Disposition: attachment;filename=\"greetings.txt\"r\n"), | 688 MockRead("Content-Disposition: attachment;filename=\"greetings.txt\"r\n"), |
679 MockRead("Content-Disposition: attachment;filename=\"greetings.txt\"r\n"), | 689 MockRead("Content-Disposition: attachment;filename=\"greetings.txt\"r\n"), |
680 MockRead("Content-Length: 5\r\n\r\n"), | 690 MockRead("Content-Length: 5\r\n\r\n"), |
681 MockRead("Hello"), | 691 MockRead("Hello"), |
682 }; | 692 }; |
683 SimpleGetHelperResult out = SimpleGetHelper(data_reads, | 693 SimpleGetHelperResult out = SimpleGetHelper(data_reads, |
684 arraysize(data_reads)); | 694 arraysize(data_reads)); |
685 EXPECT_EQ(ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION, out.rv); | 695 EXPECT_EQ(ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION, out.rv); |
686 } | 696 } |
687 | 697 |
688 // Checks that two distinct Content-Disposition headers result in an error. | 698 // Checks that two distinct Content-Disposition headers result in an error. |
689 TEST_F(HttpNetworkTransactionTest, DuplicateDistinctContentDispositionHeaders) { | 699 TEST_F(HttpNetworkTransactionSpdy2Test, |
| 700 DuplicateDistinctContentDispositionHeaders) { |
690 MockRead data_reads[] = { | 701 MockRead data_reads[] = { |
691 MockRead("HTTP/1.1 200 OK\r\n"), | 702 MockRead("HTTP/1.1 200 OK\r\n"), |
692 MockRead("Content-Disposition: attachment;filename=\"greetings.txt\"r\n"), | 703 MockRead("Content-Disposition: attachment;filename=\"greetings.txt\"r\n"), |
693 MockRead("Content-Disposition: attachment;filename=\"hi.txt\"r\n"), | 704 MockRead("Content-Disposition: attachment;filename=\"hi.txt\"r\n"), |
694 MockRead("Content-Length: 5\r\n\r\n"), | 705 MockRead("Content-Length: 5\r\n\r\n"), |
695 MockRead("Hello"), | 706 MockRead("Hello"), |
696 }; | 707 }; |
697 SimpleGetHelperResult out = SimpleGetHelper(data_reads, | 708 SimpleGetHelperResult out = SimpleGetHelper(data_reads, |
698 arraysize(data_reads)); | 709 arraysize(data_reads)); |
699 EXPECT_EQ(ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION, out.rv); | 710 EXPECT_EQ(ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION, out.rv); |
700 } | 711 } |
701 | 712 |
702 // Checks the behavior of a single Location header. | 713 // Checks the behavior of a single Location header. |
703 TEST_F(HttpNetworkTransactionTest, SingleLocationHeader) { | 714 TEST_F(HttpNetworkTransactionSpdy2Test, SingleLocationHeader) { |
704 MockRead data_reads[] = { | 715 MockRead data_reads[] = { |
705 MockRead("HTTP/1.1 302 Redirect\r\n"), | 716 MockRead("HTTP/1.1 302 Redirect\r\n"), |
706 MockRead("Location: http://good.com/\r\n"), | 717 MockRead("Location: http://good.com/\r\n"), |
707 MockRead("Content-Length: 0\r\n\r\n"), | 718 MockRead("Content-Length: 0\r\n\r\n"), |
708 MockRead(SYNCHRONOUS, OK), | 719 MockRead(SYNCHRONOUS, OK), |
709 }; | 720 }; |
710 | 721 |
711 HttpRequestInfo request; | 722 HttpRequestInfo request; |
712 request.method = "GET"; | 723 request.method = "GET"; |
713 request.url = GURL("http://redirect.com/"); | 724 request.url = GURL("http://redirect.com/"); |
(...skipping 15 matching lines...) Expand all Loading... |
729 | 740 |
730 const HttpResponseInfo* response = trans->GetResponseInfo(); | 741 const HttpResponseInfo* response = trans->GetResponseInfo(); |
731 ASSERT_TRUE(response != NULL && response->headers != NULL); | 742 ASSERT_TRUE(response != NULL && response->headers != NULL); |
732 EXPECT_EQ("HTTP/1.1 302 Redirect", response->headers->GetStatusLine()); | 743 EXPECT_EQ("HTTP/1.1 302 Redirect", response->headers->GetStatusLine()); |
733 std::string url; | 744 std::string url; |
734 EXPECT_TRUE(response->headers->IsRedirect(&url)); | 745 EXPECT_TRUE(response->headers->IsRedirect(&url)); |
735 EXPECT_EQ("http://good.com/", url); | 746 EXPECT_EQ("http://good.com/", url); |
736 } | 747 } |
737 | 748 |
738 // Checks that two identical Location headers result in an error. | 749 // Checks that two identical Location headers result in an error. |
739 TEST_F(HttpNetworkTransactionTest, DuplicateIdenticalLocationHeaders) { | 750 TEST_F(HttpNetworkTransactionSpdy2Test, DuplicateIdenticalLocationHeaders) { |
740 MockRead data_reads[] = { | 751 MockRead data_reads[] = { |
741 MockRead("HTTP/1.1 302 Redirect\r\n"), | 752 MockRead("HTTP/1.1 302 Redirect\r\n"), |
742 MockRead("Location: http://good.com/\r\n"), | 753 MockRead("Location: http://good.com/\r\n"), |
743 MockRead("Location: http://good.com/\r\n"), | 754 MockRead("Location: http://good.com/\r\n"), |
744 MockRead("Content-Length: 0\r\n\r\n"), | 755 MockRead("Content-Length: 0\r\n\r\n"), |
745 MockRead(SYNCHRONOUS, OK), | 756 MockRead(SYNCHRONOUS, OK), |
746 }; | 757 }; |
747 SimpleGetHelperResult out = SimpleGetHelper(data_reads, | 758 SimpleGetHelperResult out = SimpleGetHelper(data_reads, |
748 arraysize(data_reads)); | 759 arraysize(data_reads)); |
749 EXPECT_EQ(ERR_RESPONSE_HEADERS_MULTIPLE_LOCATION, out.rv); | 760 EXPECT_EQ(ERR_RESPONSE_HEADERS_MULTIPLE_LOCATION, out.rv); |
750 } | 761 } |
751 | 762 |
752 // Checks that two distinct Location headers result in an error. | 763 // Checks that two distinct Location headers result in an error. |
753 TEST_F(HttpNetworkTransactionTest, DuplicateDistinctLocationHeaders) { | 764 TEST_F(HttpNetworkTransactionSpdy2Test, DuplicateDistinctLocationHeaders) { |
754 MockRead data_reads[] = { | 765 MockRead data_reads[] = { |
755 MockRead("HTTP/1.1 302 Redirect\r\n"), | 766 MockRead("HTTP/1.1 302 Redirect\r\n"), |
756 MockRead("Location: http://good.com/\r\n"), | 767 MockRead("Location: http://good.com/\r\n"), |
757 MockRead("Location: http://evil.com/\r\n"), | 768 MockRead("Location: http://evil.com/\r\n"), |
758 MockRead("Content-Length: 0\r\n\r\n"), | 769 MockRead("Content-Length: 0\r\n\r\n"), |
759 MockRead(SYNCHRONOUS, OK), | 770 MockRead(SYNCHRONOUS, OK), |
760 }; | 771 }; |
761 SimpleGetHelperResult out = SimpleGetHelper(data_reads, | 772 SimpleGetHelperResult out = SimpleGetHelper(data_reads, |
762 arraysize(data_reads)); | 773 arraysize(data_reads)); |
763 EXPECT_EQ(ERR_RESPONSE_HEADERS_MULTIPLE_LOCATION, out.rv); | 774 EXPECT_EQ(ERR_RESPONSE_HEADERS_MULTIPLE_LOCATION, out.rv); |
764 } | 775 } |
765 | 776 |
766 // Do a request using the HEAD method. Verify that we don't try to read the | 777 // Do a request using the HEAD method. Verify that we don't try to read the |
767 // message body (since HEAD has none). | 778 // message body (since HEAD has none). |
768 TEST_F(HttpNetworkTransactionTest, Head) { | 779 TEST_F(HttpNetworkTransactionSpdy2Test, Head) { |
769 HttpRequestInfo request; | 780 HttpRequestInfo request; |
770 request.method = "HEAD"; | 781 request.method = "HEAD"; |
771 request.url = GURL("http://www.google.com/"); | 782 request.url = GURL("http://www.google.com/"); |
772 request.load_flags = 0; | 783 request.load_flags = 0; |
773 | 784 |
774 SessionDependencies session_deps; | 785 SessionDependencies session_deps; |
775 scoped_ptr<HttpTransaction> trans( | 786 scoped_ptr<HttpTransaction> trans( |
776 new HttpNetworkTransaction(CreateSession(&session_deps))); | 787 new HttpNetworkTransaction(CreateSession(&session_deps))); |
777 | 788 |
778 MockWrite data_writes1[] = { | 789 MockWrite data_writes1[] = { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 EXPECT_EQ("Blah", server_header); | 829 EXPECT_EQ("Blah", server_header); |
819 | 830 |
820 // Reading should give EOF right away, since there is no message body | 831 // Reading should give EOF right away, since there is no message body |
821 // (despite non-zero content-length). | 832 // (despite non-zero content-length). |
822 std::string response_data; | 833 std::string response_data; |
823 rv = ReadTransaction(trans.get(), &response_data); | 834 rv = ReadTransaction(trans.get(), &response_data); |
824 EXPECT_EQ(OK, rv); | 835 EXPECT_EQ(OK, rv); |
825 EXPECT_EQ("", response_data); | 836 EXPECT_EQ("", response_data); |
826 } | 837 } |
827 | 838 |
828 TEST_F(HttpNetworkTransactionTest, ReuseConnection) { | 839 TEST_F(HttpNetworkTransactionSpdy2Test, ReuseConnection) { |
829 SessionDependencies session_deps; | 840 SessionDependencies session_deps; |
830 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 841 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
831 | 842 |
832 MockRead data_reads[] = { | 843 MockRead data_reads[] = { |
833 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"), | 844 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"), |
834 MockRead("hello"), | 845 MockRead("hello"), |
835 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"), | 846 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"), |
836 MockRead("world"), | 847 MockRead("world"), |
837 MockRead(SYNCHRONOUS, OK), | 848 MockRead(SYNCHRONOUS, OK), |
838 }; | 849 }; |
(...skipping 26 matching lines...) Expand all Loading... |
865 EXPECT_TRUE(response->headers != NULL); | 876 EXPECT_TRUE(response->headers != NULL); |
866 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 877 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
867 | 878 |
868 std::string response_data; | 879 std::string response_data; |
869 rv = ReadTransaction(trans.get(), &response_data); | 880 rv = ReadTransaction(trans.get(), &response_data); |
870 EXPECT_EQ(OK, rv); | 881 EXPECT_EQ(OK, rv); |
871 EXPECT_EQ(kExpectedResponseData[i], response_data); | 882 EXPECT_EQ(kExpectedResponseData[i], response_data); |
872 } | 883 } |
873 } | 884 } |
874 | 885 |
875 TEST_F(HttpNetworkTransactionTest, Ignores100) { | 886 TEST_F(HttpNetworkTransactionSpdy2Test, Ignores100) { |
876 HttpRequestInfo request; | 887 HttpRequestInfo request; |
877 request.method = "POST"; | 888 request.method = "POST"; |
878 request.url = GURL("http://www.foo.com/"); | 889 request.url = GURL("http://www.foo.com/"); |
879 request.upload_data = new UploadData; | 890 request.upload_data = new UploadData; |
880 request.upload_data->AppendBytes("foo", 3); | 891 request.upload_data->AppendBytes("foo", 3); |
881 request.load_flags = 0; | 892 request.load_flags = 0; |
882 | 893 |
883 SessionDependencies session_deps; | 894 SessionDependencies session_deps; |
884 scoped_ptr<HttpTransaction> trans( | 895 scoped_ptr<HttpTransaction> trans( |
885 new HttpNetworkTransaction(CreateSession(&session_deps))); | 896 new HttpNetworkTransaction(CreateSession(&session_deps))); |
(...skipping 23 matching lines...) Expand all Loading... |
909 | 920 |
910 std::string response_data; | 921 std::string response_data; |
911 rv = ReadTransaction(trans.get(), &response_data); | 922 rv = ReadTransaction(trans.get(), &response_data); |
912 EXPECT_EQ(OK, rv); | 923 EXPECT_EQ(OK, rv); |
913 EXPECT_EQ("hello world", response_data); | 924 EXPECT_EQ("hello world", response_data); |
914 } | 925 } |
915 | 926 |
916 // This test is almost the same as Ignores100 above, but the response contains | 927 // This test is almost the same as Ignores100 above, but the response contains |
917 // a 102 instead of a 100. Also, instead of HTTP/1.0 the response is | 928 // a 102 instead of a 100. Also, instead of HTTP/1.0 the response is |
918 // HTTP/1.1 and the two status headers are read in one read. | 929 // HTTP/1.1 and the two status headers are read in one read. |
919 TEST_F(HttpNetworkTransactionTest, Ignores1xx) { | 930 TEST_F(HttpNetworkTransactionSpdy2Test, Ignores1xx) { |
920 HttpRequestInfo request; | 931 HttpRequestInfo request; |
921 request.method = "GET"; | 932 request.method = "GET"; |
922 request.url = GURL("http://www.foo.com/"); | 933 request.url = GURL("http://www.foo.com/"); |
923 request.load_flags = 0; | 934 request.load_flags = 0; |
924 | 935 |
925 SessionDependencies session_deps; | 936 SessionDependencies session_deps; |
926 scoped_ptr<HttpTransaction> trans( | 937 scoped_ptr<HttpTransaction> trans( |
927 new HttpNetworkTransaction(CreateSession(&session_deps))); | 938 new HttpNetworkTransaction(CreateSession(&session_deps))); |
928 | 939 |
929 MockRead data_reads[] = { | 940 MockRead data_reads[] = { |
(...skipping 18 matching lines...) Expand all Loading... |
948 | 959 |
949 EXPECT_TRUE(response->headers != NULL); | 960 EXPECT_TRUE(response->headers != NULL); |
950 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 961 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
951 | 962 |
952 std::string response_data; | 963 std::string response_data; |
953 rv = ReadTransaction(trans.get(), &response_data); | 964 rv = ReadTransaction(trans.get(), &response_data); |
954 EXPECT_EQ(OK, rv); | 965 EXPECT_EQ(OK, rv); |
955 EXPECT_EQ("hello world", response_data); | 966 EXPECT_EQ("hello world", response_data); |
956 } | 967 } |
957 | 968 |
958 TEST_F(HttpNetworkTransactionTest, Incomplete100ThenEOF) { | 969 TEST_F(HttpNetworkTransactionSpdy2Test, Incomplete100ThenEOF) { |
959 HttpRequestInfo request; | 970 HttpRequestInfo request; |
960 request.method = "POST"; | 971 request.method = "POST"; |
961 request.url = GURL("http://www.foo.com/"); | 972 request.url = GURL("http://www.foo.com/"); |
962 request.load_flags = 0; | 973 request.load_flags = 0; |
963 | 974 |
964 SessionDependencies session_deps; | 975 SessionDependencies session_deps; |
965 scoped_ptr<HttpTransaction> trans( | 976 scoped_ptr<HttpTransaction> trans( |
966 new HttpNetworkTransaction(CreateSession(&session_deps))); | 977 new HttpNetworkTransaction(CreateSession(&session_deps))); |
967 | 978 |
968 MockRead data_reads[] = { | 979 MockRead data_reads[] = { |
(...skipping 10 matching lines...) Expand all Loading... |
979 | 990 |
980 rv = callback.WaitForResult(); | 991 rv = callback.WaitForResult(); |
981 EXPECT_EQ(OK, rv); | 992 EXPECT_EQ(OK, rv); |
982 | 993 |
983 std::string response_data; | 994 std::string response_data; |
984 rv = ReadTransaction(trans.get(), &response_data); | 995 rv = ReadTransaction(trans.get(), &response_data); |
985 EXPECT_EQ(OK, rv); | 996 EXPECT_EQ(OK, rv); |
986 EXPECT_EQ("", response_data); | 997 EXPECT_EQ("", response_data); |
987 } | 998 } |
988 | 999 |
989 TEST_F(HttpNetworkTransactionTest, EmptyResponse) { | 1000 TEST_F(HttpNetworkTransactionSpdy2Test, EmptyResponse) { |
990 HttpRequestInfo request; | 1001 HttpRequestInfo request; |
991 request.method = "POST"; | 1002 request.method = "POST"; |
992 request.url = GURL("http://www.foo.com/"); | 1003 request.url = GURL("http://www.foo.com/"); |
993 request.load_flags = 0; | 1004 request.load_flags = 0; |
994 | 1005 |
995 SessionDependencies session_deps; | 1006 SessionDependencies session_deps; |
996 scoped_ptr<HttpTransaction> trans( | 1007 scoped_ptr<HttpTransaction> trans( |
997 new HttpNetworkTransaction(CreateSession(&session_deps))); | 1008 new HttpNetworkTransaction(CreateSession(&session_deps))); |
998 | 1009 |
999 MockRead data_reads[] = { | 1010 MockRead data_reads[] = { |
1000 MockRead(ASYNC, 0), | 1011 MockRead(ASYNC, 0), |
1001 }; | 1012 }; |
1002 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 1013 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
1003 session_deps.socket_factory.AddSocketDataProvider(&data); | 1014 session_deps.socket_factory.AddSocketDataProvider(&data); |
1004 | 1015 |
1005 TestCompletionCallback callback; | 1016 TestCompletionCallback callback; |
1006 | 1017 |
1007 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 1018 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
1008 EXPECT_EQ(ERR_IO_PENDING, rv); | 1019 EXPECT_EQ(ERR_IO_PENDING, rv); |
1009 | 1020 |
1010 rv = callback.WaitForResult(); | 1021 rv = callback.WaitForResult(); |
1011 EXPECT_EQ(ERR_EMPTY_RESPONSE, rv); | 1022 EXPECT_EQ(ERR_EMPTY_RESPONSE, rv); |
1012 } | 1023 } |
1013 | 1024 |
1014 void HttpNetworkTransactionTest::KeepAliveConnectionResendRequestTest( | 1025 void HttpNetworkTransactionSpdy2Test::KeepAliveConnectionResendRequestTest( |
1015 const MockWrite* write_failure, | 1026 const MockWrite* write_failure, |
1016 const MockRead* read_failure) { | 1027 const MockRead* read_failure) { |
1017 HttpRequestInfo request; | 1028 HttpRequestInfo request; |
1018 request.method = "GET"; | 1029 request.method = "GET"; |
1019 request.url = GURL("http://www.foo.com/"); | 1030 request.url = GURL("http://www.foo.com/"); |
1020 request.load_flags = 0; | 1031 request.load_flags = 0; |
1021 | 1032 |
1022 SessionDependencies session_deps; | 1033 SessionDependencies session_deps; |
1023 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 1034 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
1024 | 1035 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1080 EXPECT_TRUE(response->headers != NULL); | 1091 EXPECT_TRUE(response->headers != NULL); |
1081 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 1092 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
1082 | 1093 |
1083 std::string response_data; | 1094 std::string response_data; |
1084 rv = ReadTransaction(trans.get(), &response_data); | 1095 rv = ReadTransaction(trans.get(), &response_data); |
1085 EXPECT_EQ(OK, rv); | 1096 EXPECT_EQ(OK, rv); |
1086 EXPECT_EQ(kExpectedResponseData[i], response_data); | 1097 EXPECT_EQ(kExpectedResponseData[i], response_data); |
1087 } | 1098 } |
1088 } | 1099 } |
1089 | 1100 |
1090 TEST_F(HttpNetworkTransactionTest, KeepAliveConnectionNotConnectedOnWrite) { | 1101 TEST_F(HttpNetworkTransactionSpdy2Test, |
| 1102 KeepAliveConnectionNotConnectedOnWrite) { |
1091 MockWrite write_failure(ASYNC, ERR_SOCKET_NOT_CONNECTED); | 1103 MockWrite write_failure(ASYNC, ERR_SOCKET_NOT_CONNECTED); |
1092 KeepAliveConnectionResendRequestTest(&write_failure, NULL); | 1104 KeepAliveConnectionResendRequestTest(&write_failure, NULL); |
1093 } | 1105 } |
1094 | 1106 |
1095 TEST_F(HttpNetworkTransactionTest, KeepAliveConnectionReset) { | 1107 TEST_F(HttpNetworkTransactionSpdy2Test, KeepAliveConnectionReset) { |
1096 MockRead read_failure(ASYNC, ERR_CONNECTION_RESET); | 1108 MockRead read_failure(ASYNC, ERR_CONNECTION_RESET); |
1097 KeepAliveConnectionResendRequestTest(NULL, &read_failure); | 1109 KeepAliveConnectionResendRequestTest(NULL, &read_failure); |
1098 } | 1110 } |
1099 | 1111 |
1100 TEST_F(HttpNetworkTransactionTest, KeepAliveConnectionEOF) { | 1112 TEST_F(HttpNetworkTransactionSpdy2Test, KeepAliveConnectionEOF) { |
1101 MockRead read_failure(SYNCHRONOUS, OK); // EOF | 1113 MockRead read_failure(SYNCHRONOUS, OK); // EOF |
1102 KeepAliveConnectionResendRequestTest(NULL, &read_failure); | 1114 KeepAliveConnectionResendRequestTest(NULL, &read_failure); |
1103 } | 1115 } |
1104 | 1116 |
1105 TEST_F(HttpNetworkTransactionTest, NonKeepAliveConnectionReset) { | 1117 TEST_F(HttpNetworkTransactionSpdy2Test, NonKeepAliveConnectionReset) { |
1106 HttpRequestInfo request; | 1118 HttpRequestInfo request; |
1107 request.method = "GET"; | 1119 request.method = "GET"; |
1108 request.url = GURL("http://www.google.com/"); | 1120 request.url = GURL("http://www.google.com/"); |
1109 request.load_flags = 0; | 1121 request.load_flags = 0; |
1110 | 1122 |
1111 SessionDependencies session_deps; | 1123 SessionDependencies session_deps; |
1112 scoped_ptr<HttpTransaction> trans( | 1124 scoped_ptr<HttpTransaction> trans( |
1113 new HttpNetworkTransaction(CreateSession(&session_deps))); | 1125 new HttpNetworkTransaction(CreateSession(&session_deps))); |
1114 | 1126 |
1115 MockRead data_reads[] = { | 1127 MockRead data_reads[] = { |
(...skipping 19 matching lines...) Expand all Loading... |
1135 | 1147 |
1136 // What do various browsers do when the server closes a non-keepalive | 1148 // What do various browsers do when the server closes a non-keepalive |
1137 // connection without sending any response header or body? | 1149 // connection without sending any response header or body? |
1138 // | 1150 // |
1139 // IE7: error page | 1151 // IE7: error page |
1140 // Safari 3.1.2 (Windows): error page | 1152 // Safari 3.1.2 (Windows): error page |
1141 // Firefox 3.0.1: blank page | 1153 // Firefox 3.0.1: blank page |
1142 // Opera 9.52: after five attempts, blank page | 1154 // Opera 9.52: after five attempts, blank page |
1143 // Us with WinHTTP: error page (ERR_INVALID_RESPONSE) | 1155 // Us with WinHTTP: error page (ERR_INVALID_RESPONSE) |
1144 // Us: error page (EMPTY_RESPONSE) | 1156 // Us: error page (EMPTY_RESPONSE) |
1145 TEST_F(HttpNetworkTransactionTest, NonKeepAliveConnectionEOF) { | 1157 TEST_F(HttpNetworkTransactionSpdy2Test, NonKeepAliveConnectionEOF) { |
1146 MockRead data_reads[] = { | 1158 MockRead data_reads[] = { |
1147 MockRead(SYNCHRONOUS, OK), // EOF | 1159 MockRead(SYNCHRONOUS, OK), // EOF |
1148 MockRead("HTTP/1.0 200 OK\r\n\r\n"), // Should not be used | 1160 MockRead("HTTP/1.0 200 OK\r\n\r\n"), // Should not be used |
1149 MockRead("hello world"), | 1161 MockRead("hello world"), |
1150 MockRead(SYNCHRONOUS, OK), | 1162 MockRead(SYNCHRONOUS, OK), |
1151 }; | 1163 }; |
1152 SimpleGetHelperResult out = SimpleGetHelper(data_reads, | 1164 SimpleGetHelperResult out = SimpleGetHelper(data_reads, |
1153 arraysize(data_reads)); | 1165 arraysize(data_reads)); |
1154 EXPECT_EQ(ERR_EMPTY_RESPONSE, out.rv); | 1166 EXPECT_EQ(ERR_EMPTY_RESPONSE, out.rv); |
1155 } | 1167 } |
1156 | 1168 |
1157 // Test that we correctly reuse a keep-alive connection after not explicitly | 1169 // Test that we correctly reuse a keep-alive connection after not explicitly |
1158 // reading the body. | 1170 // reading the body. |
1159 TEST_F(HttpNetworkTransactionTest, KeepAliveAfterUnreadBody) { | 1171 TEST_F(HttpNetworkTransactionSpdy2Test, KeepAliveAfterUnreadBody) { |
1160 HttpRequestInfo request; | 1172 HttpRequestInfo request; |
1161 request.method = "GET"; | 1173 request.method = "GET"; |
1162 request.url = GURL("http://www.foo.com/"); | 1174 request.url = GURL("http://www.foo.com/"); |
1163 request.load_flags = 0; | 1175 request.load_flags = 0; |
1164 | 1176 |
1165 SessionDependencies session_deps; | 1177 SessionDependencies session_deps; |
1166 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 1178 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
1167 | 1179 |
1168 // Note that because all these reads happen in the same | 1180 // Note that because all these reads happen in the same |
1169 // StaticSocketDataProvider, it shows that the same socket is being reused for | 1181 // StaticSocketDataProvider, it shows that the same socket is being reused for |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1244 ASSERT_TRUE(response->headers != NULL); | 1256 ASSERT_TRUE(response->headers != NULL); |
1245 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 1257 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
1246 std::string response_data; | 1258 std::string response_data; |
1247 rv = ReadTransaction(trans.get(), &response_data); | 1259 rv = ReadTransaction(trans.get(), &response_data); |
1248 EXPECT_EQ(OK, rv); | 1260 EXPECT_EQ(OK, rv); |
1249 EXPECT_EQ("hello", response_data); | 1261 EXPECT_EQ("hello", response_data); |
1250 } | 1262 } |
1251 | 1263 |
1252 // Test the request-challenge-retry sequence for basic auth. | 1264 // Test the request-challenge-retry sequence for basic auth. |
1253 // (basic auth is the easiest to mock, because it has no randomness). | 1265 // (basic auth is the easiest to mock, because it has no randomness). |
1254 TEST_F(HttpNetworkTransactionTest, BasicAuth) { | 1266 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuth) { |
1255 HttpRequestInfo request; | 1267 HttpRequestInfo request; |
1256 request.method = "GET"; | 1268 request.method = "GET"; |
1257 request.url = GURL("http://www.google.com/"); | 1269 request.url = GURL("http://www.google.com/"); |
1258 request.load_flags = 0; | 1270 request.load_flags = 0; |
1259 | 1271 |
1260 SessionDependencies session_deps; | 1272 SessionDependencies session_deps; |
1261 scoped_ptr<HttpTransaction> trans( | 1273 scoped_ptr<HttpTransaction> trans( |
1262 new HttpNetworkTransaction(CreateSession(&session_deps))); | 1274 new HttpNetworkTransaction(CreateSession(&session_deps))); |
1263 | 1275 |
1264 MockWrite data_writes1[] = { | 1276 MockWrite data_writes1[] = { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1324 | 1336 |
1325 rv = callback2.WaitForResult(); | 1337 rv = callback2.WaitForResult(); |
1326 EXPECT_EQ(OK, rv); | 1338 EXPECT_EQ(OK, rv); |
1327 | 1339 |
1328 response = trans->GetResponseInfo(); | 1340 response = trans->GetResponseInfo(); |
1329 ASSERT_TRUE(response != NULL); | 1341 ASSERT_TRUE(response != NULL); |
1330 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 1342 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
1331 EXPECT_EQ(100, response->headers->GetContentLength()); | 1343 EXPECT_EQ(100, response->headers->GetContentLength()); |
1332 } | 1344 } |
1333 | 1345 |
1334 TEST_F(HttpNetworkTransactionTest, DoNotSendAuth) { | 1346 TEST_F(HttpNetworkTransactionSpdy2Test, DoNotSendAuth) { |
1335 HttpRequestInfo request; | 1347 HttpRequestInfo request; |
1336 request.method = "GET"; | 1348 request.method = "GET"; |
1337 request.url = GURL("http://www.google.com/"); | 1349 request.url = GURL("http://www.google.com/"); |
1338 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; | 1350 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; |
1339 | 1351 |
1340 SessionDependencies session_deps; | 1352 SessionDependencies session_deps; |
1341 scoped_ptr<HttpTransaction> trans( | 1353 scoped_ptr<HttpTransaction> trans( |
1342 new HttpNetworkTransaction(CreateSession(&session_deps))); | 1354 new HttpNetworkTransaction(CreateSession(&session_deps))); |
1343 | 1355 |
1344 MockWrite data_writes[] = { | 1356 MockWrite data_writes[] = { |
(...skipping 22 matching lines...) Expand all Loading... |
1367 rv = callback.WaitForResult(); | 1379 rv = callback.WaitForResult(); |
1368 EXPECT_EQ(0, rv); | 1380 EXPECT_EQ(0, rv); |
1369 | 1381 |
1370 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1382 const HttpResponseInfo* response = trans->GetResponseInfo(); |
1371 ASSERT_TRUE(response != NULL); | 1383 ASSERT_TRUE(response != NULL); |
1372 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 1384 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
1373 } | 1385 } |
1374 | 1386 |
1375 // Test the request-challenge-retry sequence for basic auth, over a keep-alive | 1387 // Test the request-challenge-retry sequence for basic auth, over a keep-alive |
1376 // connection. | 1388 // connection. |
1377 TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAlive) { | 1389 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthKeepAlive) { |
1378 HttpRequestInfo request; | 1390 HttpRequestInfo request; |
1379 request.method = "GET"; | 1391 request.method = "GET"; |
1380 request.url = GURL("http://www.google.com/"); | 1392 request.url = GURL("http://www.google.com/"); |
1381 request.load_flags = 0; | 1393 request.load_flags = 0; |
1382 | 1394 |
1383 SessionDependencies session_deps; | 1395 SessionDependencies session_deps; |
1384 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 1396 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
1385 | 1397 |
1386 MockWrite data_writes1[] = { | 1398 MockWrite data_writes1[] = { |
1387 MockWrite("GET / HTTP/1.1\r\n" | 1399 MockWrite("GET / HTTP/1.1\r\n" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1446 EXPECT_EQ(OK, rv); | 1458 EXPECT_EQ(OK, rv); |
1447 | 1459 |
1448 response = trans->GetResponseInfo(); | 1460 response = trans->GetResponseInfo(); |
1449 ASSERT_TRUE(response != NULL); | 1461 ASSERT_TRUE(response != NULL); |
1450 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 1462 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
1451 EXPECT_EQ(5, response->headers->GetContentLength()); | 1463 EXPECT_EQ(5, response->headers->GetContentLength()); |
1452 } | 1464 } |
1453 | 1465 |
1454 // Test the request-challenge-retry sequence for basic auth, over a keep-alive | 1466 // Test the request-challenge-retry sequence for basic auth, over a keep-alive |
1455 // connection and with no response body to drain. | 1467 // connection and with no response body to drain. |
1456 TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAliveNoBody) { | 1468 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthKeepAliveNoBody) { |
1457 HttpRequestInfo request; | 1469 HttpRequestInfo request; |
1458 request.method = "GET"; | 1470 request.method = "GET"; |
1459 request.url = GURL("http://www.google.com/"); | 1471 request.url = GURL("http://www.google.com/"); |
1460 request.load_flags = 0; | 1472 request.load_flags = 0; |
1461 | 1473 |
1462 SessionDependencies session_deps; | 1474 SessionDependencies session_deps; |
1463 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 1475 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
1464 | 1476 |
1465 MockWrite data_writes1[] = { | 1477 MockWrite data_writes1[] = { |
1466 MockWrite("GET / HTTP/1.1\r\n" | 1478 MockWrite("GET / HTTP/1.1\r\n" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1522 EXPECT_EQ(OK, rv); | 1534 EXPECT_EQ(OK, rv); |
1523 | 1535 |
1524 response = trans->GetResponseInfo(); | 1536 response = trans->GetResponseInfo(); |
1525 ASSERT_TRUE(response != NULL); | 1537 ASSERT_TRUE(response != NULL); |
1526 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 1538 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
1527 EXPECT_EQ(5, response->headers->GetContentLength()); | 1539 EXPECT_EQ(5, response->headers->GetContentLength()); |
1528 } | 1540 } |
1529 | 1541 |
1530 // Test the request-challenge-retry sequence for basic auth, over a keep-alive | 1542 // Test the request-challenge-retry sequence for basic auth, over a keep-alive |
1531 // connection and with a large response body to drain. | 1543 // connection and with a large response body to drain. |
1532 TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAliveLargeBody) { | 1544 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthKeepAliveLargeBody) { |
1533 HttpRequestInfo request; | 1545 HttpRequestInfo request; |
1534 request.method = "GET"; | 1546 request.method = "GET"; |
1535 request.url = GURL("http://www.google.com/"); | 1547 request.url = GURL("http://www.google.com/"); |
1536 request.load_flags = 0; | 1548 request.load_flags = 0; |
1537 | 1549 |
1538 SessionDependencies session_deps; | 1550 SessionDependencies session_deps; |
1539 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 1551 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
1540 | 1552 |
1541 MockWrite data_writes1[] = { | 1553 MockWrite data_writes1[] = { |
1542 MockWrite("GET / HTTP/1.1\r\n" | 1554 MockWrite("GET / HTTP/1.1\r\n" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1606 EXPECT_EQ(OK, rv); | 1618 EXPECT_EQ(OK, rv); |
1607 | 1619 |
1608 response = trans->GetResponseInfo(); | 1620 response = trans->GetResponseInfo(); |
1609 ASSERT_TRUE(response != NULL); | 1621 ASSERT_TRUE(response != NULL); |
1610 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 1622 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
1611 EXPECT_EQ(5, response->headers->GetContentLength()); | 1623 EXPECT_EQ(5, response->headers->GetContentLength()); |
1612 } | 1624 } |
1613 | 1625 |
1614 // Test the request-challenge-retry sequence for basic auth, over a keep-alive | 1626 // Test the request-challenge-retry sequence for basic auth, over a keep-alive |
1615 // connection, but the server gets impatient and closes the connection. | 1627 // connection, but the server gets impatient and closes the connection. |
1616 TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAliveImpatientServer) { | 1628 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthKeepAliveImpatientServer) { |
1617 HttpRequestInfo request; | 1629 HttpRequestInfo request; |
1618 request.method = "GET"; | 1630 request.method = "GET"; |
1619 request.url = GURL("http://www.google.com/"); | 1631 request.url = GURL("http://www.google.com/"); |
1620 request.load_flags = 0; | 1632 request.load_flags = 0; |
1621 | 1633 |
1622 SessionDependencies session_deps; | 1634 SessionDependencies session_deps; |
1623 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 1635 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
1624 | 1636 |
1625 MockWrite data_writes1[] = { | 1637 MockWrite data_writes1[] = { |
1626 MockWrite("GET / HTTP/1.1\r\n" | 1638 MockWrite("GET / HTTP/1.1\r\n" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1692 EXPECT_EQ(OK, rv); | 1704 EXPECT_EQ(OK, rv); |
1693 | 1705 |
1694 response = trans->GetResponseInfo(); | 1706 response = trans->GetResponseInfo(); |
1695 ASSERT_TRUE(response != NULL); | 1707 ASSERT_TRUE(response != NULL); |
1696 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 1708 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
1697 EXPECT_EQ(5, response->headers->GetContentLength()); | 1709 EXPECT_EQ(5, response->headers->GetContentLength()); |
1698 } | 1710 } |
1699 | 1711 |
1700 // Test the request-challenge-retry sequence for basic auth, over a connection | 1712 // Test the request-challenge-retry sequence for basic auth, over a connection |
1701 // that requires a restart when setting up an SSL tunnel. | 1713 // that requires a restart when setting up an SSL tunnel. |
1702 TEST_F(HttpNetworkTransactionTest, BasicAuthProxyNoKeepAlive) { | 1714 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthProxyNoKeepAlive) { |
1703 HttpRequestInfo request; | 1715 HttpRequestInfo request; |
1704 request.method = "GET"; | 1716 request.method = "GET"; |
1705 request.url = GURL("https://www.google.com/"); | 1717 request.url = GURL("https://www.google.com/"); |
1706 // when the no authentication data flag is set. | 1718 // when the no authentication data flag is set. |
1707 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; | 1719 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; |
1708 | 1720 |
1709 // Configure against proxy server "myproxy:70". | 1721 // Configure against proxy server "myproxy:70". |
1710 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 1722 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
1711 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 1723 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); |
1712 session_deps.net_log = log.bound().net_log(); | 1724 session_deps.net_log = log.bound().net_log(); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1797 | 1809 |
1798 // The password prompt info should not be set. | 1810 // The password prompt info should not be set. |
1799 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 1811 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
1800 | 1812 |
1801 trans.reset(); | 1813 trans.reset(); |
1802 session->CloseAllConnections(); | 1814 session->CloseAllConnections(); |
1803 } | 1815 } |
1804 | 1816 |
1805 // Test the request-challenge-retry sequence for basic auth, over a keep-alive | 1817 // Test the request-challenge-retry sequence for basic auth, over a keep-alive |
1806 // proxy connection, when setting up an SSL tunnel. | 1818 // proxy connection, when setting up an SSL tunnel. |
1807 TEST_F(HttpNetworkTransactionTest, BasicAuthProxyKeepAlive) { | 1819 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthProxyKeepAlive) { |
1808 HttpRequestInfo request; | 1820 HttpRequestInfo request; |
1809 request.method = "GET"; | 1821 request.method = "GET"; |
1810 request.url = GURL("https://www.google.com/"); | 1822 request.url = GURL("https://www.google.com/"); |
1811 // Ensure that proxy authentication is attempted even | 1823 // Ensure that proxy authentication is attempted even |
1812 // when the no authentication data flag is set. | 1824 // when the no authentication data flag is set. |
1813 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; | 1825 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; |
1814 | 1826 |
1815 // Configure against proxy server "myproxy:70". | 1827 // Configure against proxy server "myproxy:70". |
1816 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 1828 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
1817 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 1829 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1900 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 1912 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
1901 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 1913 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
1902 | 1914 |
1903 // Flush the idle socket before the NetLog and HttpNetworkTransaction go | 1915 // Flush the idle socket before the NetLog and HttpNetworkTransaction go |
1904 // out of scope. | 1916 // out of scope. |
1905 session->CloseAllConnections(); | 1917 session->CloseAllConnections(); |
1906 } | 1918 } |
1907 | 1919 |
1908 // Test that we don't read the response body when we fail to establish a tunnel, | 1920 // Test that we don't read the response body when we fail to establish a tunnel, |
1909 // even if the user cancels the proxy's auth attempt. | 1921 // even if the user cancels the proxy's auth attempt. |
1910 TEST_F(HttpNetworkTransactionTest, BasicAuthProxyCancelTunnel) { | 1922 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthProxyCancelTunnel) { |
1911 HttpRequestInfo request; | 1923 HttpRequestInfo request; |
1912 request.method = "GET"; | 1924 request.method = "GET"; |
1913 request.url = GURL("https://www.google.com/"); | 1925 request.url = GURL("https://www.google.com/"); |
1914 request.load_flags = 0; | 1926 request.load_flags = 0; |
1915 | 1927 |
1916 // Configure against proxy server "myproxy:70". | 1928 // Configure against proxy server "myproxy:70". |
1917 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 1929 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
1918 | 1930 |
1919 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 1931 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
1920 | 1932 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1958 std::string response_data; | 1970 std::string response_data; |
1959 rv = ReadTransaction(trans.get(), &response_data); | 1971 rv = ReadTransaction(trans.get(), &response_data); |
1960 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); | 1972 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); |
1961 | 1973 |
1962 // Flush the idle socket before the HttpNetworkTransaction goes out of scope. | 1974 // Flush the idle socket before the HttpNetworkTransaction goes out of scope. |
1963 session->CloseAllConnections(); | 1975 session->CloseAllConnections(); |
1964 } | 1976 } |
1965 | 1977 |
1966 // Test when a server (non-proxy) returns a 407 (proxy-authenticate). | 1978 // Test when a server (non-proxy) returns a 407 (proxy-authenticate). |
1967 // The request should fail with ERR_UNEXPECTED_PROXY_AUTH. | 1979 // The request should fail with ERR_UNEXPECTED_PROXY_AUTH. |
1968 TEST_F(HttpNetworkTransactionTest, UnexpectedProxyAuth) { | 1980 TEST_F(HttpNetworkTransactionSpdy2Test, UnexpectedProxyAuth) { |
1969 HttpRequestInfo request; | 1981 HttpRequestInfo request; |
1970 request.method = "GET"; | 1982 request.method = "GET"; |
1971 request.url = GURL("http://www.google.com/"); | 1983 request.url = GURL("http://www.google.com/"); |
1972 request.load_flags = 0; | 1984 request.load_flags = 0; |
1973 | 1985 |
1974 // We are using a DIRECT connection (i.e. no proxy) for this session. | 1986 // We are using a DIRECT connection (i.e. no proxy) for this session. |
1975 SessionDependencies session_deps; | 1987 SessionDependencies session_deps; |
1976 scoped_ptr<HttpTransaction> trans( | 1988 scoped_ptr<HttpTransaction> trans( |
1977 new HttpNetworkTransaction(CreateSession(&session_deps))); | 1989 new HttpNetworkTransaction(CreateSession(&session_deps))); |
1978 | 1990 |
(...skipping 24 matching lines...) Expand all Loading... |
2003 EXPECT_EQ(ERR_UNEXPECTED_PROXY_AUTH, rv); | 2015 EXPECT_EQ(ERR_UNEXPECTED_PROXY_AUTH, rv); |
2004 } | 2016 } |
2005 | 2017 |
2006 // Tests when an HTTPS server (non-proxy) returns a 407 (proxy-authentication) | 2018 // Tests when an HTTPS server (non-proxy) returns a 407 (proxy-authentication) |
2007 // through a non-authenticating proxy. The request should fail with | 2019 // through a non-authenticating proxy. The request should fail with |
2008 // ERR_UNEXPECTED_PROXY_AUTH. | 2020 // ERR_UNEXPECTED_PROXY_AUTH. |
2009 // Note that it is impossible to detect if an HTTP server returns a 407 through | 2021 // Note that it is impossible to detect if an HTTP server returns a 407 through |
2010 // a non-authenticating proxy - there is nothing to indicate whether the | 2022 // a non-authenticating proxy - there is nothing to indicate whether the |
2011 // response came from the proxy or the server, so it is treated as if the proxy | 2023 // response came from the proxy or the server, so it is treated as if the proxy |
2012 // issued the challenge. | 2024 // issued the challenge. |
2013 TEST_F(HttpNetworkTransactionTest, HttpsServerRequestsProxyAuthThroughProxy) { | 2025 TEST_F(HttpNetworkTransactionSpdy2Test, |
| 2026 HttpsServerRequestsProxyAuthThroughProxy) { |
2014 HttpRequestInfo request; | 2027 HttpRequestInfo request; |
2015 request.method = "GET"; | 2028 request.method = "GET"; |
2016 request.url = GURL("https://www.google.com/"); | 2029 request.url = GURL("https://www.google.com/"); |
2017 | 2030 |
2018 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 2031 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
2019 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 2032 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); |
2020 session_deps.net_log = log.bound().net_log(); | 2033 session_deps.net_log = log.bound().net_log(); |
2021 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 2034 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
2022 | 2035 |
2023 // Since we have proxy, should try to establish tunnel. | 2036 // Since we have proxy, should try to establish tunnel. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2060 size_t pos = ExpectLogContainsSomewhere( | 2073 size_t pos = ExpectLogContainsSomewhere( |
2061 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 2074 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
2062 NetLog::PHASE_NONE); | 2075 NetLog::PHASE_NONE); |
2063 ExpectLogContainsSomewhere( | 2076 ExpectLogContainsSomewhere( |
2064 entries, pos, | 2077 entries, pos, |
2065 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 2078 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
2066 NetLog::PHASE_NONE); | 2079 NetLog::PHASE_NONE); |
2067 } | 2080 } |
2068 | 2081 |
2069 // Test a simple get through an HTTPS Proxy. | 2082 // Test a simple get through an HTTPS Proxy. |
2070 TEST_F(HttpNetworkTransactionTest, HttpsProxyGet) { | 2083 TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxyGet) { |
2071 HttpRequestInfo request; | 2084 HttpRequestInfo request; |
2072 request.method = "GET"; | 2085 request.method = "GET"; |
2073 request.url = GURL("http://www.google.com/"); | 2086 request.url = GURL("http://www.google.com/"); |
2074 | 2087 |
2075 // Configure against https proxy server "proxy:70". | 2088 // Configure against https proxy server "proxy:70". |
2076 SessionDependencies session_deps(ProxyService::CreateFixed( | 2089 SessionDependencies session_deps(ProxyService::CreateFixed( |
2077 "https://proxy:70")); | 2090 "https://proxy:70")); |
2078 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 2091 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); |
2079 session_deps.net_log = log.bound().net_log(); | 2092 session_deps.net_log = log.bound().net_log(); |
2080 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 2093 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2115 EXPECT_TRUE(response->headers->IsKeepAlive()); | 2128 EXPECT_TRUE(response->headers->IsKeepAlive()); |
2116 EXPECT_EQ(200, response->headers->response_code()); | 2129 EXPECT_EQ(200, response->headers->response_code()); |
2117 EXPECT_EQ(100, response->headers->GetContentLength()); | 2130 EXPECT_EQ(100, response->headers->GetContentLength()); |
2118 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 2131 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
2119 | 2132 |
2120 // The password prompt info should not be set. | 2133 // The password prompt info should not be set. |
2121 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 2134 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
2122 } | 2135 } |
2123 | 2136 |
2124 // Test a SPDY get through an HTTPS Proxy. | 2137 // Test a SPDY get through an HTTPS Proxy. |
2125 TEST_F(HttpNetworkTransactionTest, HttpsProxySpdyGet) { | 2138 TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxySpdyGet) { |
2126 HttpRequestInfo request; | 2139 HttpRequestInfo request; |
2127 request.method = "GET"; | 2140 request.method = "GET"; |
2128 request.url = GURL("http://www.google.com/"); | 2141 request.url = GURL("http://www.google.com/"); |
2129 request.load_flags = 0; | 2142 request.load_flags = 0; |
2130 | 2143 |
2131 // Configure against https proxy server "proxy:70". | 2144 // Configure against https proxy server "proxy:70". |
2132 SessionDependencies session_deps(ProxyService::CreateFixed( | 2145 SessionDependencies session_deps(ProxyService::CreateFixed( |
2133 "https://proxy:70")); | 2146 "https://proxy:70")); |
2134 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 2147 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); |
2135 session_deps.net_log = log.bound().net_log(); | 2148 session_deps.net_log = log.bound().net_log(); |
(...skipping 13 matching lines...) Expand all Loading... |
2149 }; | 2162 }; |
2150 | 2163 |
2151 scoped_ptr<DelayedSocketData> spdy_data( | 2164 scoped_ptr<DelayedSocketData> spdy_data( |
2152 new DelayedSocketData( | 2165 new DelayedSocketData( |
2153 1, // wait for one write to finish before reading. | 2166 1, // wait for one write to finish before reading. |
2154 spdy_reads, arraysize(spdy_reads), | 2167 spdy_reads, arraysize(spdy_reads), |
2155 spdy_writes, arraysize(spdy_writes))); | 2168 spdy_writes, arraysize(spdy_writes))); |
2156 session_deps.socket_factory.AddSocketDataProvider(spdy_data.get()); | 2169 session_deps.socket_factory.AddSocketDataProvider(spdy_data.get()); |
2157 | 2170 |
2158 SSLSocketDataProvider ssl(ASYNC, OK); | 2171 SSLSocketDataProvider ssl(ASYNC, OK); |
2159 ssl.SetNextProto(SSLClientSocket::kProtoSPDY21); | 2172 ssl.SetNextProto(SSLClientSocket::kProtoSPDY2); |
2160 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 2173 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
2161 | 2174 |
2162 TestCompletionCallback callback1; | 2175 TestCompletionCallback callback1; |
2163 | 2176 |
2164 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 2177 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
2165 | 2178 |
2166 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 2179 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
2167 EXPECT_EQ(ERR_IO_PENDING, rv); | 2180 EXPECT_EQ(ERR_IO_PENDING, rv); |
2168 | 2181 |
2169 rv = callback1.WaitForResult(); | 2182 rv = callback1.WaitForResult(); |
2170 EXPECT_EQ(OK, rv); | 2183 EXPECT_EQ(OK, rv); |
2171 | 2184 |
2172 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2185 const HttpResponseInfo* response = trans->GetResponseInfo(); |
2173 ASSERT_TRUE(response != NULL); | 2186 ASSERT_TRUE(response != NULL); |
2174 ASSERT_TRUE(response->headers != NULL); | 2187 ASSERT_TRUE(response->headers != NULL); |
2175 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 2188 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
2176 | 2189 |
2177 std::string response_data; | 2190 std::string response_data; |
2178 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 2191 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
2179 EXPECT_EQ(net::kUploadData, response_data); | 2192 EXPECT_EQ(kUploadData, response_data); |
2180 } | 2193 } |
2181 | 2194 |
2182 // Test a SPDY get through an HTTPS Proxy. | 2195 // Test a SPDY get through an HTTPS Proxy. |
2183 TEST_F(HttpNetworkTransactionTest, HttpsProxySpdyGetWithProxyAuth) { | 2196 TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxySpdyGetWithProxyAuth) { |
2184 HttpRequestInfo request; | 2197 HttpRequestInfo request; |
2185 request.method = "GET"; | 2198 request.method = "GET"; |
2186 request.url = GURL("http://www.google.com/"); | 2199 request.url = GURL("http://www.google.com/"); |
2187 request.load_flags = 0; | 2200 request.load_flags = 0; |
2188 | 2201 |
2189 // Configure against https proxy server "myproxy:70". | 2202 // Configure against https proxy server "myproxy:70". |
2190 SessionDependencies session_deps( | 2203 SessionDependencies session_deps( |
2191 ProxyService::CreateFixed("https://myproxy:70")); | 2204 ProxyService::CreateFixed("https://myproxy:70")); |
2192 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 2205 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); |
2193 session_deps.net_log = log.bound().net_log(); | 2206 session_deps.net_log = log.bound().net_log(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2233 CreateMockRead(*body_data, 6), | 2246 CreateMockRead(*body_data, 6), |
2234 MockRead(ASYNC, 0, 7), | 2247 MockRead(ASYNC, 0, 7), |
2235 }; | 2248 }; |
2236 | 2249 |
2237 scoped_ptr<OrderedSocketData> data( | 2250 scoped_ptr<OrderedSocketData> data( |
2238 new OrderedSocketData(spdy_reads, arraysize(spdy_reads), | 2251 new OrderedSocketData(spdy_reads, arraysize(spdy_reads), |
2239 spdy_writes, arraysize(spdy_writes))); | 2252 spdy_writes, arraysize(spdy_writes))); |
2240 session_deps.socket_factory.AddSocketDataProvider(data.get()); | 2253 session_deps.socket_factory.AddSocketDataProvider(data.get()); |
2241 | 2254 |
2242 SSLSocketDataProvider ssl(ASYNC, OK); | 2255 SSLSocketDataProvider ssl(ASYNC, OK); |
2243 ssl.SetNextProto(SSLClientSocket::kProtoSPDY21); | 2256 ssl.SetNextProto(SSLClientSocket::kProtoSPDY2); |
2244 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 2257 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
2245 | 2258 |
2246 TestCompletionCallback callback1; | 2259 TestCompletionCallback callback1; |
2247 | 2260 |
2248 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 2261 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
2249 | 2262 |
2250 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 2263 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
2251 EXPECT_EQ(ERR_IO_PENDING, rv); | 2264 EXPECT_EQ(ERR_IO_PENDING, rv); |
2252 | 2265 |
2253 rv = callback1.WaitForResult(); | 2266 rv = callback1.WaitForResult(); |
(...skipping 19 matching lines...) Expand all Loading... |
2273 const HttpResponseInfo* const response_restart = trans->GetResponseInfo(); | 2286 const HttpResponseInfo* const response_restart = trans->GetResponseInfo(); |
2274 | 2287 |
2275 ASSERT_TRUE(response_restart != NULL); | 2288 ASSERT_TRUE(response_restart != NULL); |
2276 ASSERT_TRUE(response_restart->headers != NULL); | 2289 ASSERT_TRUE(response_restart->headers != NULL); |
2277 EXPECT_EQ(200, response_restart->headers->response_code()); | 2290 EXPECT_EQ(200, response_restart->headers->response_code()); |
2278 // The password prompt info should not be set. | 2291 // The password prompt info should not be set. |
2279 EXPECT_TRUE(response_restart->auth_challenge.get() == NULL); | 2292 EXPECT_TRUE(response_restart->auth_challenge.get() == NULL); |
2280 } | 2293 } |
2281 | 2294 |
2282 // Test a SPDY CONNECT through an HTTPS Proxy to an HTTPS (non-SPDY) Server. | 2295 // Test a SPDY CONNECT through an HTTPS Proxy to an HTTPS (non-SPDY) Server. |
2283 TEST_F(HttpNetworkTransactionTest, HttpsProxySpdyConnectHttps) { | 2296 TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxySpdyConnectHttps) { |
2284 HttpRequestInfo request; | 2297 HttpRequestInfo request; |
2285 request.method = "GET"; | 2298 request.method = "GET"; |
2286 request.url = GURL("https://www.google.com/"); | 2299 request.url = GURL("https://www.google.com/"); |
2287 request.load_flags = 0; | 2300 request.load_flags = 0; |
2288 | 2301 |
2289 // Configure against https proxy server "proxy:70". | 2302 // Configure against https proxy server "proxy:70". |
2290 SessionDependencies session_deps(ProxyService::CreateFixed( | 2303 SessionDependencies session_deps(ProxyService::CreateFixed( |
2291 "https://proxy:70")); | 2304 "https://proxy:70")); |
2292 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 2305 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); |
2293 session_deps.net_log = log.bound().net_log(); | 2306 session_deps.net_log = log.bound().net_log(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2328 MockRead(ASYNC, 0, 8), | 2341 MockRead(ASYNC, 0, 8), |
2329 }; | 2342 }; |
2330 | 2343 |
2331 scoped_ptr<OrderedSocketData> spdy_data( | 2344 scoped_ptr<OrderedSocketData> spdy_data( |
2332 new OrderedSocketData( | 2345 new OrderedSocketData( |
2333 spdy_reads, arraysize(spdy_reads), | 2346 spdy_reads, arraysize(spdy_reads), |
2334 spdy_writes, arraysize(spdy_writes))); | 2347 spdy_writes, arraysize(spdy_writes))); |
2335 session_deps.socket_factory.AddSocketDataProvider(spdy_data.get()); | 2348 session_deps.socket_factory.AddSocketDataProvider(spdy_data.get()); |
2336 | 2349 |
2337 SSLSocketDataProvider ssl(ASYNC, OK); | 2350 SSLSocketDataProvider ssl(ASYNC, OK); |
2338 ssl.SetNextProto(SSLClientSocket::kProtoSPDY21); | 2351 ssl.SetNextProto(SSLClientSocket::kProtoSPDY2); |
2339 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 2352 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
2340 SSLSocketDataProvider ssl2(ASYNC, OK); | 2353 SSLSocketDataProvider ssl2(ASYNC, OK); |
2341 ssl2.was_npn_negotiated = false; | 2354 ssl2.was_npn_negotiated = false; |
2342 ssl2.protocol_negotiated = SSLClientSocket::kProtoUnknown; | 2355 ssl2.protocol_negotiated = SSLClientSocket::kProtoUnknown; |
2343 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl2); | 2356 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl2); |
2344 | 2357 |
2345 TestCompletionCallback callback1; | 2358 TestCompletionCallback callback1; |
2346 | 2359 |
2347 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 2360 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
2348 EXPECT_EQ(ERR_IO_PENDING, rv); | 2361 EXPECT_EQ(ERR_IO_PENDING, rv); |
2349 | 2362 |
2350 rv = callback1.WaitForResult(); | 2363 rv = callback1.WaitForResult(); |
2351 EXPECT_EQ(OK, rv); | 2364 EXPECT_EQ(OK, rv); |
2352 | 2365 |
2353 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2366 const HttpResponseInfo* response = trans->GetResponseInfo(); |
2354 ASSERT_TRUE(response != NULL); | 2367 ASSERT_TRUE(response != NULL); |
2355 ASSERT_TRUE(response->headers != NULL); | 2368 ASSERT_TRUE(response->headers != NULL); |
2356 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 2369 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
2357 | 2370 |
2358 std::string response_data; | 2371 std::string response_data; |
2359 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 2372 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
2360 EXPECT_EQ("1234567890", response_data); | 2373 EXPECT_EQ("1234567890", response_data); |
2361 } | 2374 } |
2362 | 2375 |
2363 // Test a SPDY CONNECT through an HTTPS Proxy to a SPDY server. | 2376 // Test a SPDY CONNECT through an HTTPS Proxy to a SPDY server. |
2364 TEST_F(HttpNetworkTransactionTest, HttpsProxySpdyConnectSpdy) { | 2377 TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxySpdyConnectSpdy) { |
2365 HttpRequestInfo request; | 2378 HttpRequestInfo request; |
2366 request.method = "GET"; | 2379 request.method = "GET"; |
2367 request.url = GURL("https://www.google.com/"); | 2380 request.url = GURL("https://www.google.com/"); |
2368 request.load_flags = 0; | 2381 request.load_flags = 0; |
2369 | 2382 |
2370 // Configure against https proxy server "proxy:70". | 2383 // Configure against https proxy server "proxy:70". |
2371 SessionDependencies session_deps(ProxyService::CreateFixed( | 2384 SessionDependencies session_deps(ProxyService::CreateFixed( |
2372 "https://proxy:70")); | 2385 "https://proxy:70")); |
2373 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 2386 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); |
2374 session_deps.net_log = log.bound().net_log(); | 2387 session_deps.net_log = log.bound().net_log(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2407 MockRead(ASYNC, 0, 8), | 2420 MockRead(ASYNC, 0, 8), |
2408 }; | 2421 }; |
2409 | 2422 |
2410 scoped_ptr<OrderedSocketData> spdy_data( | 2423 scoped_ptr<OrderedSocketData> spdy_data( |
2411 new OrderedSocketData( | 2424 new OrderedSocketData( |
2412 spdy_reads, arraysize(spdy_reads), | 2425 spdy_reads, arraysize(spdy_reads), |
2413 spdy_writes, arraysize(spdy_writes))); | 2426 spdy_writes, arraysize(spdy_writes))); |
2414 session_deps.socket_factory.AddSocketDataProvider(spdy_data.get()); | 2427 session_deps.socket_factory.AddSocketDataProvider(spdy_data.get()); |
2415 | 2428 |
2416 SSLSocketDataProvider ssl(ASYNC, OK); | 2429 SSLSocketDataProvider ssl(ASYNC, OK); |
2417 ssl.SetNextProto(SSLClientSocket::kProtoSPDY21); | 2430 ssl.SetNextProto(SSLClientSocket::kProtoSPDY2); |
2418 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 2431 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
2419 SSLSocketDataProvider ssl2(ASYNC, OK); | 2432 SSLSocketDataProvider ssl2(ASYNC, OK); |
2420 ssl2.SetNextProto(SSLClientSocket::kProtoSPDY21); | 2433 ssl2.SetNextProto(SSLClientSocket::kProtoSPDY2); |
2421 ssl2.protocol_negotiated = SSLClientSocket::kProtoSPDY21; | 2434 ssl2.protocol_negotiated = SSLClientSocket::kProtoSPDY2; |
2422 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl2); | 2435 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl2); |
2423 | 2436 |
2424 TestCompletionCallback callback1; | 2437 TestCompletionCallback callback1; |
2425 | 2438 |
2426 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 2439 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
2427 EXPECT_EQ(ERR_IO_PENDING, rv); | 2440 EXPECT_EQ(ERR_IO_PENDING, rv); |
2428 | 2441 |
2429 rv = callback1.WaitForResult(); | 2442 rv = callback1.WaitForResult(); |
2430 EXPECT_EQ(OK, rv); | 2443 EXPECT_EQ(OK, rv); |
2431 | 2444 |
2432 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2445 const HttpResponseInfo* response = trans->GetResponseInfo(); |
2433 ASSERT_TRUE(response != NULL); | 2446 ASSERT_TRUE(response != NULL); |
2434 ASSERT_TRUE(response->headers != NULL); | 2447 ASSERT_TRUE(response->headers != NULL); |
2435 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 2448 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
2436 | 2449 |
2437 std::string response_data; | 2450 std::string response_data; |
2438 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 2451 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
2439 EXPECT_EQ(net::kUploadData, response_data); | 2452 EXPECT_EQ(kUploadData, response_data); |
2440 } | 2453 } |
2441 | 2454 |
2442 // Test a SPDY CONNECT failure through an HTTPS Proxy. | 2455 // Test a SPDY CONNECT failure through an HTTPS Proxy. |
2443 TEST_F(HttpNetworkTransactionTest, HttpsProxySpdyConnectFailure) { | 2456 TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxySpdyConnectFailure) { |
2444 HttpRequestInfo request; | 2457 HttpRequestInfo request; |
2445 request.method = "GET"; | 2458 request.method = "GET"; |
2446 request.url = GURL("https://www.google.com/"); | 2459 request.url = GURL("https://www.google.com/"); |
2447 request.load_flags = 0; | 2460 request.load_flags = 0; |
2448 | 2461 |
2449 // Configure against https proxy server "proxy:70". | 2462 // Configure against https proxy server "proxy:70". |
2450 SessionDependencies session_deps(ProxyService::CreateFixed( | 2463 SessionDependencies session_deps(ProxyService::CreateFixed( |
2451 "https://proxy:70")); | 2464 "https://proxy:70")); |
2452 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 2465 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); |
2453 session_deps.net_log = log.bound().net_log(); | 2466 session_deps.net_log = log.bound().net_log(); |
(...skipping 17 matching lines...) Expand all Loading... |
2471 MockRead(ASYNC, 0, 4), | 2484 MockRead(ASYNC, 0, 4), |
2472 }; | 2485 }; |
2473 | 2486 |
2474 scoped_ptr<OrderedSocketData> spdy_data( | 2487 scoped_ptr<OrderedSocketData> spdy_data( |
2475 new OrderedSocketData( | 2488 new OrderedSocketData( |
2476 spdy_reads, arraysize(spdy_reads), | 2489 spdy_reads, arraysize(spdy_reads), |
2477 spdy_writes, arraysize(spdy_writes))); | 2490 spdy_writes, arraysize(spdy_writes))); |
2478 session_deps.socket_factory.AddSocketDataProvider(spdy_data.get()); | 2491 session_deps.socket_factory.AddSocketDataProvider(spdy_data.get()); |
2479 | 2492 |
2480 SSLSocketDataProvider ssl(ASYNC, OK); | 2493 SSLSocketDataProvider ssl(ASYNC, OK); |
2481 ssl.SetNextProto(SSLClientSocket::kProtoSPDY21); | 2494 ssl.SetNextProto(SSLClientSocket::kProtoSPDY2); |
2482 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 2495 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
2483 SSLSocketDataProvider ssl2(ASYNC, OK); | 2496 SSLSocketDataProvider ssl2(ASYNC, OK); |
2484 ssl2.SetNextProto(SSLClientSocket::kProtoSPDY21); | 2497 ssl2.SetNextProto(SSLClientSocket::kProtoSPDY2); |
2485 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl2); | 2498 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl2); |
2486 | 2499 |
2487 TestCompletionCallback callback1; | 2500 TestCompletionCallback callback1; |
2488 | 2501 |
2489 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 2502 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
2490 EXPECT_EQ(ERR_IO_PENDING, rv); | 2503 EXPECT_EQ(ERR_IO_PENDING, rv); |
2491 | 2504 |
2492 rv = callback1.WaitForResult(); | 2505 rv = callback1.WaitForResult(); |
2493 EXPECT_EQ(OK, rv); | 2506 EXPECT_EQ(OK, rv); |
2494 | 2507 |
2495 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2508 const HttpResponseInfo* response = trans->GetResponseInfo(); |
2496 ASSERT_TRUE(response != NULL); | 2509 ASSERT_TRUE(response != NULL); |
2497 EXPECT_EQ(500, response->headers->response_code()); | 2510 EXPECT_EQ(500, response->headers->response_code()); |
2498 } | 2511 } |
2499 | 2512 |
2500 // Test the challenge-response-retry sequence through an HTTPS Proxy | 2513 // Test the challenge-response-retry sequence through an HTTPS Proxy |
2501 TEST_F(HttpNetworkTransactionTest, HttpsProxyAuthRetry) { | 2514 TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxyAuthRetry) { |
2502 HttpRequestInfo request; | 2515 HttpRequestInfo request; |
2503 request.method = "GET"; | 2516 request.method = "GET"; |
2504 request.url = GURL("http://www.google.com/"); | 2517 request.url = GURL("http://www.google.com/"); |
2505 // when the no authentication data flag is set. | 2518 // when the no authentication data flag is set. |
2506 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; | 2519 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; |
2507 | 2520 |
2508 // Configure against https proxy server "myproxy:70". | 2521 // Configure against https proxy server "myproxy:70". |
2509 SessionDependencies session_deps( | 2522 SessionDependencies session_deps( |
2510 ProxyService::CreateFixed("https://myproxy:70")); | 2523 ProxyService::CreateFixed("https://myproxy:70")); |
2511 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 2524 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2578 | 2591 |
2579 EXPECT_TRUE(response->headers->IsKeepAlive()); | 2592 EXPECT_TRUE(response->headers->IsKeepAlive()); |
2580 EXPECT_EQ(200, response->headers->response_code()); | 2593 EXPECT_EQ(200, response->headers->response_code()); |
2581 EXPECT_EQ(100, response->headers->GetContentLength()); | 2594 EXPECT_EQ(100, response->headers->GetContentLength()); |
2582 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 2595 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
2583 | 2596 |
2584 // The password prompt info should not be set. | 2597 // The password prompt info should not be set. |
2585 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 2598 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
2586 } | 2599 } |
2587 | 2600 |
2588 void HttpNetworkTransactionTest::ConnectStatusHelperWithExpectedStatus( | 2601 void HttpNetworkTransactionSpdy2Test::ConnectStatusHelperWithExpectedStatus( |
2589 const MockRead& status, int expected_status) { | 2602 const MockRead& status, int expected_status) { |
2590 HttpRequestInfo request; | 2603 HttpRequestInfo request; |
2591 request.method = "GET"; | 2604 request.method = "GET"; |
2592 request.url = GURL("https://www.google.com/"); | 2605 request.url = GURL("https://www.google.com/"); |
2593 request.load_flags = 0; | 2606 request.load_flags = 0; |
2594 | 2607 |
2595 // Configure against proxy server "myproxy:70". | 2608 // Configure against proxy server "myproxy:70". |
2596 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 2609 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
2597 | 2610 |
2598 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 2611 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
(...skipping 20 matching lines...) Expand all Loading... |
2619 | 2632 |
2620 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 2633 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
2621 | 2634 |
2622 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 2635 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
2623 EXPECT_EQ(ERR_IO_PENDING, rv); | 2636 EXPECT_EQ(ERR_IO_PENDING, rv); |
2624 | 2637 |
2625 rv = callback.WaitForResult(); | 2638 rv = callback.WaitForResult(); |
2626 EXPECT_EQ(expected_status, rv); | 2639 EXPECT_EQ(expected_status, rv); |
2627 } | 2640 } |
2628 | 2641 |
2629 void HttpNetworkTransactionTest::ConnectStatusHelper(const MockRead& status) { | 2642 void HttpNetworkTransactionSpdy2Test::ConnectStatusHelper( |
| 2643 const MockRead& status) { |
2630 ConnectStatusHelperWithExpectedStatus( | 2644 ConnectStatusHelperWithExpectedStatus( |
2631 status, ERR_TUNNEL_CONNECTION_FAILED); | 2645 status, ERR_TUNNEL_CONNECTION_FAILED); |
2632 } | 2646 } |
2633 | 2647 |
2634 TEST_F(HttpNetworkTransactionTest, ConnectStatus100) { | 2648 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus100) { |
2635 ConnectStatusHelper(MockRead("HTTP/1.1 100 Continue\r\n")); | 2649 ConnectStatusHelper(MockRead("HTTP/1.1 100 Continue\r\n")); |
2636 } | 2650 } |
2637 | 2651 |
2638 TEST_F(HttpNetworkTransactionTest, ConnectStatus101) { | 2652 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus101) { |
2639 ConnectStatusHelper(MockRead("HTTP/1.1 101 Switching Protocols\r\n")); | 2653 ConnectStatusHelper(MockRead("HTTP/1.1 101 Switching Protocols\r\n")); |
2640 } | 2654 } |
2641 | 2655 |
2642 TEST_F(HttpNetworkTransactionTest, ConnectStatus201) { | 2656 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus201) { |
2643 ConnectStatusHelper(MockRead("HTTP/1.1 201 Created\r\n")); | 2657 ConnectStatusHelper(MockRead("HTTP/1.1 201 Created\r\n")); |
2644 } | 2658 } |
2645 | 2659 |
2646 TEST_F(HttpNetworkTransactionTest, ConnectStatus202) { | 2660 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus202) { |
2647 ConnectStatusHelper(MockRead("HTTP/1.1 202 Accepted\r\n")); | 2661 ConnectStatusHelper(MockRead("HTTP/1.1 202 Accepted\r\n")); |
2648 } | 2662 } |
2649 | 2663 |
2650 TEST_F(HttpNetworkTransactionTest, ConnectStatus203) { | 2664 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus203) { |
2651 ConnectStatusHelper( | 2665 ConnectStatusHelper( |
2652 MockRead("HTTP/1.1 203 Non-Authoritative Information\r\n")); | 2666 MockRead("HTTP/1.1 203 Non-Authoritative Information\r\n")); |
2653 } | 2667 } |
2654 | 2668 |
2655 TEST_F(HttpNetworkTransactionTest, ConnectStatus204) { | 2669 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus204) { |
2656 ConnectStatusHelper(MockRead("HTTP/1.1 204 No Content\r\n")); | 2670 ConnectStatusHelper(MockRead("HTTP/1.1 204 No Content\r\n")); |
2657 } | 2671 } |
2658 | 2672 |
2659 TEST_F(HttpNetworkTransactionTest, ConnectStatus205) { | 2673 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus205) { |
2660 ConnectStatusHelper(MockRead("HTTP/1.1 205 Reset Content\r\n")); | 2674 ConnectStatusHelper(MockRead("HTTP/1.1 205 Reset Content\r\n")); |
2661 } | 2675 } |
2662 | 2676 |
2663 TEST_F(HttpNetworkTransactionTest, ConnectStatus206) { | 2677 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus206) { |
2664 ConnectStatusHelper(MockRead("HTTP/1.1 206 Partial Content\r\n")); | 2678 ConnectStatusHelper(MockRead("HTTP/1.1 206 Partial Content\r\n")); |
2665 } | 2679 } |
2666 | 2680 |
2667 TEST_F(HttpNetworkTransactionTest, ConnectStatus300) { | 2681 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus300) { |
2668 ConnectStatusHelper(MockRead("HTTP/1.1 300 Multiple Choices\r\n")); | 2682 ConnectStatusHelper(MockRead("HTTP/1.1 300 Multiple Choices\r\n")); |
2669 } | 2683 } |
2670 | 2684 |
2671 TEST_F(HttpNetworkTransactionTest, ConnectStatus301) { | 2685 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus301) { |
2672 ConnectStatusHelper(MockRead("HTTP/1.1 301 Moved Permanently\r\n")); | 2686 ConnectStatusHelper(MockRead("HTTP/1.1 301 Moved Permanently\r\n")); |
2673 } | 2687 } |
2674 | 2688 |
2675 TEST_F(HttpNetworkTransactionTest, ConnectStatus302) { | 2689 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus302) { |
2676 ConnectStatusHelper(MockRead("HTTP/1.1 302 Found\r\n")); | 2690 ConnectStatusHelper(MockRead("HTTP/1.1 302 Found\r\n")); |
2677 } | 2691 } |
2678 | 2692 |
2679 TEST_F(HttpNetworkTransactionTest, ConnectStatus303) { | 2693 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus303) { |
2680 ConnectStatusHelper(MockRead("HTTP/1.1 303 See Other\r\n")); | 2694 ConnectStatusHelper(MockRead("HTTP/1.1 303 See Other\r\n")); |
2681 } | 2695 } |
2682 | 2696 |
2683 TEST_F(HttpNetworkTransactionTest, ConnectStatus304) { | 2697 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus304) { |
2684 ConnectStatusHelper(MockRead("HTTP/1.1 304 Not Modified\r\n")); | 2698 ConnectStatusHelper(MockRead("HTTP/1.1 304 Not Modified\r\n")); |
2685 } | 2699 } |
2686 | 2700 |
2687 TEST_F(HttpNetworkTransactionTest, ConnectStatus305) { | 2701 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus305) { |
2688 ConnectStatusHelper(MockRead("HTTP/1.1 305 Use Proxy\r\n")); | 2702 ConnectStatusHelper(MockRead("HTTP/1.1 305 Use Proxy\r\n")); |
2689 } | 2703 } |
2690 | 2704 |
2691 TEST_F(HttpNetworkTransactionTest, ConnectStatus306) { | 2705 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus306) { |
2692 ConnectStatusHelper(MockRead("HTTP/1.1 306\r\n")); | 2706 ConnectStatusHelper(MockRead("HTTP/1.1 306\r\n")); |
2693 } | 2707 } |
2694 | 2708 |
2695 TEST_F(HttpNetworkTransactionTest, ConnectStatus307) { | 2709 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus307) { |
2696 ConnectStatusHelper(MockRead("HTTP/1.1 307 Temporary Redirect\r\n")); | 2710 ConnectStatusHelper(MockRead("HTTP/1.1 307 Temporary Redirect\r\n")); |
2697 } | 2711 } |
2698 | 2712 |
2699 TEST_F(HttpNetworkTransactionTest, ConnectStatus400) { | 2713 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus400) { |
2700 ConnectStatusHelper(MockRead("HTTP/1.1 400 Bad Request\r\n")); | 2714 ConnectStatusHelper(MockRead("HTTP/1.1 400 Bad Request\r\n")); |
2701 } | 2715 } |
2702 | 2716 |
2703 TEST_F(HttpNetworkTransactionTest, ConnectStatus401) { | 2717 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus401) { |
2704 ConnectStatusHelper(MockRead("HTTP/1.1 401 Unauthorized\r\n")); | 2718 ConnectStatusHelper(MockRead("HTTP/1.1 401 Unauthorized\r\n")); |
2705 } | 2719 } |
2706 | 2720 |
2707 TEST_F(HttpNetworkTransactionTest, ConnectStatus402) { | 2721 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus402) { |
2708 ConnectStatusHelper(MockRead("HTTP/1.1 402 Payment Required\r\n")); | 2722 ConnectStatusHelper(MockRead("HTTP/1.1 402 Payment Required\r\n")); |
2709 } | 2723 } |
2710 | 2724 |
2711 TEST_F(HttpNetworkTransactionTest, ConnectStatus403) { | 2725 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus403) { |
2712 ConnectStatusHelper(MockRead("HTTP/1.1 403 Forbidden\r\n")); | 2726 ConnectStatusHelper(MockRead("HTTP/1.1 403 Forbidden\r\n")); |
2713 } | 2727 } |
2714 | 2728 |
2715 TEST_F(HttpNetworkTransactionTest, ConnectStatus404) { | 2729 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus404) { |
2716 ConnectStatusHelper(MockRead("HTTP/1.1 404 Not Found\r\n")); | 2730 ConnectStatusHelper(MockRead("HTTP/1.1 404 Not Found\r\n")); |
2717 } | 2731 } |
2718 | 2732 |
2719 TEST_F(HttpNetworkTransactionTest, ConnectStatus405) { | 2733 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus405) { |
2720 ConnectStatusHelper(MockRead("HTTP/1.1 405 Method Not Allowed\r\n")); | 2734 ConnectStatusHelper(MockRead("HTTP/1.1 405 Method Not Allowed\r\n")); |
2721 } | 2735 } |
2722 | 2736 |
2723 TEST_F(HttpNetworkTransactionTest, ConnectStatus406) { | 2737 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus406) { |
2724 ConnectStatusHelper(MockRead("HTTP/1.1 406 Not Acceptable\r\n")); | 2738 ConnectStatusHelper(MockRead("HTTP/1.1 406 Not Acceptable\r\n")); |
2725 } | 2739 } |
2726 | 2740 |
2727 TEST_F(HttpNetworkTransactionTest, ConnectStatus407) { | 2741 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus407) { |
2728 ConnectStatusHelperWithExpectedStatus( | 2742 ConnectStatusHelperWithExpectedStatus( |
2729 MockRead("HTTP/1.1 407 Proxy Authentication Required\r\n"), | 2743 MockRead("HTTP/1.1 407 Proxy Authentication Required\r\n"), |
2730 ERR_PROXY_AUTH_UNSUPPORTED); | 2744 ERR_PROXY_AUTH_UNSUPPORTED); |
2731 } | 2745 } |
2732 | 2746 |
2733 TEST_F(HttpNetworkTransactionTest, ConnectStatus408) { | 2747 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus408) { |
2734 ConnectStatusHelper(MockRead("HTTP/1.1 408 Request Timeout\r\n")); | 2748 ConnectStatusHelper(MockRead("HTTP/1.1 408 Request Timeout\r\n")); |
2735 } | 2749 } |
2736 | 2750 |
2737 TEST_F(HttpNetworkTransactionTest, ConnectStatus409) { | 2751 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus409) { |
2738 ConnectStatusHelper(MockRead("HTTP/1.1 409 Conflict\r\n")); | 2752 ConnectStatusHelper(MockRead("HTTP/1.1 409 Conflict\r\n")); |
2739 } | 2753 } |
2740 | 2754 |
2741 TEST_F(HttpNetworkTransactionTest, ConnectStatus410) { | 2755 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus410) { |
2742 ConnectStatusHelper(MockRead("HTTP/1.1 410 Gone\r\n")); | 2756 ConnectStatusHelper(MockRead("HTTP/1.1 410 Gone\r\n")); |
2743 } | 2757 } |
2744 | 2758 |
2745 TEST_F(HttpNetworkTransactionTest, ConnectStatus411) { | 2759 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus411) { |
2746 ConnectStatusHelper(MockRead("HTTP/1.1 411 Length Required\r\n")); | 2760 ConnectStatusHelper(MockRead("HTTP/1.1 411 Length Required\r\n")); |
2747 } | 2761 } |
2748 | 2762 |
2749 TEST_F(HttpNetworkTransactionTest, ConnectStatus412) { | 2763 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus412) { |
2750 ConnectStatusHelper(MockRead("HTTP/1.1 412 Precondition Failed\r\n")); | 2764 ConnectStatusHelper(MockRead("HTTP/1.1 412 Precondition Failed\r\n")); |
2751 } | 2765 } |
2752 | 2766 |
2753 TEST_F(HttpNetworkTransactionTest, ConnectStatus413) { | 2767 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus413) { |
2754 ConnectStatusHelper(MockRead("HTTP/1.1 413 Request Entity Too Large\r\n")); | 2768 ConnectStatusHelper(MockRead("HTTP/1.1 413 Request Entity Too Large\r\n")); |
2755 } | 2769 } |
2756 | 2770 |
2757 TEST_F(HttpNetworkTransactionTest, ConnectStatus414) { | 2771 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus414) { |
2758 ConnectStatusHelper(MockRead("HTTP/1.1 414 Request-URI Too Long\r\n")); | 2772 ConnectStatusHelper(MockRead("HTTP/1.1 414 Request-URI Too Long\r\n")); |
2759 } | 2773 } |
2760 | 2774 |
2761 TEST_F(HttpNetworkTransactionTest, ConnectStatus415) { | 2775 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus415) { |
2762 ConnectStatusHelper(MockRead("HTTP/1.1 415 Unsupported Media Type\r\n")); | 2776 ConnectStatusHelper(MockRead("HTTP/1.1 415 Unsupported Media Type\r\n")); |
2763 } | 2777 } |
2764 | 2778 |
2765 TEST_F(HttpNetworkTransactionTest, ConnectStatus416) { | 2779 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus416) { |
2766 ConnectStatusHelper( | 2780 ConnectStatusHelper( |
2767 MockRead("HTTP/1.1 416 Requested Range Not Satisfiable\r\n")); | 2781 MockRead("HTTP/1.1 416 Requested Range Not Satisfiable\r\n")); |
2768 } | 2782 } |
2769 | 2783 |
2770 TEST_F(HttpNetworkTransactionTest, ConnectStatus417) { | 2784 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus417) { |
2771 ConnectStatusHelper(MockRead("HTTP/1.1 417 Expectation Failed\r\n")); | 2785 ConnectStatusHelper(MockRead("HTTP/1.1 417 Expectation Failed\r\n")); |
2772 } | 2786 } |
2773 | 2787 |
2774 TEST_F(HttpNetworkTransactionTest, ConnectStatus500) { | 2788 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus500) { |
2775 ConnectStatusHelper(MockRead("HTTP/1.1 500 Internal Server Error\r\n")); | 2789 ConnectStatusHelper(MockRead("HTTP/1.1 500 Internal Server Error\r\n")); |
2776 } | 2790 } |
2777 | 2791 |
2778 TEST_F(HttpNetworkTransactionTest, ConnectStatus501) { | 2792 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus501) { |
2779 ConnectStatusHelper(MockRead("HTTP/1.1 501 Not Implemented\r\n")); | 2793 ConnectStatusHelper(MockRead("HTTP/1.1 501 Not Implemented\r\n")); |
2780 } | 2794 } |
2781 | 2795 |
2782 TEST_F(HttpNetworkTransactionTest, ConnectStatus502) { | 2796 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus502) { |
2783 ConnectStatusHelper(MockRead("HTTP/1.1 502 Bad Gateway\r\n")); | 2797 ConnectStatusHelper(MockRead("HTTP/1.1 502 Bad Gateway\r\n")); |
2784 } | 2798 } |
2785 | 2799 |
2786 TEST_F(HttpNetworkTransactionTest, ConnectStatus503) { | 2800 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus503) { |
2787 ConnectStatusHelper(MockRead("HTTP/1.1 503 Service Unavailable\r\n")); | 2801 ConnectStatusHelper(MockRead("HTTP/1.1 503 Service Unavailable\r\n")); |
2788 } | 2802 } |
2789 | 2803 |
2790 TEST_F(HttpNetworkTransactionTest, ConnectStatus504) { | 2804 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus504) { |
2791 ConnectStatusHelper(MockRead("HTTP/1.1 504 Gateway Timeout\r\n")); | 2805 ConnectStatusHelper(MockRead("HTTP/1.1 504 Gateway Timeout\r\n")); |
2792 } | 2806 } |
2793 | 2807 |
2794 TEST_F(HttpNetworkTransactionTest, ConnectStatus505) { | 2808 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectStatus505) { |
2795 ConnectStatusHelper(MockRead("HTTP/1.1 505 HTTP Version Not Supported\r\n")); | 2809 ConnectStatusHelper(MockRead("HTTP/1.1 505 HTTP Version Not Supported\r\n")); |
2796 } | 2810 } |
2797 | 2811 |
2798 // Test the flow when both the proxy server AND origin server require | 2812 // Test the flow when both the proxy server AND origin server require |
2799 // authentication. Again, this uses basic auth for both since that is | 2813 // authentication. Again, this uses basic auth for both since that is |
2800 // the simplest to mock. | 2814 // the simplest to mock. |
2801 TEST_F(HttpNetworkTransactionTest, BasicAuthProxyThenServer) { | 2815 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthProxyThenServer) { |
2802 HttpRequestInfo request; | 2816 HttpRequestInfo request; |
2803 request.method = "GET"; | 2817 request.method = "GET"; |
2804 request.url = GURL("http://www.google.com/"); | 2818 request.url = GURL("http://www.google.com/"); |
2805 request.load_flags = 0; | 2819 request.load_flags = 0; |
2806 | 2820 |
2807 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 2821 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
2808 | 2822 |
2809 // Configure against proxy server "myproxy:70". | 2823 // Configure against proxy server "myproxy:70". |
2810 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction( | 2824 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction( |
2811 CreateSession(&session_deps))); | 2825 CreateSession(&session_deps))); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2920 | 2934 |
2921 // For the NTLM implementation using SSPI, we skip the NTLM tests since we | 2935 // For the NTLM implementation using SSPI, we skip the NTLM tests since we |
2922 // can't hook into its internals to cause it to generate predictable NTLM | 2936 // can't hook into its internals to cause it to generate predictable NTLM |
2923 // authorization headers. | 2937 // authorization headers. |
2924 #if defined(NTLM_PORTABLE) | 2938 #if defined(NTLM_PORTABLE) |
2925 // The NTLM authentication unit tests were generated by capturing the HTTP | 2939 // The NTLM authentication unit tests were generated by capturing the HTTP |
2926 // requests and responses using Fiddler 2 and inspecting the generated random | 2940 // requests and responses using Fiddler 2 and inspecting the generated random |
2927 // bytes in the debugger. | 2941 // bytes in the debugger. |
2928 | 2942 |
2929 // Enter the correct password and authenticate successfully. | 2943 // Enter the correct password and authenticate successfully. |
2930 TEST_F(HttpNetworkTransactionTest, NTLMAuth1) { | 2944 TEST_F(HttpNetworkTransactionSpdy2Test, NTLMAuth1) { |
2931 HttpRequestInfo request; | 2945 HttpRequestInfo request; |
2932 request.method = "GET"; | 2946 request.method = "GET"; |
2933 request.url = GURL("http://172.22.68.17/kids/login.aspx"); | 2947 request.url = GURL("http://172.22.68.17/kids/login.aspx"); |
2934 request.load_flags = 0; | 2948 request.load_flags = 0; |
2935 | 2949 |
2936 HttpAuthHandlerNTLM::ScopedProcSetter proc_setter(MockGenerateRandom1, | 2950 HttpAuthHandlerNTLM::ScopedProcSetter proc_setter(MockGenerateRandom1, |
2937 MockGetHostName); | 2951 MockGetHostName); |
2938 SessionDependencies session_deps; | 2952 SessionDependencies session_deps; |
2939 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 2953 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
2940 | 2954 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3049 rv = callback3.WaitForResult(); | 3063 rv = callback3.WaitForResult(); |
3050 EXPECT_EQ(OK, rv); | 3064 EXPECT_EQ(OK, rv); |
3051 | 3065 |
3052 response = trans->GetResponseInfo(); | 3066 response = trans->GetResponseInfo(); |
3053 ASSERT_TRUE(response != NULL); | 3067 ASSERT_TRUE(response != NULL); |
3054 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 3068 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
3055 EXPECT_EQ(13, response->headers->GetContentLength()); | 3069 EXPECT_EQ(13, response->headers->GetContentLength()); |
3056 } | 3070 } |
3057 | 3071 |
3058 // Enter a wrong password, and then the correct one. | 3072 // Enter a wrong password, and then the correct one. |
3059 TEST_F(HttpNetworkTransactionTest, NTLMAuth2) { | 3073 TEST_F(HttpNetworkTransactionSpdy2Test, NTLMAuth2) { |
3060 HttpRequestInfo request; | 3074 HttpRequestInfo request; |
3061 request.method = "GET"; | 3075 request.method = "GET"; |
3062 request.url = GURL("http://172.22.68.17/kids/login.aspx"); | 3076 request.url = GURL("http://172.22.68.17/kids/login.aspx"); |
3063 request.load_flags = 0; | 3077 request.load_flags = 0; |
3064 | 3078 |
3065 HttpAuthHandlerNTLM::ScopedProcSetter proc_setter(MockGenerateRandom2, | 3079 HttpAuthHandlerNTLM::ScopedProcSetter proc_setter(MockGenerateRandom2, |
3066 MockGetHostName); | 3080 MockGetHostName); |
3067 SessionDependencies session_deps; | 3081 SessionDependencies session_deps; |
3068 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 3082 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
3069 | 3083 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3251 | 3265 |
3252 response = trans->GetResponseInfo(); | 3266 response = trans->GetResponseInfo(); |
3253 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 3267 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
3254 EXPECT_EQ(13, response->headers->GetContentLength()); | 3268 EXPECT_EQ(13, response->headers->GetContentLength()); |
3255 } | 3269 } |
3256 #endif // NTLM_PORTABLE | 3270 #endif // NTLM_PORTABLE |
3257 | 3271 |
3258 // Test reading a server response which has only headers, and no body. | 3272 // Test reading a server response which has only headers, and no body. |
3259 // After some maximum number of bytes is consumed, the transaction should | 3273 // After some maximum number of bytes is consumed, the transaction should |
3260 // fail with ERR_RESPONSE_HEADERS_TOO_BIG. | 3274 // fail with ERR_RESPONSE_HEADERS_TOO_BIG. |
3261 TEST_F(HttpNetworkTransactionTest, LargeHeadersNoBody) { | 3275 TEST_F(HttpNetworkTransactionSpdy2Test, LargeHeadersNoBody) { |
3262 HttpRequestInfo request; | 3276 HttpRequestInfo request; |
3263 request.method = "GET"; | 3277 request.method = "GET"; |
3264 request.url = GURL("http://www.google.com/"); | 3278 request.url = GURL("http://www.google.com/"); |
3265 request.load_flags = 0; | 3279 request.load_flags = 0; |
3266 | 3280 |
3267 SessionDependencies session_deps; | 3281 SessionDependencies session_deps; |
3268 scoped_ptr<HttpTransaction> trans( | 3282 scoped_ptr<HttpTransaction> trans( |
3269 new HttpNetworkTransaction(CreateSession(&session_deps))); | 3283 new HttpNetworkTransaction(CreateSession(&session_deps))); |
3270 | 3284 |
3271 // Respond with 300 kb of headers (we should fail after 256 kb). | 3285 // Respond with 300 kb of headers (we should fail after 256 kb). |
(...skipping 17 matching lines...) Expand all Loading... |
3289 rv = callback.WaitForResult(); | 3303 rv = callback.WaitForResult(); |
3290 EXPECT_EQ(ERR_RESPONSE_HEADERS_TOO_BIG, rv); | 3304 EXPECT_EQ(ERR_RESPONSE_HEADERS_TOO_BIG, rv); |
3291 | 3305 |
3292 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3306 const HttpResponseInfo* response = trans->GetResponseInfo(); |
3293 EXPECT_TRUE(response == NULL); | 3307 EXPECT_TRUE(response == NULL); |
3294 } | 3308 } |
3295 | 3309 |
3296 // Make sure that we don't try to reuse a TCPClientSocket when failing to | 3310 // Make sure that we don't try to reuse a TCPClientSocket when failing to |
3297 // establish tunnel. | 3311 // establish tunnel. |
3298 // http://code.google.com/p/chromium/issues/detail?id=3772 | 3312 // http://code.google.com/p/chromium/issues/detail?id=3772 |
3299 TEST_F(HttpNetworkTransactionTest, DontRecycleTransportSocketForSSLTunnel) { | 3313 TEST_F(HttpNetworkTransactionSpdy2Test, |
| 3314 DontRecycleTransportSocketForSSLTunnel) { |
3300 HttpRequestInfo request; | 3315 HttpRequestInfo request; |
3301 request.method = "GET"; | 3316 request.method = "GET"; |
3302 request.url = GURL("https://www.google.com/"); | 3317 request.url = GURL("https://www.google.com/"); |
3303 request.load_flags = 0; | 3318 request.load_flags = 0; |
3304 | 3319 |
3305 // Configure against proxy server "myproxy:70". | 3320 // Configure against proxy server "myproxy:70". |
3306 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 3321 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
3307 | 3322 |
3308 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 3323 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
3309 | 3324 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3347 // We now check to make sure the TCPClientSocket was not added back to | 3362 // We now check to make sure the TCPClientSocket was not added back to |
3348 // the pool. | 3363 // the pool. |
3349 EXPECT_EQ(0, session->GetTransportSocketPool()->IdleSocketCount()); | 3364 EXPECT_EQ(0, session->GetTransportSocketPool()->IdleSocketCount()); |
3350 trans.reset(); | 3365 trans.reset(); |
3351 MessageLoop::current()->RunAllPending(); | 3366 MessageLoop::current()->RunAllPending(); |
3352 // Make sure that the socket didn't get recycled after calling the destructor. | 3367 // Make sure that the socket didn't get recycled after calling the destructor. |
3353 EXPECT_EQ(0, session->GetTransportSocketPool()->IdleSocketCount()); | 3368 EXPECT_EQ(0, session->GetTransportSocketPool()->IdleSocketCount()); |
3354 } | 3369 } |
3355 | 3370 |
3356 // Make sure that we recycle a socket after reading all of the response body. | 3371 // Make sure that we recycle a socket after reading all of the response body. |
3357 TEST_F(HttpNetworkTransactionTest, RecycleSocket) { | 3372 TEST_F(HttpNetworkTransactionSpdy2Test, RecycleSocket) { |
3358 HttpRequestInfo request; | 3373 HttpRequestInfo request; |
3359 request.method = "GET"; | 3374 request.method = "GET"; |
3360 request.url = GURL("http://www.google.com/"); | 3375 request.url = GURL("http://www.google.com/"); |
3361 request.load_flags = 0; | 3376 request.load_flags = 0; |
3362 | 3377 |
3363 SessionDependencies session_deps; | 3378 SessionDependencies session_deps; |
3364 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 3379 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
3365 | 3380 |
3366 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 3381 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
3367 | 3382 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3403 // Empty the current queue. This is necessary because idle sockets are | 3418 // Empty the current queue. This is necessary because idle sockets are |
3404 // added to the connection pool asynchronously with a PostTask. | 3419 // added to the connection pool asynchronously with a PostTask. |
3405 MessageLoop::current()->RunAllPending(); | 3420 MessageLoop::current()->RunAllPending(); |
3406 | 3421 |
3407 // We now check to make sure the socket was added back to the pool. | 3422 // We now check to make sure the socket was added back to the pool. |
3408 EXPECT_EQ(1, session->GetTransportSocketPool()->IdleSocketCount()); | 3423 EXPECT_EQ(1, session->GetTransportSocketPool()->IdleSocketCount()); |
3409 } | 3424 } |
3410 | 3425 |
3411 // Make sure that we recycle a SSL socket after reading all of the response | 3426 // Make sure that we recycle a SSL socket after reading all of the response |
3412 // body. | 3427 // body. |
3413 TEST_F(HttpNetworkTransactionTest, RecycleSSLSocket) { | 3428 TEST_F(HttpNetworkTransactionSpdy2Test, RecycleSSLSocket) { |
3414 SessionDependencies session_deps; | 3429 SessionDependencies session_deps; |
3415 HttpRequestInfo request; | 3430 HttpRequestInfo request; |
3416 request.method = "GET"; | 3431 request.method = "GET"; |
3417 request.url = GURL("https://www.google.com/"); | 3432 request.url = GURL("https://www.google.com/"); |
3418 request.load_flags = 0; | 3433 request.load_flags = 0; |
3419 | 3434 |
3420 MockWrite data_writes[] = { | 3435 MockWrite data_writes[] = { |
3421 MockWrite("GET / HTTP/1.1\r\n" | 3436 MockWrite("GET / HTTP/1.1\r\n" |
3422 "Host: www.google.com\r\n" | 3437 "Host: www.google.com\r\n" |
3423 "Connection: keep-alive\r\n\r\n"), | 3438 "Connection: keep-alive\r\n\r\n"), |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3462 // Empty the current queue. This is necessary because idle sockets are | 3477 // Empty the current queue. This is necessary because idle sockets are |
3463 // added to the connection pool asynchronously with a PostTask. | 3478 // added to the connection pool asynchronously with a PostTask. |
3464 MessageLoop::current()->RunAllPending(); | 3479 MessageLoop::current()->RunAllPending(); |
3465 | 3480 |
3466 // We now check to make sure the socket was added back to the pool. | 3481 // We now check to make sure the socket was added back to the pool. |
3467 EXPECT_EQ(1, session->GetSSLSocketPool()->IdleSocketCount()); | 3482 EXPECT_EQ(1, session->GetSSLSocketPool()->IdleSocketCount()); |
3468 } | 3483 } |
3469 | 3484 |
3470 // Grab a SSL socket, use it, and put it back into the pool. Then, reuse it | 3485 // Grab a SSL socket, use it, and put it back into the pool. Then, reuse it |
3471 // from the pool and make sure that we recover okay. | 3486 // from the pool and make sure that we recover okay. |
3472 TEST_F(HttpNetworkTransactionTest, RecycleDeadSSLSocket) { | 3487 TEST_F(HttpNetworkTransactionSpdy2Test, RecycleDeadSSLSocket) { |
3473 SessionDependencies session_deps; | 3488 SessionDependencies session_deps; |
3474 HttpRequestInfo request; | 3489 HttpRequestInfo request; |
3475 request.method = "GET"; | 3490 request.method = "GET"; |
3476 request.url = GURL("https://www.google.com/"); | 3491 request.url = GURL("https://www.google.com/"); |
3477 request.load_flags = 0; | 3492 request.load_flags = 0; |
3478 | 3493 |
3479 MockWrite data_writes[] = { | 3494 MockWrite data_writes[] = { |
3480 MockWrite("GET / HTTP/1.1\r\n" | 3495 MockWrite("GET / HTTP/1.1\r\n" |
3481 "Host: www.google.com\r\n" | 3496 "Host: www.google.com\r\n" |
3482 "Connection: keep-alive\r\n\r\n"), | 3497 "Connection: keep-alive\r\n\r\n"), |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3557 // Empty the current queue. This is necessary because idle sockets are | 3572 // Empty the current queue. This is necessary because idle sockets are |
3558 // added to the connection pool asynchronously with a PostTask. | 3573 // added to the connection pool asynchronously with a PostTask. |
3559 MessageLoop::current()->RunAllPending(); | 3574 MessageLoop::current()->RunAllPending(); |
3560 | 3575 |
3561 // We now check to make sure the socket was added back to the pool. | 3576 // We now check to make sure the socket was added back to the pool. |
3562 EXPECT_EQ(1, session->GetSSLSocketPool()->IdleSocketCount()); | 3577 EXPECT_EQ(1, session->GetSSLSocketPool()->IdleSocketCount()); |
3563 } | 3578 } |
3564 | 3579 |
3565 // Make sure that we recycle a socket after a zero-length response. | 3580 // Make sure that we recycle a socket after a zero-length response. |
3566 // http://crbug.com/9880 | 3581 // http://crbug.com/9880 |
3567 TEST_F(HttpNetworkTransactionTest, RecycleSocketAfterZeroContentLength) { | 3582 TEST_F(HttpNetworkTransactionSpdy2Test, RecycleSocketAfterZeroContentLength) { |
3568 HttpRequestInfo request; | 3583 HttpRequestInfo request; |
3569 request.method = "GET"; | 3584 request.method = "GET"; |
3570 request.url = GURL("http://www.google.com/csi?v=3&s=web&action=&" | 3585 request.url = GURL("http://www.google.com/csi?v=3&s=web&action=&" |
3571 "tran=undefined&ei=mAXcSeegAo-SMurloeUN&" | 3586 "tran=undefined&ei=mAXcSeegAo-SMurloeUN&" |
3572 "e=17259,18167,19592,19773,19981,20133,20173,20233&" | 3587 "e=17259,18167,19592,19773,19981,20133,20173,20233&" |
3573 "rt=prt.2642,ol.2649,xjs.2951"); | 3588 "rt=prt.2642,ol.2649,xjs.2951"); |
3574 request.load_flags = 0; | 3589 request.load_flags = 0; |
3575 | 3590 |
3576 SessionDependencies session_deps; | 3591 SessionDependencies session_deps; |
3577 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 3592 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3612 EXPECT_EQ("", response_data); | 3627 EXPECT_EQ("", response_data); |
3613 | 3628 |
3614 // Empty the current queue. This is necessary because idle sockets are | 3629 // Empty the current queue. This is necessary because idle sockets are |
3615 // added to the connection pool asynchronously with a PostTask. | 3630 // added to the connection pool asynchronously with a PostTask. |
3616 MessageLoop::current()->RunAllPending(); | 3631 MessageLoop::current()->RunAllPending(); |
3617 | 3632 |
3618 // We now check to make sure the socket was added back to the pool. | 3633 // We now check to make sure the socket was added back to the pool. |
3619 EXPECT_EQ(1, session->GetTransportSocketPool()->IdleSocketCount()); | 3634 EXPECT_EQ(1, session->GetTransportSocketPool()->IdleSocketCount()); |
3620 } | 3635 } |
3621 | 3636 |
3622 TEST_F(HttpNetworkTransactionTest, ResendRequestOnWriteBodyError) { | 3637 TEST_F(HttpNetworkTransactionSpdy2Test, ResendRequestOnWriteBodyError) { |
3623 HttpRequestInfo request[2]; | 3638 HttpRequestInfo request[2]; |
3624 // Transaction 1: a GET request that succeeds. The socket is recycled | 3639 // Transaction 1: a GET request that succeeds. The socket is recycled |
3625 // after use. | 3640 // after use. |
3626 request[0].method = "GET"; | 3641 request[0].method = "GET"; |
3627 request[0].url = GURL("http://www.google.com/"); | 3642 request[0].url = GURL("http://www.google.com/"); |
3628 request[0].load_flags = 0; | 3643 request[0].load_flags = 0; |
3629 // Transaction 2: a POST request. Reuses the socket kept alive from | 3644 // Transaction 2: a POST request. Reuses the socket kept alive from |
3630 // transaction 1. The first attempts fails when writing the POST data. | 3645 // transaction 1. The first attempts fails when writing the POST data. |
3631 // This causes the transaction to retry with a new socket. The second | 3646 // This causes the transaction to retry with a new socket. The second |
3632 // attempt succeeds. | 3647 // attempt succeeds. |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3702 std::string response_data; | 3717 std::string response_data; |
3703 rv = ReadTransaction(trans.get(), &response_data); | 3718 rv = ReadTransaction(trans.get(), &response_data); |
3704 EXPECT_EQ(OK, rv); | 3719 EXPECT_EQ(OK, rv); |
3705 EXPECT_EQ(kExpectedResponseData[i], response_data); | 3720 EXPECT_EQ(kExpectedResponseData[i], response_data); |
3706 } | 3721 } |
3707 } | 3722 } |
3708 | 3723 |
3709 // Test the request-challenge-retry sequence for basic auth when there is | 3724 // Test the request-challenge-retry sequence for basic auth when there is |
3710 // an identity in the URL. The request should be sent as normal, but when | 3725 // an identity in the URL. The request should be sent as normal, but when |
3711 // it fails the identity from the URL is no longer used. | 3726 // it fails the identity from the URL is no longer used. |
3712 TEST_F(HttpNetworkTransactionTest, IgnoreAuthIdentityInURL) { | 3727 TEST_F(HttpNetworkTransactionSpdy2Test, IgnoreAuthIdentityInURL) { |
3713 HttpRequestInfo request; | 3728 HttpRequestInfo request; |
3714 request.method = "GET"; | 3729 request.method = "GET"; |
3715 request.url = GURL("http://foo:b@r@www.google.com/"); | 3730 request.url = GURL("http://foo:b@r@www.google.com/"); |
3716 request.load_flags = LOAD_NORMAL; | 3731 request.load_flags = LOAD_NORMAL; |
3717 | 3732 |
3718 SessionDependencies session_deps; | 3733 SessionDependencies session_deps; |
3719 scoped_ptr<HttpTransaction> trans( | 3734 scoped_ptr<HttpTransaction> trans( |
3720 new HttpNetworkTransaction(CreateSession(&session_deps))); | 3735 new HttpNetworkTransaction(CreateSession(&session_deps))); |
3721 | 3736 |
3722 // The password contains an escaped character -- for this test to pass it | 3737 // The password contains an escaped character -- for this test to pass it |
(...skipping 22 matching lines...) Expand all Loading... |
3745 EXPECT_EQ(ERR_IO_PENDING, rv); | 3760 EXPECT_EQ(ERR_IO_PENDING, rv); |
3746 rv = callback1.WaitForResult(); | 3761 rv = callback1.WaitForResult(); |
3747 EXPECT_EQ(OK, rv); | 3762 EXPECT_EQ(OK, rv); |
3748 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 3763 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
3749 | 3764 |
3750 // Empty the current queue. | 3765 // Empty the current queue. |
3751 MessageLoop::current()->RunAllPending(); | 3766 MessageLoop::current()->RunAllPending(); |
3752 } | 3767 } |
3753 | 3768 |
3754 // Test that previously tried username/passwords for a realm get re-used. | 3769 // Test that previously tried username/passwords for a realm get re-used. |
3755 TEST_F(HttpNetworkTransactionTest, BasicAuthCacheAndPreauth) { | 3770 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthCacheAndPreauth) { |
3756 SessionDependencies session_deps; | 3771 SessionDependencies session_deps; |
3757 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 3772 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
3758 | 3773 |
3759 // Transaction 1: authenticate (foo, bar) on MyRealm1 | 3774 // Transaction 1: authenticate (foo, bar) on MyRealm1 |
3760 { | 3775 { |
3761 HttpRequestInfo request; | 3776 HttpRequestInfo request; |
3762 request.method = "GET"; | 3777 request.method = "GET"; |
3763 request.url = GURL("http://www.google.com/x/y/z"); | 3778 request.url = GURL("http://www.google.com/x/y/z"); |
3764 request.load_flags = 0; | 3779 request.load_flags = 0; |
3765 | 3780 |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4125 | 4140 |
4126 response = trans->GetResponseInfo(); | 4141 response = trans->GetResponseInfo(); |
4127 ASSERT_TRUE(response != NULL); | 4142 ASSERT_TRUE(response != NULL); |
4128 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 4143 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
4129 EXPECT_EQ(100, response->headers->GetContentLength()); | 4144 EXPECT_EQ(100, response->headers->GetContentLength()); |
4130 } | 4145 } |
4131 } | 4146 } |
4132 | 4147 |
4133 // Tests that nonce count increments when multiple auth attempts | 4148 // Tests that nonce count increments when multiple auth attempts |
4134 // are started with the same nonce. | 4149 // are started with the same nonce. |
4135 TEST_F(HttpNetworkTransactionTest, DigestPreAuthNonceCount) { | 4150 TEST_F(HttpNetworkTransactionSpdy2Test, DigestPreAuthNonceCount) { |
4136 SessionDependencies session_deps; | 4151 SessionDependencies session_deps; |
4137 HttpAuthHandlerDigest::Factory* digest_factory = | 4152 HttpAuthHandlerDigest::Factory* digest_factory = |
4138 new HttpAuthHandlerDigest::Factory(); | 4153 new HttpAuthHandlerDigest::Factory(); |
4139 HttpAuthHandlerDigest::FixedNonceGenerator* nonce_generator = | 4154 HttpAuthHandlerDigest::FixedNonceGenerator* nonce_generator = |
4140 new HttpAuthHandlerDigest::FixedNonceGenerator("0123456789abcdef"); | 4155 new HttpAuthHandlerDigest::FixedNonceGenerator("0123456789abcdef"); |
4141 digest_factory->set_nonce_generator(nonce_generator); | 4156 digest_factory->set_nonce_generator(nonce_generator); |
4142 session_deps.http_auth_handler_factory.reset(digest_factory); | 4157 session_deps.http_auth_handler_factory.reset(digest_factory); |
4143 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 4158 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
4144 | 4159 |
4145 // Transaction 1: authenticate (foo, bar) on MyRealm1 | 4160 // Transaction 1: authenticate (foo, bar) on MyRealm1 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4258 rv = callback1.WaitForResult(); | 4273 rv = callback1.WaitForResult(); |
4259 EXPECT_EQ(OK, rv); | 4274 EXPECT_EQ(OK, rv); |
4260 | 4275 |
4261 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4276 const HttpResponseInfo* response = trans->GetResponseInfo(); |
4262 ASSERT_TRUE(response != NULL); | 4277 ASSERT_TRUE(response != NULL); |
4263 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 4278 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
4264 } | 4279 } |
4265 } | 4280 } |
4266 | 4281 |
4267 // Test the ResetStateForRestart() private method. | 4282 // Test the ResetStateForRestart() private method. |
4268 TEST_F(HttpNetworkTransactionTest, ResetStateForRestart) { | 4283 TEST_F(HttpNetworkTransactionSpdy2Test, ResetStateForRestart) { |
4269 // Create a transaction (the dependencies aren't important). | 4284 // Create a transaction (the dependencies aren't important). |
4270 SessionDependencies session_deps; | 4285 SessionDependencies session_deps; |
4271 scoped_ptr<HttpNetworkTransaction> trans( | 4286 scoped_ptr<HttpNetworkTransaction> trans( |
4272 new HttpNetworkTransaction(CreateSession(&session_deps))); | 4287 new HttpNetworkTransaction(CreateSession(&session_deps))); |
4273 | 4288 |
4274 // Setup some state (which we expect ResetStateForRestart() will clear). | 4289 // Setup some state (which we expect ResetStateForRestart() will clear). |
4275 trans->read_buf_ = new IOBuffer(15); | 4290 trans->read_buf_ = new IOBuffer(15); |
4276 trans->read_buf_len_ = 15; | 4291 trans->read_buf_len_ = 15; |
4277 trans->request_headers_.SetHeader("Authorization", "NTLM"); | 4292 trans->request_headers_.SetHeader("Authorization", "NTLM"); |
4278 | 4293 |
(...skipping 22 matching lines...) Expand all Loading... |
4301 EXPECT_EQ(0, trans->read_buf_len_); | 4316 EXPECT_EQ(0, trans->read_buf_len_); |
4302 EXPECT_TRUE(trans->request_headers_.IsEmpty()); | 4317 EXPECT_TRUE(trans->request_headers_.IsEmpty()); |
4303 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 4318 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
4304 EXPECT_TRUE(response->headers.get() == NULL); | 4319 EXPECT_TRUE(response->headers.get() == NULL); |
4305 EXPECT_FALSE(response->was_cached); | 4320 EXPECT_FALSE(response->was_cached); |
4306 EXPECT_EQ(0U, response->ssl_info.cert_status); | 4321 EXPECT_EQ(0U, response->ssl_info.cert_status); |
4307 EXPECT_FALSE(response->vary_data.is_valid()); | 4322 EXPECT_FALSE(response->vary_data.is_valid()); |
4308 } | 4323 } |
4309 | 4324 |
4310 // Test HTTPS connections to a site with a bad certificate | 4325 // Test HTTPS connections to a site with a bad certificate |
4311 TEST_F(HttpNetworkTransactionTest, HTTPSBadCertificate) { | 4326 TEST_F(HttpNetworkTransactionSpdy2Test, HTTPSBadCertificate) { |
4312 HttpRequestInfo request; | 4327 HttpRequestInfo request; |
4313 request.method = "GET"; | 4328 request.method = "GET"; |
4314 request.url = GURL("https://www.google.com/"); | 4329 request.url = GURL("https://www.google.com/"); |
4315 request.load_flags = 0; | 4330 request.load_flags = 0; |
4316 | 4331 |
4317 SessionDependencies session_deps; | 4332 SessionDependencies session_deps; |
4318 scoped_ptr<HttpTransaction> trans( | 4333 scoped_ptr<HttpTransaction> trans( |
4319 new HttpNetworkTransaction(CreateSession(&session_deps))); | 4334 new HttpNetworkTransaction(CreateSession(&session_deps))); |
4320 | 4335 |
4321 MockWrite data_writes[] = { | 4336 MockWrite data_writes[] = { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4357 EXPECT_EQ(OK, rv); | 4372 EXPECT_EQ(OK, rv); |
4358 | 4373 |
4359 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4374 const HttpResponseInfo* response = trans->GetResponseInfo(); |
4360 | 4375 |
4361 ASSERT_TRUE(response != NULL); | 4376 ASSERT_TRUE(response != NULL); |
4362 EXPECT_EQ(100, response->headers->GetContentLength()); | 4377 EXPECT_EQ(100, response->headers->GetContentLength()); |
4363 } | 4378 } |
4364 | 4379 |
4365 // Test HTTPS connections to a site with a bad certificate, going through a | 4380 // Test HTTPS connections to a site with a bad certificate, going through a |
4366 // proxy | 4381 // proxy |
4367 TEST_F(HttpNetworkTransactionTest, HTTPSBadCertificateViaProxy) { | 4382 TEST_F(HttpNetworkTransactionSpdy2Test, HTTPSBadCertificateViaProxy) { |
4368 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 4383 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
4369 | 4384 |
4370 HttpRequestInfo request; | 4385 HttpRequestInfo request; |
4371 request.method = "GET"; | 4386 request.method = "GET"; |
4372 request.url = GURL("https://www.google.com/"); | 4387 request.url = GURL("https://www.google.com/"); |
4373 request.load_flags = 0; | 4388 request.load_flags = 0; |
4374 | 4389 |
4375 MockWrite proxy_writes[] = { | 4390 MockWrite proxy_writes[] = { |
4376 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 4391 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
4377 "Host: www.google.com\r\n" | 4392 "Host: www.google.com\r\n" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4435 | 4450 |
4436 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4451 const HttpResponseInfo* response = trans->GetResponseInfo(); |
4437 | 4452 |
4438 ASSERT_TRUE(response != NULL); | 4453 ASSERT_TRUE(response != NULL); |
4439 EXPECT_EQ(100, response->headers->GetContentLength()); | 4454 EXPECT_EQ(100, response->headers->GetContentLength()); |
4440 } | 4455 } |
4441 } | 4456 } |
4442 | 4457 |
4443 | 4458 |
4444 // Test HTTPS connections to a site, going through an HTTPS proxy | 4459 // Test HTTPS connections to a site, going through an HTTPS proxy |
4445 TEST_F(HttpNetworkTransactionTest, HTTPSViaHttpsProxy) { | 4460 TEST_F(HttpNetworkTransactionSpdy2Test, HTTPSViaHttpsProxy) { |
4446 SessionDependencies session_deps(ProxyService::CreateFixed( | 4461 SessionDependencies session_deps(ProxyService::CreateFixed( |
4447 "https://proxy:70")); | 4462 "https://proxy:70")); |
4448 | 4463 |
4449 HttpRequestInfo request; | 4464 HttpRequestInfo request; |
4450 request.method = "GET"; | 4465 request.method = "GET"; |
4451 request.url = GURL("https://www.google.com/"); | 4466 request.url = GURL("https://www.google.com/"); |
4452 request.load_flags = 0; | 4467 request.load_flags = 0; |
4453 | 4468 |
4454 MockWrite data_writes[] = { | 4469 MockWrite data_writes[] = { |
4455 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 4470 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4491 | 4506 |
4492 ASSERT_TRUE(response != NULL); | 4507 ASSERT_TRUE(response != NULL); |
4493 | 4508 |
4494 EXPECT_TRUE(response->headers->IsKeepAlive()); | 4509 EXPECT_TRUE(response->headers->IsKeepAlive()); |
4495 EXPECT_EQ(200, response->headers->response_code()); | 4510 EXPECT_EQ(200, response->headers->response_code()); |
4496 EXPECT_EQ(100, response->headers->GetContentLength()); | 4511 EXPECT_EQ(100, response->headers->GetContentLength()); |
4497 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 4512 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
4498 } | 4513 } |
4499 | 4514 |
4500 // Test an HTTPS Proxy's ability to redirect a CONNECT request | 4515 // Test an HTTPS Proxy's ability to redirect a CONNECT request |
4501 TEST_F(HttpNetworkTransactionTest, RedirectOfHttpsConnectViaHttpsProxy) { | 4516 TEST_F(HttpNetworkTransactionSpdy2Test, RedirectOfHttpsConnectViaHttpsProxy) { |
4502 SessionDependencies session_deps( | 4517 SessionDependencies session_deps( |
4503 ProxyService::CreateFixed("https://proxy:70")); | 4518 ProxyService::CreateFixed("https://proxy:70")); |
4504 | 4519 |
4505 HttpRequestInfo request; | 4520 HttpRequestInfo request; |
4506 request.method = "GET"; | 4521 request.method = "GET"; |
4507 request.url = GURL("https://www.google.com/"); | 4522 request.url = GURL("https://www.google.com/"); |
4508 request.load_flags = 0; | 4523 request.load_flags = 0; |
4509 | 4524 |
4510 MockWrite data_writes[] = { | 4525 MockWrite data_writes[] = { |
4511 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 4526 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
(...skipping 29 matching lines...) Expand all Loading... |
4541 | 4556 |
4542 ASSERT_TRUE(response != NULL); | 4557 ASSERT_TRUE(response != NULL); |
4543 | 4558 |
4544 EXPECT_EQ(302, response->headers->response_code()); | 4559 EXPECT_EQ(302, response->headers->response_code()); |
4545 std::string url; | 4560 std::string url; |
4546 EXPECT_TRUE(response->headers->IsRedirect(&url)); | 4561 EXPECT_TRUE(response->headers->IsRedirect(&url)); |
4547 EXPECT_EQ("http://login.example.com/", url); | 4562 EXPECT_EQ("http://login.example.com/", url); |
4548 } | 4563 } |
4549 | 4564 |
4550 // Test an HTTPS (SPDY) Proxy's ability to redirect a CONNECT request | 4565 // Test an HTTPS (SPDY) Proxy's ability to redirect a CONNECT request |
4551 TEST_F(HttpNetworkTransactionTest, RedirectOfHttpsConnectViaSpdyProxy) { | 4566 TEST_F(HttpNetworkTransactionSpdy2Test, RedirectOfHttpsConnectViaSpdyProxy) { |
4552 SessionDependencies session_deps( | 4567 SessionDependencies session_deps( |
4553 ProxyService::CreateFixed("https://proxy:70")); | 4568 ProxyService::CreateFixed("https://proxy:70")); |
4554 | 4569 |
4555 HttpRequestInfo request; | 4570 HttpRequestInfo request; |
4556 request.method = "GET"; | 4571 request.method = "GET"; |
4557 request.url = GURL("https://www.google.com/"); | 4572 request.url = GURL("https://www.google.com/"); |
4558 request.load_flags = 0; | 4573 request.load_flags = 0; |
4559 | 4574 |
4560 scoped_ptr<spdy::SpdyFrame> conn(ConstructSpdyConnect(NULL, 0, 1)); | 4575 scoped_ptr<spdy::SpdyFrame> conn(ConstructSpdyConnect(NULL, 0, 1)); |
4561 scoped_ptr<spdy::SpdyFrame> goaway(ConstructSpdyRstStream(1, spdy::CANCEL)); | 4576 scoped_ptr<spdy::SpdyFrame> goaway(ConstructSpdyRstStream(1, spdy::CANCEL)); |
(...skipping 12 matching lines...) Expand all Loading... |
4574 CreateMockRead(*resp.get(), 1, SYNCHRONOUS), | 4589 CreateMockRead(*resp.get(), 1, SYNCHRONOUS), |
4575 MockRead(ASYNC, 0, 2), // EOF | 4590 MockRead(ASYNC, 0, 2), // EOF |
4576 }; | 4591 }; |
4577 | 4592 |
4578 scoped_ptr<DelayedSocketData> data( | 4593 scoped_ptr<DelayedSocketData> data( |
4579 new DelayedSocketData( | 4594 new DelayedSocketData( |
4580 1, // wait for one write to finish before reading. | 4595 1, // wait for one write to finish before reading. |
4581 data_reads, arraysize(data_reads), | 4596 data_reads, arraysize(data_reads), |
4582 data_writes, arraysize(data_writes))); | 4597 data_writes, arraysize(data_writes))); |
4583 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy | 4598 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy |
4584 proxy_ssl.SetNextProto(SSLClientSocket::kProtoSPDY21); | 4599 proxy_ssl.SetNextProto(SSLClientSocket::kProtoSPDY2); |
4585 | 4600 |
4586 session_deps.socket_factory.AddSocketDataProvider(data.get()); | 4601 session_deps.socket_factory.AddSocketDataProvider(data.get()); |
4587 session_deps.socket_factory.AddSSLSocketDataProvider(&proxy_ssl); | 4602 session_deps.socket_factory.AddSSLSocketDataProvider(&proxy_ssl); |
4588 | 4603 |
4589 TestCompletionCallback callback; | 4604 TestCompletionCallback callback; |
4590 | 4605 |
4591 scoped_ptr<HttpTransaction> trans( | 4606 scoped_ptr<HttpTransaction> trans( |
4592 new HttpNetworkTransaction(CreateSession(&session_deps))); | 4607 new HttpNetworkTransaction(CreateSession(&session_deps))); |
4593 | 4608 |
4594 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 4609 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
4595 EXPECT_EQ(ERR_IO_PENDING, rv); | 4610 EXPECT_EQ(ERR_IO_PENDING, rv); |
4596 | 4611 |
4597 rv = callback.WaitForResult(); | 4612 rv = callback.WaitForResult(); |
4598 EXPECT_EQ(OK, rv); | 4613 EXPECT_EQ(OK, rv); |
4599 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4614 const HttpResponseInfo* response = trans->GetResponseInfo(); |
4600 | 4615 |
4601 ASSERT_TRUE(response != NULL); | 4616 ASSERT_TRUE(response != NULL); |
4602 | 4617 |
4603 EXPECT_EQ(302, response->headers->response_code()); | 4618 EXPECT_EQ(302, response->headers->response_code()); |
4604 std::string url; | 4619 std::string url; |
4605 EXPECT_TRUE(response->headers->IsRedirect(&url)); | 4620 EXPECT_TRUE(response->headers->IsRedirect(&url)); |
4606 EXPECT_EQ("http://login.example.com/", url); | 4621 EXPECT_EQ("http://login.example.com/", url); |
4607 } | 4622 } |
4608 | 4623 |
4609 // Test an HTTPS Proxy's ability to provide a response to a CONNECT request | 4624 // Test an HTTPS Proxy's ability to provide a response to a CONNECT request |
4610 TEST_F(HttpNetworkTransactionTest, ErrorResponseTofHttpsConnectViaHttpsProxy) { | 4625 TEST_F(HttpNetworkTransactionSpdy2Test, |
| 4626 ErrorResponseTofHttpsConnectViaHttpsProxy) { |
4611 SessionDependencies session_deps( | 4627 SessionDependencies session_deps( |
4612 ProxyService::CreateFixed("https://proxy:70")); | 4628 ProxyService::CreateFixed("https://proxy:70")); |
4613 | 4629 |
4614 HttpRequestInfo request; | 4630 HttpRequestInfo request; |
4615 request.method = "GET"; | 4631 request.method = "GET"; |
4616 request.url = GURL("https://www.google.com/"); | 4632 request.url = GURL("https://www.google.com/"); |
4617 request.load_flags = 0; | 4633 request.load_flags = 0; |
4618 | 4634 |
4619 MockWrite data_writes[] = { | 4635 MockWrite data_writes[] = { |
4620 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 4636 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4655 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 4671 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
4656 EXPECT_FALSE(response->ssl_info.is_valid()); | 4672 EXPECT_FALSE(response->ssl_info.is_valid()); |
4657 | 4673 |
4658 std::string response_data; | 4674 std::string response_data; |
4659 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 4675 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
4660 EXPECT_EQ("The host does not exist", response_data); | 4676 EXPECT_EQ("The host does not exist", response_data); |
4661 } | 4677 } |
4662 | 4678 |
4663 // Test an HTTPS (SPDY) Proxy's ability to provide a response to a CONNECT | 4679 // Test an HTTPS (SPDY) Proxy's ability to provide a response to a CONNECT |
4664 // request | 4680 // request |
4665 TEST_F(HttpNetworkTransactionTest, ErrorResponseTofHttpsConnectViaSpdyProxy) { | 4681 TEST_F(HttpNetworkTransactionSpdy2Test, |
| 4682 ErrorResponseTofHttpsConnectViaSpdyProxy) { |
4666 SessionDependencies session_deps( | 4683 SessionDependencies session_deps( |
4667 ProxyService::CreateFixed("https://proxy:70")); | 4684 ProxyService::CreateFixed("https://proxy:70")); |
4668 | 4685 |
4669 HttpRequestInfo request; | 4686 HttpRequestInfo request; |
4670 request.method = "GET"; | 4687 request.method = "GET"; |
4671 request.url = GURL("https://www.google.com/"); | 4688 request.url = GURL("https://www.google.com/"); |
4672 request.load_flags = 0; | 4689 request.load_flags = 0; |
4673 | 4690 |
4674 scoped_ptr<spdy::SpdyFrame> conn(ConstructSpdyConnect(NULL, 0, 1)); | 4691 scoped_ptr<spdy::SpdyFrame> conn(ConstructSpdyConnect(NULL, 0, 1)); |
4675 scoped_ptr<spdy::SpdyFrame> goaway(ConstructSpdyRstStream(1, spdy::CANCEL)); | 4692 scoped_ptr<spdy::SpdyFrame> goaway(ConstructSpdyRstStream(1, spdy::CANCEL)); |
(...skipping 15 matching lines...) Expand all Loading... |
4691 CreateMockRead(*body.get(), 2, SYNCHRONOUS), | 4708 CreateMockRead(*body.get(), 2, SYNCHRONOUS), |
4692 MockRead(ASYNC, 0, 3), // EOF | 4709 MockRead(ASYNC, 0, 3), // EOF |
4693 }; | 4710 }; |
4694 | 4711 |
4695 scoped_ptr<DelayedSocketData> data( | 4712 scoped_ptr<DelayedSocketData> data( |
4696 new DelayedSocketData( | 4713 new DelayedSocketData( |
4697 1, // wait for one write to finish before reading. | 4714 1, // wait for one write to finish before reading. |
4698 data_reads, arraysize(data_reads), | 4715 data_reads, arraysize(data_reads), |
4699 data_writes, arraysize(data_writes))); | 4716 data_writes, arraysize(data_writes))); |
4700 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy | 4717 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy |
4701 proxy_ssl.SetNextProto(SSLClientSocket::kProtoSPDY21); | 4718 proxy_ssl.SetNextProto(SSLClientSocket::kProtoSPDY2); |
4702 | 4719 |
4703 session_deps.socket_factory.AddSocketDataProvider(data.get()); | 4720 session_deps.socket_factory.AddSocketDataProvider(data.get()); |
4704 session_deps.socket_factory.AddSSLSocketDataProvider(&proxy_ssl); | 4721 session_deps.socket_factory.AddSSLSocketDataProvider(&proxy_ssl); |
4705 | 4722 |
4706 TestCompletionCallback callback; | 4723 TestCompletionCallback callback; |
4707 | 4724 |
4708 scoped_ptr<HttpTransaction> trans( | 4725 scoped_ptr<HttpTransaction> trans( |
4709 new HttpNetworkTransaction(CreateSession(&session_deps))); | 4726 new HttpNetworkTransaction(CreateSession(&session_deps))); |
4710 | 4727 |
4711 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 4728 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
4712 EXPECT_EQ(ERR_IO_PENDING, rv); | 4729 EXPECT_EQ(ERR_IO_PENDING, rv); |
4713 | 4730 |
4714 rv = callback.WaitForResult(); | 4731 rv = callback.WaitForResult(); |
4715 EXPECT_EQ(OK, rv); | 4732 EXPECT_EQ(OK, rv); |
4716 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4733 const HttpResponseInfo* response = trans->GetResponseInfo(); |
4717 | 4734 |
4718 ASSERT_TRUE(response != NULL); | 4735 ASSERT_TRUE(response != NULL); |
4719 | 4736 |
4720 EXPECT_EQ(404, response->headers->response_code()); | 4737 EXPECT_EQ(404, response->headers->response_code()); |
4721 EXPECT_FALSE(response->ssl_info.is_valid()); | 4738 EXPECT_FALSE(response->ssl_info.is_valid()); |
4722 | 4739 |
4723 std::string response_data; | 4740 std::string response_data; |
4724 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 4741 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
4725 EXPECT_EQ("The host does not exist", response_data); | 4742 EXPECT_EQ("The host does not exist", response_data); |
4726 } | 4743 } |
4727 | 4744 |
4728 // Test the request-challenge-retry sequence for basic auth, through | 4745 // Test the request-challenge-retry sequence for basic auth, through |
4729 // a SPDY proxy over a single SPDY session. | 4746 // a SPDY proxy over a single SPDY session. |
4730 TEST_F(HttpNetworkTransactionTest, BasicAuthSpdyProxy) { | 4747 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthSpdyProxy) { |
4731 HttpRequestInfo request; | 4748 HttpRequestInfo request; |
4732 request.method = "GET"; | 4749 request.method = "GET"; |
4733 request.url = GURL("https://www.google.com/"); | 4750 request.url = GURL("https://www.google.com/"); |
4734 // when the no authentication data flag is set. | 4751 // when the no authentication data flag is set. |
4735 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; | 4752 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; |
4736 | 4753 |
4737 // Configure against https proxy server "myproxy:70". | 4754 // Configure against https proxy server "myproxy:70". |
4738 SessionDependencies session_deps( | 4755 SessionDependencies session_deps( |
4739 ProxyService::CreateFixed("https://myproxy:70")); | 4756 ProxyService::CreateFixed("https://myproxy:70")); |
4740 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 4757 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4860 | 4877 |
4861 // The password prompt info should not be set. | 4878 // The password prompt info should not be set. |
4862 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 4879 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
4863 | 4880 |
4864 trans.reset(); | 4881 trans.reset(); |
4865 session->CloseAllConnections(); | 4882 session->CloseAllConnections(); |
4866 } | 4883 } |
4867 | 4884 |
4868 // Test HTTPS connections to a site with a bad certificate, going through an | 4885 // Test HTTPS connections to a site with a bad certificate, going through an |
4869 // HTTPS proxy | 4886 // HTTPS proxy |
4870 TEST_F(HttpNetworkTransactionTest, HTTPSBadCertificateViaHttpsProxy) { | 4887 TEST_F(HttpNetworkTransactionSpdy2Test, HTTPSBadCertificateViaHttpsProxy) { |
4871 SessionDependencies session_deps(ProxyService::CreateFixed( | 4888 SessionDependencies session_deps(ProxyService::CreateFixed( |
4872 "https://proxy:70")); | 4889 "https://proxy:70")); |
4873 | 4890 |
4874 HttpRequestInfo request; | 4891 HttpRequestInfo request; |
4875 request.method = "GET"; | 4892 request.method = "GET"; |
4876 request.url = GURL("https://www.google.com/"); | 4893 request.url = GURL("https://www.google.com/"); |
4877 request.load_flags = 0; | 4894 request.load_flags = 0; |
4878 | 4895 |
4879 // Attempt to fetch the URL from a server with a bad cert | 4896 // Attempt to fetch the URL from a server with a bad cert |
4880 MockWrite bad_cert_writes[] = { | 4897 MockWrite bad_cert_writes[] = { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4940 | 4957 |
4941 rv = callback.WaitForResult(); | 4958 rv = callback.WaitForResult(); |
4942 EXPECT_EQ(OK, rv); | 4959 EXPECT_EQ(OK, rv); |
4943 | 4960 |
4944 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4961 const HttpResponseInfo* response = trans->GetResponseInfo(); |
4945 | 4962 |
4946 ASSERT_TRUE(response != NULL); | 4963 ASSERT_TRUE(response != NULL); |
4947 EXPECT_EQ(100, response->headers->GetContentLength()); | 4964 EXPECT_EQ(100, response->headers->GetContentLength()); |
4948 } | 4965 } |
4949 | 4966 |
4950 TEST_F(HttpNetworkTransactionTest, BuildRequest_UserAgent) { | 4967 TEST_F(HttpNetworkTransactionSpdy2Test, BuildRequest_UserAgent) { |
4951 HttpRequestInfo request; | 4968 HttpRequestInfo request; |
4952 request.method = "GET"; | 4969 request.method = "GET"; |
4953 request.url = GURL("http://www.google.com/"); | 4970 request.url = GURL("http://www.google.com/"); |
4954 request.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent, | 4971 request.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent, |
4955 "Chromium Ultra Awesome X Edition"); | 4972 "Chromium Ultra Awesome X Edition"); |
4956 | 4973 |
4957 SessionDependencies session_deps; | 4974 SessionDependencies session_deps; |
4958 scoped_ptr<HttpTransaction> trans( | 4975 scoped_ptr<HttpTransaction> trans( |
4959 new HttpNetworkTransaction(CreateSession(&session_deps))); | 4976 new HttpNetworkTransaction(CreateSession(&session_deps))); |
4960 | 4977 |
(...skipping 18 matching lines...) Expand all Loading... |
4979 | 4996 |
4980 TestCompletionCallback callback; | 4997 TestCompletionCallback callback; |
4981 | 4998 |
4982 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 4999 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
4983 EXPECT_EQ(ERR_IO_PENDING, rv); | 5000 EXPECT_EQ(ERR_IO_PENDING, rv); |
4984 | 5001 |
4985 rv = callback.WaitForResult(); | 5002 rv = callback.WaitForResult(); |
4986 EXPECT_EQ(OK, rv); | 5003 EXPECT_EQ(OK, rv); |
4987 } | 5004 } |
4988 | 5005 |
4989 TEST_F(HttpNetworkTransactionTest, BuildRequest_UserAgentOverTunnel) { | 5006 TEST_F(HttpNetworkTransactionSpdy2Test, BuildRequest_UserAgentOverTunnel) { |
4990 HttpRequestInfo request; | 5007 HttpRequestInfo request; |
4991 request.method = "GET"; | 5008 request.method = "GET"; |
4992 request.url = GURL("https://www.google.com/"); | 5009 request.url = GURL("https://www.google.com/"); |
4993 request.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent, | 5010 request.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent, |
4994 "Chromium Ultra Awesome X Edition"); | 5011 "Chromium Ultra Awesome X Edition"); |
4995 | 5012 |
4996 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 5013 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
4997 scoped_ptr<HttpTransaction> trans( | 5014 scoped_ptr<HttpTransaction> trans( |
4998 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5015 new HttpNetworkTransaction(CreateSession(&session_deps))); |
4999 | 5016 |
(...skipping 17 matching lines...) Expand all Loading... |
5017 | 5034 |
5018 TestCompletionCallback callback; | 5035 TestCompletionCallback callback; |
5019 | 5036 |
5020 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 5037 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
5021 EXPECT_EQ(ERR_IO_PENDING, rv); | 5038 EXPECT_EQ(ERR_IO_PENDING, rv); |
5022 | 5039 |
5023 rv = callback.WaitForResult(); | 5040 rv = callback.WaitForResult(); |
5024 EXPECT_EQ(OK, rv); | 5041 EXPECT_EQ(OK, rv); |
5025 } | 5042 } |
5026 | 5043 |
5027 TEST_F(HttpNetworkTransactionTest, BuildRequest_Referer) { | 5044 TEST_F(HttpNetworkTransactionSpdy2Test, BuildRequest_Referer) { |
5028 HttpRequestInfo request; | 5045 HttpRequestInfo request; |
5029 request.method = "GET"; | 5046 request.method = "GET"; |
5030 request.url = GURL("http://www.google.com/"); | 5047 request.url = GURL("http://www.google.com/"); |
5031 request.load_flags = 0; | 5048 request.load_flags = 0; |
5032 request.extra_headers.SetHeader(HttpRequestHeaders::kReferer, | 5049 request.extra_headers.SetHeader(HttpRequestHeaders::kReferer, |
5033 "http://the.previous.site.com/"); | 5050 "http://the.previous.site.com/"); |
5034 | 5051 |
5035 SessionDependencies session_deps; | 5052 SessionDependencies session_deps; |
5036 scoped_ptr<HttpTransaction> trans( | 5053 scoped_ptr<HttpTransaction> trans( |
5037 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5054 new HttpNetworkTransaction(CreateSession(&session_deps))); |
(...skipping 19 matching lines...) Expand all Loading... |
5057 | 5074 |
5058 TestCompletionCallback callback; | 5075 TestCompletionCallback callback; |
5059 | 5076 |
5060 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 5077 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
5061 EXPECT_EQ(ERR_IO_PENDING, rv); | 5078 EXPECT_EQ(ERR_IO_PENDING, rv); |
5062 | 5079 |
5063 rv = callback.WaitForResult(); | 5080 rv = callback.WaitForResult(); |
5064 EXPECT_EQ(OK, rv); | 5081 EXPECT_EQ(OK, rv); |
5065 } | 5082 } |
5066 | 5083 |
5067 TEST_F(HttpNetworkTransactionTest, BuildRequest_PostContentLengthZero) { | 5084 TEST_F(HttpNetworkTransactionSpdy2Test, BuildRequest_PostContentLengthZero) { |
5068 HttpRequestInfo request; | 5085 HttpRequestInfo request; |
5069 request.method = "POST"; | 5086 request.method = "POST"; |
5070 request.url = GURL("http://www.google.com/"); | 5087 request.url = GURL("http://www.google.com/"); |
5071 | 5088 |
5072 SessionDependencies session_deps; | 5089 SessionDependencies session_deps; |
5073 scoped_ptr<HttpTransaction> trans( | 5090 scoped_ptr<HttpTransaction> trans( |
5074 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5091 new HttpNetworkTransaction(CreateSession(&session_deps))); |
5075 | 5092 |
5076 MockWrite data_writes[] = { | 5093 MockWrite data_writes[] = { |
5077 MockWrite("POST / HTTP/1.1\r\n" | 5094 MockWrite("POST / HTTP/1.1\r\n" |
(...skipping 16 matching lines...) Expand all Loading... |
5094 | 5111 |
5095 TestCompletionCallback callback; | 5112 TestCompletionCallback callback; |
5096 | 5113 |
5097 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 5114 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
5098 EXPECT_EQ(ERR_IO_PENDING, rv); | 5115 EXPECT_EQ(ERR_IO_PENDING, rv); |
5099 | 5116 |
5100 rv = callback.WaitForResult(); | 5117 rv = callback.WaitForResult(); |
5101 EXPECT_EQ(OK, rv); | 5118 EXPECT_EQ(OK, rv); |
5102 } | 5119 } |
5103 | 5120 |
5104 TEST_F(HttpNetworkTransactionTest, BuildRequest_PutContentLengthZero) { | 5121 TEST_F(HttpNetworkTransactionSpdy2Test, BuildRequest_PutContentLengthZero) { |
5105 HttpRequestInfo request; | 5122 HttpRequestInfo request; |
5106 request.method = "PUT"; | 5123 request.method = "PUT"; |
5107 request.url = GURL("http://www.google.com/"); | 5124 request.url = GURL("http://www.google.com/"); |
5108 | 5125 |
5109 SessionDependencies session_deps; | 5126 SessionDependencies session_deps; |
5110 scoped_ptr<HttpTransaction> trans( | 5127 scoped_ptr<HttpTransaction> trans( |
5111 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5128 new HttpNetworkTransaction(CreateSession(&session_deps))); |
5112 | 5129 |
5113 MockWrite data_writes[] = { | 5130 MockWrite data_writes[] = { |
5114 MockWrite("PUT / HTTP/1.1\r\n" | 5131 MockWrite("PUT / HTTP/1.1\r\n" |
(...skipping 16 matching lines...) Expand all Loading... |
5131 | 5148 |
5132 TestCompletionCallback callback; | 5149 TestCompletionCallback callback; |
5133 | 5150 |
5134 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 5151 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
5135 EXPECT_EQ(ERR_IO_PENDING, rv); | 5152 EXPECT_EQ(ERR_IO_PENDING, rv); |
5136 | 5153 |
5137 rv = callback.WaitForResult(); | 5154 rv = callback.WaitForResult(); |
5138 EXPECT_EQ(OK, rv); | 5155 EXPECT_EQ(OK, rv); |
5139 } | 5156 } |
5140 | 5157 |
5141 TEST_F(HttpNetworkTransactionTest, BuildRequest_HeadContentLengthZero) { | 5158 TEST_F(HttpNetworkTransactionSpdy2Test, BuildRequest_HeadContentLengthZero) { |
5142 HttpRequestInfo request; | 5159 HttpRequestInfo request; |
5143 request.method = "HEAD"; | 5160 request.method = "HEAD"; |
5144 request.url = GURL("http://www.google.com/"); | 5161 request.url = GURL("http://www.google.com/"); |
5145 | 5162 |
5146 SessionDependencies session_deps; | 5163 SessionDependencies session_deps; |
5147 scoped_ptr<HttpTransaction> trans( | 5164 scoped_ptr<HttpTransaction> trans( |
5148 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5165 new HttpNetworkTransaction(CreateSession(&session_deps))); |
5149 | 5166 |
5150 MockWrite data_writes[] = { | 5167 MockWrite data_writes[] = { |
5151 MockWrite("HEAD / HTTP/1.1\r\n" | 5168 MockWrite("HEAD / HTTP/1.1\r\n" |
(...skipping 16 matching lines...) Expand all Loading... |
5168 | 5185 |
5169 TestCompletionCallback callback; | 5186 TestCompletionCallback callback; |
5170 | 5187 |
5171 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 5188 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
5172 EXPECT_EQ(ERR_IO_PENDING, rv); | 5189 EXPECT_EQ(ERR_IO_PENDING, rv); |
5173 | 5190 |
5174 rv = callback.WaitForResult(); | 5191 rv = callback.WaitForResult(); |
5175 EXPECT_EQ(OK, rv); | 5192 EXPECT_EQ(OK, rv); |
5176 } | 5193 } |
5177 | 5194 |
5178 TEST_F(HttpNetworkTransactionTest, BuildRequest_CacheControlNoCache) { | 5195 TEST_F(HttpNetworkTransactionSpdy2Test, BuildRequest_CacheControlNoCache) { |
5179 HttpRequestInfo request; | 5196 HttpRequestInfo request; |
5180 request.method = "GET"; | 5197 request.method = "GET"; |
5181 request.url = GURL("http://www.google.com/"); | 5198 request.url = GURL("http://www.google.com/"); |
5182 request.load_flags = LOAD_BYPASS_CACHE; | 5199 request.load_flags = LOAD_BYPASS_CACHE; |
5183 | 5200 |
5184 SessionDependencies session_deps; | 5201 SessionDependencies session_deps; |
5185 scoped_ptr<HttpTransaction> trans( | 5202 scoped_ptr<HttpTransaction> trans( |
5186 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5203 new HttpNetworkTransaction(CreateSession(&session_deps))); |
5187 | 5204 |
5188 MockWrite data_writes[] = { | 5205 MockWrite data_writes[] = { |
(...skipping 18 matching lines...) Expand all Loading... |
5207 | 5224 |
5208 TestCompletionCallback callback; | 5225 TestCompletionCallback callback; |
5209 | 5226 |
5210 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 5227 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
5211 EXPECT_EQ(ERR_IO_PENDING, rv); | 5228 EXPECT_EQ(ERR_IO_PENDING, rv); |
5212 | 5229 |
5213 rv = callback.WaitForResult(); | 5230 rv = callback.WaitForResult(); |
5214 EXPECT_EQ(OK, rv); | 5231 EXPECT_EQ(OK, rv); |
5215 } | 5232 } |
5216 | 5233 |
5217 TEST_F(HttpNetworkTransactionTest, | 5234 TEST_F(HttpNetworkTransactionSpdy2Test, |
5218 BuildRequest_CacheControlValidateCache) { | 5235 BuildRequest_CacheControlValidateCache) { |
5219 HttpRequestInfo request; | 5236 HttpRequestInfo request; |
5220 request.method = "GET"; | 5237 request.method = "GET"; |
5221 request.url = GURL("http://www.google.com/"); | 5238 request.url = GURL("http://www.google.com/"); |
5222 request.load_flags = LOAD_VALIDATE_CACHE; | 5239 request.load_flags = LOAD_VALIDATE_CACHE; |
5223 | 5240 |
5224 SessionDependencies session_deps; | 5241 SessionDependencies session_deps; |
5225 scoped_ptr<HttpTransaction> trans( | 5242 scoped_ptr<HttpTransaction> trans( |
5226 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5243 new HttpNetworkTransaction(CreateSession(&session_deps))); |
5227 | 5244 |
(...skipping 18 matching lines...) Expand all Loading... |
5246 | 5263 |
5247 TestCompletionCallback callback; | 5264 TestCompletionCallback callback; |
5248 | 5265 |
5249 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 5266 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
5250 EXPECT_EQ(ERR_IO_PENDING, rv); | 5267 EXPECT_EQ(ERR_IO_PENDING, rv); |
5251 | 5268 |
5252 rv = callback.WaitForResult(); | 5269 rv = callback.WaitForResult(); |
5253 EXPECT_EQ(OK, rv); | 5270 EXPECT_EQ(OK, rv); |
5254 } | 5271 } |
5255 | 5272 |
5256 TEST_F(HttpNetworkTransactionTest, BuildRequest_ExtraHeaders) { | 5273 TEST_F(HttpNetworkTransactionSpdy2Test, BuildRequest_ExtraHeaders) { |
5257 HttpRequestInfo request; | 5274 HttpRequestInfo request; |
5258 request.method = "GET"; | 5275 request.method = "GET"; |
5259 request.url = GURL("http://www.google.com/"); | 5276 request.url = GURL("http://www.google.com/"); |
5260 request.extra_headers.SetHeader("FooHeader", "Bar"); | 5277 request.extra_headers.SetHeader("FooHeader", "Bar"); |
5261 | 5278 |
5262 SessionDependencies session_deps; | 5279 SessionDependencies session_deps; |
5263 scoped_ptr<HttpTransaction> trans( | 5280 scoped_ptr<HttpTransaction> trans( |
5264 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5281 new HttpNetworkTransaction(CreateSession(&session_deps))); |
5265 | 5282 |
5266 MockWrite data_writes[] = { | 5283 MockWrite data_writes[] = { |
(...skipping 17 matching lines...) Expand all Loading... |
5284 | 5301 |
5285 TestCompletionCallback callback; | 5302 TestCompletionCallback callback; |
5286 | 5303 |
5287 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 5304 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
5288 EXPECT_EQ(ERR_IO_PENDING, rv); | 5305 EXPECT_EQ(ERR_IO_PENDING, rv); |
5289 | 5306 |
5290 rv = callback.WaitForResult(); | 5307 rv = callback.WaitForResult(); |
5291 EXPECT_EQ(OK, rv); | 5308 EXPECT_EQ(OK, rv); |
5292 } | 5309 } |
5293 | 5310 |
5294 TEST_F(HttpNetworkTransactionTest, BuildRequest_ExtraHeadersStripped) { | 5311 TEST_F(HttpNetworkTransactionSpdy2Test, BuildRequest_ExtraHeadersStripped) { |
5295 HttpRequestInfo request; | 5312 HttpRequestInfo request; |
5296 request.method = "GET"; | 5313 request.method = "GET"; |
5297 request.url = GURL("http://www.google.com/"); | 5314 request.url = GURL("http://www.google.com/"); |
5298 request.extra_headers.SetHeader("referer", "www.foo.com"); | 5315 request.extra_headers.SetHeader("referer", "www.foo.com"); |
5299 request.extra_headers.SetHeader("hEllo", "Kitty"); | 5316 request.extra_headers.SetHeader("hEllo", "Kitty"); |
5300 request.extra_headers.SetHeader("FoO", "bar"); | 5317 request.extra_headers.SetHeader("FoO", "bar"); |
5301 | 5318 |
5302 SessionDependencies session_deps; | 5319 SessionDependencies session_deps; |
5303 scoped_ptr<HttpTransaction> trans( | 5320 scoped_ptr<HttpTransaction> trans( |
5304 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5321 new HttpNetworkTransaction(CreateSession(&session_deps))); |
(...skipping 28 matching lines...) Expand all Loading... |
5333 EXPECT_EQ(OK, rv); | 5350 EXPECT_EQ(OK, rv); |
5334 } | 5351 } |
5335 | 5352 |
5336 // http://crbug.com/112682 | 5353 // http://crbug.com/112682 |
5337 #if defined(OS_MACOSX) | 5354 #if defined(OS_MACOSX) |
5338 #define MAYBE_SOCKS4_HTTP_GET DISABLED_SOCKS4_HTTP_GET | 5355 #define MAYBE_SOCKS4_HTTP_GET DISABLED_SOCKS4_HTTP_GET |
5339 #else | 5356 #else |
5340 #define MAYBE_SOCKS4_HTTP_GET SOCKS4_HTTP_GET | 5357 #define MAYBE_SOCKS4_HTTP_GET SOCKS4_HTTP_GET |
5341 #endif | 5358 #endif |
5342 | 5359 |
5343 TEST_F(HttpNetworkTransactionTest, MAYBE_SOCKS4_HTTP_GET) { | 5360 TEST_F(HttpNetworkTransactionSpdy2Test, MAYBE_SOCKS4_HTTP_GET) { |
5344 HttpRequestInfo request; | 5361 HttpRequestInfo request; |
5345 request.method = "GET"; | 5362 request.method = "GET"; |
5346 request.url = GURL("http://www.google.com/"); | 5363 request.url = GURL("http://www.google.com/"); |
5347 request.load_flags = 0; | 5364 request.load_flags = 0; |
5348 | 5365 |
5349 SessionDependencies session_deps( | 5366 SessionDependencies session_deps( |
5350 ProxyService::CreateFixed("socks4://myproxy:1080")); | 5367 ProxyService::CreateFixed("socks4://myproxy:1080")); |
5351 | 5368 |
5352 scoped_ptr<HttpTransaction> trans( | 5369 scoped_ptr<HttpTransaction> trans( |
5353 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5370 new HttpNetworkTransaction(CreateSession(&session_deps))); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5391 EXPECT_EQ("Payload", response_text); | 5408 EXPECT_EQ("Payload", response_text); |
5392 } | 5409 } |
5393 | 5410 |
5394 // http://crbug.com/112682 | 5411 // http://crbug.com/112682 |
5395 #if defined(OS_MACOSX) | 5412 #if defined(OS_MACOSX) |
5396 #define MAYBE_SOCKS4_SSL_GET DISABLED_SOCKS4_SSL_GET | 5413 #define MAYBE_SOCKS4_SSL_GET DISABLED_SOCKS4_SSL_GET |
5397 #else | 5414 #else |
5398 #define MAYBE_SOCKS4_SSL_GET SOCKS4_SSL_GET | 5415 #define MAYBE_SOCKS4_SSL_GET SOCKS4_SSL_GET |
5399 #endif | 5416 #endif |
5400 | 5417 |
5401 TEST_F(HttpNetworkTransactionTest, MAYBE_SOCKS4_SSL_GET) { | 5418 TEST_F(HttpNetworkTransactionSpdy2Test, MAYBE_SOCKS4_SSL_GET) { |
5402 HttpRequestInfo request; | 5419 HttpRequestInfo request; |
5403 request.method = "GET"; | 5420 request.method = "GET"; |
5404 request.url = GURL("https://www.google.com/"); | 5421 request.url = GURL("https://www.google.com/"); |
5405 request.load_flags = 0; | 5422 request.load_flags = 0; |
5406 | 5423 |
5407 SessionDependencies session_deps( | 5424 SessionDependencies session_deps( |
5408 ProxyService::CreateFixed("socks4://myproxy:1080")); | 5425 ProxyService::CreateFixed("socks4://myproxy:1080")); |
5409 | 5426 |
5410 scoped_ptr<HttpTransaction> trans( | 5427 scoped_ptr<HttpTransaction> trans( |
5411 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5428 new HttpNetworkTransaction(CreateSession(&session_deps))); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5447 | 5464 |
5448 const HttpResponseInfo* response = trans->GetResponseInfo(); | 5465 const HttpResponseInfo* response = trans->GetResponseInfo(); |
5449 ASSERT_TRUE(response != NULL); | 5466 ASSERT_TRUE(response != NULL); |
5450 | 5467 |
5451 std::string response_text; | 5468 std::string response_text; |
5452 rv = ReadTransaction(trans.get(), &response_text); | 5469 rv = ReadTransaction(trans.get(), &response_text); |
5453 EXPECT_EQ(OK, rv); | 5470 EXPECT_EQ(OK, rv); |
5454 EXPECT_EQ("Payload", response_text); | 5471 EXPECT_EQ("Payload", response_text); |
5455 } | 5472 } |
5456 | 5473 |
5457 TEST_F(HttpNetworkTransactionTest, SOCKS5_HTTP_GET) { | 5474 TEST_F(HttpNetworkTransactionSpdy2Test, SOCKS5_HTTP_GET) { |
5458 HttpRequestInfo request; | 5475 HttpRequestInfo request; |
5459 request.method = "GET"; | 5476 request.method = "GET"; |
5460 request.url = GURL("http://www.google.com/"); | 5477 request.url = GURL("http://www.google.com/"); |
5461 request.load_flags = 0; | 5478 request.load_flags = 0; |
5462 | 5479 |
5463 SessionDependencies session_deps( | 5480 SessionDependencies session_deps( |
5464 ProxyService::CreateFixed("socks5://myproxy:1080")); | 5481 ProxyService::CreateFixed("socks5://myproxy:1080")); |
5465 | 5482 |
5466 scoped_ptr<HttpTransaction> trans( | 5483 scoped_ptr<HttpTransaction> trans( |
5467 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5484 new HttpNetworkTransaction(CreateSession(&session_deps))); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5512 | 5529 |
5513 const HttpResponseInfo* response = trans->GetResponseInfo(); | 5530 const HttpResponseInfo* response = trans->GetResponseInfo(); |
5514 ASSERT_TRUE(response != NULL); | 5531 ASSERT_TRUE(response != NULL); |
5515 | 5532 |
5516 std::string response_text; | 5533 std::string response_text; |
5517 rv = ReadTransaction(trans.get(), &response_text); | 5534 rv = ReadTransaction(trans.get(), &response_text); |
5518 EXPECT_EQ(OK, rv); | 5535 EXPECT_EQ(OK, rv); |
5519 EXPECT_EQ("Payload", response_text); | 5536 EXPECT_EQ("Payload", response_text); |
5520 } | 5537 } |
5521 | 5538 |
5522 TEST_F(HttpNetworkTransactionTest, SOCKS5_SSL_GET) { | 5539 TEST_F(HttpNetworkTransactionSpdy2Test, SOCKS5_SSL_GET) { |
5523 HttpRequestInfo request; | 5540 HttpRequestInfo request; |
5524 request.method = "GET"; | 5541 request.method = "GET"; |
5525 request.url = GURL("https://www.google.com/"); | 5542 request.url = GURL("https://www.google.com/"); |
5526 request.load_flags = 0; | 5543 request.load_flags = 0; |
5527 | 5544 |
5528 SessionDependencies session_deps( | 5545 SessionDependencies session_deps( |
5529 ProxyService::CreateFixed("socks5://myproxy:1080")); | 5546 ProxyService::CreateFixed("socks5://myproxy:1080")); |
5530 | 5547 |
5531 scoped_ptr<HttpTransaction> trans( | 5548 scoped_ptr<HttpTransaction> trans( |
5532 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5549 new HttpNetworkTransaction(CreateSession(&session_deps))); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5582 | 5599 |
5583 const HttpResponseInfo* response = trans->GetResponseInfo(); | 5600 const HttpResponseInfo* response = trans->GetResponseInfo(); |
5584 ASSERT_TRUE(response != NULL); | 5601 ASSERT_TRUE(response != NULL); |
5585 | 5602 |
5586 std::string response_text; | 5603 std::string response_text; |
5587 rv = ReadTransaction(trans.get(), &response_text); | 5604 rv = ReadTransaction(trans.get(), &response_text); |
5588 EXPECT_EQ(OK, rv); | 5605 EXPECT_EQ(OK, rv); |
5589 EXPECT_EQ("Payload", response_text); | 5606 EXPECT_EQ("Payload", response_text); |
5590 } | 5607 } |
5591 | 5608 |
| 5609 namespace { |
| 5610 |
5592 // Tests that for connection endpoints the group names are correctly set. | 5611 // Tests that for connection endpoints the group names are correctly set. |
5593 | 5612 |
5594 struct GroupNameTest { | 5613 struct GroupNameTest { |
5595 std::string proxy_server; | 5614 std::string proxy_server; |
5596 std::string url; | 5615 std::string url; |
5597 std::string expected_group_name; | 5616 std::string expected_group_name; |
5598 bool ssl; | 5617 bool ssl; |
5599 }; | 5618 }; |
5600 | 5619 |
5601 scoped_refptr<HttpNetworkSession> SetupSessionForGroupNameTests( | 5620 scoped_refptr<HttpNetworkSession> SetupSessionForGroupNameTests( |
5602 SessionDependencies* session_deps) { | 5621 SessionDependencies* session_deps) { |
5603 scoped_refptr<HttpNetworkSession> session(CreateSession(session_deps)); | 5622 scoped_refptr<HttpNetworkSession> session(CreateSession(session_deps)); |
5604 | 5623 |
5605 HttpServerProperties* http_server_properties = | 5624 HttpServerProperties* http_server_properties = |
5606 session->http_server_properties(); | 5625 session->http_server_properties(); |
5607 http_server_properties->SetAlternateProtocol( | 5626 http_server_properties->SetAlternateProtocol( |
5608 HostPortPair("host.with.alternate", 80), 443, | 5627 HostPortPair("host.with.alternate", 80), 443, |
5609 NPN_SPDY_21); | 5628 NPN_SPDY_2); |
5610 | 5629 |
5611 return session; | 5630 return session; |
5612 } | 5631 } |
5613 | 5632 |
5614 int GroupNameTransactionHelper( | 5633 int GroupNameTransactionHelper( |
5615 const std::string& url, | 5634 const std::string& url, |
5616 const scoped_refptr<HttpNetworkSession>& session) { | 5635 const scoped_refptr<HttpNetworkSession>& session) { |
5617 HttpRequestInfo request; | 5636 HttpRequestInfo request; |
5618 request.method = "GET"; | 5637 request.method = "GET"; |
5619 request.url = GURL(url); | 5638 request.url = GURL(url); |
5620 request.load_flags = 0; | 5639 request.load_flags = 0; |
5621 | 5640 |
5622 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 5641 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
5623 | 5642 |
5624 TestCompletionCallback callback; | 5643 TestCompletionCallback callback; |
5625 | 5644 |
5626 // We do not complete this request, the dtor will clean the transaction up. | 5645 // We do not complete this request, the dtor will clean the transaction up. |
5627 return trans->Start(&request, callback.callback(), BoundNetLog()); | 5646 return trans->Start(&request, callback.callback(), BoundNetLog()); |
5628 } | 5647 } |
5629 | 5648 |
5630 TEST_F(HttpNetworkTransactionTest, GroupNameForDirectConnections) { | 5649 } // namespace |
| 5650 |
| 5651 TEST_F(HttpNetworkTransactionSpdy2Test, GroupNameForDirectConnections) { |
5631 const GroupNameTest tests[] = { | 5652 const GroupNameTest tests[] = { |
5632 { | 5653 { |
5633 "", // unused | 5654 "", // unused |
5634 "http://www.google.com/direct", | 5655 "http://www.google.com/direct", |
5635 "www.google.com:80", | 5656 "www.google.com:80", |
5636 false, | 5657 false, |
5637 }, | 5658 }, |
5638 { | 5659 { |
5639 "", // unused | 5660 "", // unused |
5640 "http://[2001:1418:13:1::25]/direct", | 5661 "http://[2001:1418:13:1::25]/direct", |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5688 EXPECT_EQ(tests[i].expected_group_name, | 5709 EXPECT_EQ(tests[i].expected_group_name, |
5689 ssl_conn_pool->last_group_name_received()); | 5710 ssl_conn_pool->last_group_name_received()); |
5690 else | 5711 else |
5691 EXPECT_EQ(tests[i].expected_group_name, | 5712 EXPECT_EQ(tests[i].expected_group_name, |
5692 transport_conn_pool->last_group_name_received()); | 5713 transport_conn_pool->last_group_name_received()); |
5693 } | 5714 } |
5694 | 5715 |
5695 HttpStreamFactory::set_use_alternate_protocols(false); | 5716 HttpStreamFactory::set_use_alternate_protocols(false); |
5696 } | 5717 } |
5697 | 5718 |
5698 TEST_F(HttpNetworkTransactionTest, GroupNameForHTTPProxyConnections) { | 5719 TEST_F(HttpNetworkTransactionSpdy2Test, GroupNameForHTTPProxyConnections) { |
5699 const GroupNameTest tests[] = { | 5720 const GroupNameTest tests[] = { |
5700 { | 5721 { |
5701 "http_proxy", | 5722 "http_proxy", |
5702 "http://www.google.com/http_proxy_normal", | 5723 "http://www.google.com/http_proxy_normal", |
5703 "www.google.com:80", | 5724 "www.google.com:80", |
5704 false, | 5725 false, |
5705 }, | 5726 }, |
5706 | 5727 |
5707 // SSL Tests | 5728 // SSL Tests |
5708 { | 5729 { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5748 EXPECT_EQ(tests[i].expected_group_name, | 5769 EXPECT_EQ(tests[i].expected_group_name, |
5749 ssl_conn_pool->last_group_name_received()); | 5770 ssl_conn_pool->last_group_name_received()); |
5750 else | 5771 else |
5751 EXPECT_EQ(tests[i].expected_group_name, | 5772 EXPECT_EQ(tests[i].expected_group_name, |
5752 http_proxy_pool->last_group_name_received()); | 5773 http_proxy_pool->last_group_name_received()); |
5753 } | 5774 } |
5754 | 5775 |
5755 HttpStreamFactory::set_use_alternate_protocols(false); | 5776 HttpStreamFactory::set_use_alternate_protocols(false); |
5756 } | 5777 } |
5757 | 5778 |
5758 TEST_F(HttpNetworkTransactionTest, GroupNameForSOCKSConnections) { | 5779 TEST_F(HttpNetworkTransactionSpdy2Test, GroupNameForSOCKSConnections) { |
5759 const GroupNameTest tests[] = { | 5780 const GroupNameTest tests[] = { |
5760 { | 5781 { |
5761 "socks4://socks_proxy:1080", | 5782 "socks4://socks_proxy:1080", |
5762 "http://www.google.com/socks4_direct", | 5783 "http://www.google.com/socks4_direct", |
5763 "socks4/www.google.com:80", | 5784 "socks4/www.google.com:80", |
5764 false, | 5785 false, |
5765 }, | 5786 }, |
5766 { | 5787 { |
5767 "socks5://socks_proxy:1080", | 5788 "socks5://socks_proxy:1080", |
5768 "http://www.google.com/socks5_direct", | 5789 "http://www.google.com/socks5_direct", |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5822 EXPECT_EQ(tests[i].expected_group_name, | 5843 EXPECT_EQ(tests[i].expected_group_name, |
5823 ssl_conn_pool->last_group_name_received()); | 5844 ssl_conn_pool->last_group_name_received()); |
5824 else | 5845 else |
5825 EXPECT_EQ(tests[i].expected_group_name, | 5846 EXPECT_EQ(tests[i].expected_group_name, |
5826 socks_conn_pool->last_group_name_received()); | 5847 socks_conn_pool->last_group_name_received()); |
5827 } | 5848 } |
5828 | 5849 |
5829 HttpStreamFactory::set_use_alternate_protocols(false); | 5850 HttpStreamFactory::set_use_alternate_protocols(false); |
5830 } | 5851 } |
5831 | 5852 |
5832 TEST_F(HttpNetworkTransactionTest, ReconsiderProxyAfterFailedConnection) { | 5853 TEST_F(HttpNetworkTransactionSpdy2Test, ReconsiderProxyAfterFailedConnection) { |
5833 HttpRequestInfo request; | 5854 HttpRequestInfo request; |
5834 request.method = "GET"; | 5855 request.method = "GET"; |
5835 request.url = GURL("http://www.google.com/"); | 5856 request.url = GURL("http://www.google.com/"); |
5836 | 5857 |
5837 SessionDependencies session_deps( | 5858 SessionDependencies session_deps( |
5838 ProxyService::CreateFixed("myproxy:70;foobar:80")); | 5859 ProxyService::CreateFixed("myproxy:70;foobar:80")); |
5839 | 5860 |
5840 // This simulates failure resolving all hostnames; that means we will fail | 5861 // This simulates failure resolving all hostnames; that means we will fail |
5841 // connecting to both proxies (myproxy:70 and foobar:80). | 5862 // connecting to both proxies (myproxy:70 and foobar:80). |
5842 session_deps.host_resolver->rules()->AddSimulatedFailure("*"); | 5863 session_deps.host_resolver->rules()->AddSimulatedFailure("*"); |
5843 | 5864 |
5844 scoped_ptr<HttpTransaction> trans( | 5865 scoped_ptr<HttpTransaction> trans( |
5845 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5866 new HttpNetworkTransaction(CreateSession(&session_deps))); |
5846 | 5867 |
5847 TestCompletionCallback callback; | 5868 TestCompletionCallback callback; |
5848 | 5869 |
5849 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 5870 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
5850 EXPECT_EQ(ERR_IO_PENDING, rv); | 5871 EXPECT_EQ(ERR_IO_PENDING, rv); |
5851 | 5872 |
5852 rv = callback.WaitForResult(); | 5873 rv = callback.WaitForResult(); |
5853 EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED, rv); | 5874 EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED, rv); |
5854 } | 5875 } |
5855 | 5876 |
| 5877 namespace { |
| 5878 |
5856 // Base test to make sure that when the load flags for a request specify to | 5879 // Base test to make sure that when the load flags for a request specify to |
5857 // bypass the cache, the DNS cache is not used. | 5880 // bypass the cache, the DNS cache is not used. |
5858 void BypassHostCacheOnRefreshHelper(int load_flags) { | 5881 void BypassHostCacheOnRefreshHelper(int load_flags) { |
5859 // Issue a request, asking to bypass the cache(s). | 5882 // Issue a request, asking to bypass the cache(s). |
5860 HttpRequestInfo request; | 5883 HttpRequestInfo request; |
5861 request.method = "GET"; | 5884 request.method = "GET"; |
5862 request.load_flags = load_flags; | 5885 request.load_flags = load_flags; |
5863 request.url = GURL("http://www.google.com/"); | 5886 request.url = GURL("http://www.google.com/"); |
5864 | 5887 |
5865 SessionDependencies session_deps; | 5888 SessionDependencies session_deps; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5901 // Run the request. | 5924 // Run the request. |
5902 rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 5925 rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
5903 ASSERT_EQ(ERR_IO_PENDING, rv); | 5926 ASSERT_EQ(ERR_IO_PENDING, rv); |
5904 rv = callback.WaitForResult(); | 5927 rv = callback.WaitForResult(); |
5905 | 5928 |
5906 // If we bypassed the cache, we would have gotten a failure while resolving | 5929 // If we bypassed the cache, we would have gotten a failure while resolving |
5907 // "www.google.com". | 5930 // "www.google.com". |
5908 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, rv); | 5931 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, rv); |
5909 } | 5932 } |
5910 | 5933 |
| 5934 } // namespace |
| 5935 |
5911 // There are multiple load flags that should trigger the host cache bypass. | 5936 // There are multiple load flags that should trigger the host cache bypass. |
5912 // Test each in isolation: | 5937 // Test each in isolation: |
5913 TEST_F(HttpNetworkTransactionTest, BypassHostCacheOnRefresh1) { | 5938 TEST_F(HttpNetworkTransactionSpdy2Test, BypassHostCacheOnRefresh1) { |
5914 BypassHostCacheOnRefreshHelper(LOAD_BYPASS_CACHE); | 5939 BypassHostCacheOnRefreshHelper(LOAD_BYPASS_CACHE); |
5915 } | 5940 } |
5916 | 5941 |
5917 TEST_F(HttpNetworkTransactionTest, BypassHostCacheOnRefresh2) { | 5942 TEST_F(HttpNetworkTransactionSpdy2Test, BypassHostCacheOnRefresh2) { |
5918 BypassHostCacheOnRefreshHelper(LOAD_VALIDATE_CACHE); | 5943 BypassHostCacheOnRefreshHelper(LOAD_VALIDATE_CACHE); |
5919 } | 5944 } |
5920 | 5945 |
5921 TEST_F(HttpNetworkTransactionTest, BypassHostCacheOnRefresh3) { | 5946 TEST_F(HttpNetworkTransactionSpdy2Test, BypassHostCacheOnRefresh3) { |
5922 BypassHostCacheOnRefreshHelper(LOAD_DISABLE_CACHE); | 5947 BypassHostCacheOnRefreshHelper(LOAD_DISABLE_CACHE); |
5923 } | 5948 } |
5924 | 5949 |
5925 // Make sure we can handle an error when writing the request. | 5950 // Make sure we can handle an error when writing the request. |
5926 TEST_F(HttpNetworkTransactionTest, RequestWriteError) { | 5951 TEST_F(HttpNetworkTransactionSpdy2Test, RequestWriteError) { |
5927 SessionDependencies session_deps; | 5952 SessionDependencies session_deps; |
5928 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 5953 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
5929 | 5954 |
5930 HttpRequestInfo request; | 5955 HttpRequestInfo request; |
5931 request.method = "GET"; | 5956 request.method = "GET"; |
5932 request.url = GURL("http://www.foo.com/"); | 5957 request.url = GURL("http://www.foo.com/"); |
5933 request.load_flags = 0; | 5958 request.load_flags = 0; |
5934 | 5959 |
5935 MockWrite write_failure[] = { | 5960 MockWrite write_failure[] = { |
5936 MockWrite(ASYNC, ERR_CONNECTION_RESET), | 5961 MockWrite(ASYNC, ERR_CONNECTION_RESET), |
5937 }; | 5962 }; |
5938 StaticSocketDataProvider data(NULL, 0, | 5963 StaticSocketDataProvider data(NULL, 0, |
5939 write_failure, arraysize(write_failure)); | 5964 write_failure, arraysize(write_failure)); |
5940 session_deps.socket_factory.AddSocketDataProvider(&data); | 5965 session_deps.socket_factory.AddSocketDataProvider(&data); |
5941 | 5966 |
5942 TestCompletionCallback callback; | 5967 TestCompletionCallback callback; |
5943 | 5968 |
5944 scoped_ptr<HttpTransaction> trans( | 5969 scoped_ptr<HttpTransaction> trans( |
5945 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5970 new HttpNetworkTransaction(CreateSession(&session_deps))); |
5946 | 5971 |
5947 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 5972 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
5948 EXPECT_EQ(ERR_IO_PENDING, rv); | 5973 EXPECT_EQ(ERR_IO_PENDING, rv); |
5949 | 5974 |
5950 rv = callback.WaitForResult(); | 5975 rv = callback.WaitForResult(); |
5951 EXPECT_EQ(ERR_CONNECTION_RESET, rv); | 5976 EXPECT_EQ(ERR_CONNECTION_RESET, rv); |
5952 } | 5977 } |
5953 | 5978 |
5954 // Check that a connection closed after the start of the headers finishes ok. | 5979 // Check that a connection closed after the start of the headers finishes ok. |
5955 TEST_F(HttpNetworkTransactionTest, ConnectionClosedAfterStartOfHeaders) { | 5980 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectionClosedAfterStartOfHeaders) { |
5956 SessionDependencies session_deps; | 5981 SessionDependencies session_deps; |
5957 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 5982 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
5958 | 5983 |
5959 HttpRequestInfo request; | 5984 HttpRequestInfo request; |
5960 request.method = "GET"; | 5985 request.method = "GET"; |
5961 request.url = GURL("http://www.foo.com/"); | 5986 request.url = GURL("http://www.foo.com/"); |
5962 request.load_flags = 0; | 5987 request.load_flags = 0; |
5963 | 5988 |
5964 MockRead data_reads[] = { | 5989 MockRead data_reads[] = { |
5965 MockRead("HTTP/1."), | 5990 MockRead("HTTP/1."), |
(...skipping 21 matching lines...) Expand all Loading... |
5987 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); | 6012 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); |
5988 | 6013 |
5989 std::string response_data; | 6014 std::string response_data; |
5990 rv = ReadTransaction(trans.get(), &response_data); | 6015 rv = ReadTransaction(trans.get(), &response_data); |
5991 EXPECT_EQ(OK, rv); | 6016 EXPECT_EQ(OK, rv); |
5992 EXPECT_EQ("", response_data); | 6017 EXPECT_EQ("", response_data); |
5993 } | 6018 } |
5994 | 6019 |
5995 // Make sure that a dropped connection while draining the body for auth | 6020 // Make sure that a dropped connection while draining the body for auth |
5996 // restart does the right thing. | 6021 // restart does the right thing. |
5997 TEST_F(HttpNetworkTransactionTest, DrainResetOK) { | 6022 TEST_F(HttpNetworkTransactionSpdy2Test, DrainResetOK) { |
5998 SessionDependencies session_deps; | 6023 SessionDependencies session_deps; |
5999 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 6024 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
6000 | 6025 |
6001 HttpRequestInfo request; | 6026 HttpRequestInfo request; |
6002 request.method = "GET"; | 6027 request.method = "GET"; |
6003 request.url = GURL("http://www.google.com/"); | 6028 request.url = GURL("http://www.google.com/"); |
6004 request.load_flags = 0; | 6029 request.load_flags = 0; |
6005 | 6030 |
6006 MockWrite data_writes1[] = { | 6031 MockWrite data_writes1[] = { |
6007 MockWrite("GET / HTTP/1.1\r\n" | 6032 MockWrite("GET / HTTP/1.1\r\n" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6066 rv = callback2.WaitForResult(); | 6091 rv = callback2.WaitForResult(); |
6067 EXPECT_EQ(OK, rv); | 6092 EXPECT_EQ(OK, rv); |
6068 | 6093 |
6069 response = trans->GetResponseInfo(); | 6094 response = trans->GetResponseInfo(); |
6070 ASSERT_TRUE(response != NULL); | 6095 ASSERT_TRUE(response != NULL); |
6071 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 6096 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
6072 EXPECT_EQ(100, response->headers->GetContentLength()); | 6097 EXPECT_EQ(100, response->headers->GetContentLength()); |
6073 } | 6098 } |
6074 | 6099 |
6075 // Test HTTPS connections going through a proxy that sends extra data. | 6100 // Test HTTPS connections going through a proxy that sends extra data. |
6076 TEST_F(HttpNetworkTransactionTest, HTTPSViaProxyWithExtraData) { | 6101 TEST_F(HttpNetworkTransactionSpdy2Test, HTTPSViaProxyWithExtraData) { |
6077 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 6102 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
6078 | 6103 |
6079 HttpRequestInfo request; | 6104 HttpRequestInfo request; |
6080 request.method = "GET"; | 6105 request.method = "GET"; |
6081 request.url = GURL("https://www.google.com/"); | 6106 request.url = GURL("https://www.google.com/"); |
6082 request.load_flags = 0; | 6107 request.load_flags = 0; |
6083 | 6108 |
6084 MockRead proxy_reads[] = { | 6109 MockRead proxy_reads[] = { |
6085 MockRead("HTTP/1.0 200 Connected\r\n\r\nExtra data"), | 6110 MockRead("HTTP/1.0 200 Connected\r\n\r\nExtra data"), |
6086 MockRead(SYNCHRONOUS, OK) | 6111 MockRead(SYNCHRONOUS, OK) |
(...skipping 12 matching lines...) Expand all Loading... |
6099 scoped_ptr<HttpTransaction> trans( | 6124 scoped_ptr<HttpTransaction> trans( |
6100 new HttpNetworkTransaction(CreateSession(&session_deps))); | 6125 new HttpNetworkTransaction(CreateSession(&session_deps))); |
6101 | 6126 |
6102 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 6127 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
6103 EXPECT_EQ(ERR_IO_PENDING, rv); | 6128 EXPECT_EQ(ERR_IO_PENDING, rv); |
6104 | 6129 |
6105 rv = callback.WaitForResult(); | 6130 rv = callback.WaitForResult(); |
6106 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); | 6131 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); |
6107 } | 6132 } |
6108 | 6133 |
6109 TEST_F(HttpNetworkTransactionTest, LargeContentLengthThenClose) { | 6134 TEST_F(HttpNetworkTransactionSpdy2Test, LargeContentLengthThenClose) { |
6110 HttpRequestInfo request; | 6135 HttpRequestInfo request; |
6111 request.method = "GET"; | 6136 request.method = "GET"; |
6112 request.url = GURL("http://www.google.com/"); | 6137 request.url = GURL("http://www.google.com/"); |
6113 request.load_flags = 0; | 6138 request.load_flags = 0; |
6114 | 6139 |
6115 SessionDependencies session_deps; | 6140 SessionDependencies session_deps; |
6116 scoped_ptr<HttpTransaction> trans( | 6141 scoped_ptr<HttpTransaction> trans( |
6117 new HttpNetworkTransaction(CreateSession(&session_deps))); | 6142 new HttpNetworkTransaction(CreateSession(&session_deps))); |
6118 | 6143 |
6119 MockRead data_reads[] = { | 6144 MockRead data_reads[] = { |
(...skipping 15 matching lines...) Expand all Loading... |
6135 ASSERT_TRUE(response != NULL); | 6160 ASSERT_TRUE(response != NULL); |
6136 | 6161 |
6137 EXPECT_TRUE(response->headers != NULL); | 6162 EXPECT_TRUE(response->headers != NULL); |
6138 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); | 6163 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); |
6139 | 6164 |
6140 std::string response_data; | 6165 std::string response_data; |
6141 rv = ReadTransaction(trans.get(), &response_data); | 6166 rv = ReadTransaction(trans.get(), &response_data); |
6142 EXPECT_EQ(ERR_CONNECTION_CLOSED, rv); | 6167 EXPECT_EQ(ERR_CONNECTION_CLOSED, rv); |
6143 } | 6168 } |
6144 | 6169 |
6145 TEST_F(HttpNetworkTransactionTest, UploadFileSmallerThanLength) { | 6170 TEST_F(HttpNetworkTransactionSpdy2Test, UploadFileSmallerThanLength) { |
6146 HttpRequestInfo request; | 6171 HttpRequestInfo request; |
6147 request.method = "POST"; | 6172 request.method = "POST"; |
6148 request.url = GURL("http://www.google.com/upload"); | 6173 request.url = GURL("http://www.google.com/upload"); |
6149 request.upload_data = new UploadData; | 6174 request.upload_data = new UploadData; |
6150 request.load_flags = 0; | 6175 request.load_flags = 0; |
6151 | 6176 |
6152 SessionDependencies session_deps; | 6177 SessionDependencies session_deps; |
6153 scoped_ptr<HttpTransaction> trans( | 6178 scoped_ptr<HttpTransaction> trans( |
6154 new HttpNetworkTransaction(CreateSession(&session_deps))); | 6179 new HttpNetworkTransaction(CreateSession(&session_deps))); |
6155 | 6180 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6188 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); | 6213 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); |
6189 | 6214 |
6190 std::string response_data; | 6215 std::string response_data; |
6191 rv = ReadTransaction(trans.get(), &response_data); | 6216 rv = ReadTransaction(trans.get(), &response_data); |
6192 EXPECT_EQ(OK, rv); | 6217 EXPECT_EQ(OK, rv); |
6193 EXPECT_EQ("hello world", response_data); | 6218 EXPECT_EQ("hello world", response_data); |
6194 | 6219 |
6195 file_util::Delete(temp_file_path, false); | 6220 file_util::Delete(temp_file_path, false); |
6196 } | 6221 } |
6197 | 6222 |
6198 TEST_F(HttpNetworkTransactionTest, UploadUnreadableFile) { | 6223 TEST_F(HttpNetworkTransactionSpdy2Test, UploadUnreadableFile) { |
6199 HttpRequestInfo request; | 6224 HttpRequestInfo request; |
6200 request.method = "POST"; | 6225 request.method = "POST"; |
6201 request.url = GURL("http://www.google.com/upload"); | 6226 request.url = GURL("http://www.google.com/upload"); |
6202 request.upload_data = new UploadData; | 6227 request.upload_data = new UploadData; |
6203 request.load_flags = 0; | 6228 request.load_flags = 0; |
6204 | 6229 |
6205 // If we try to upload an unreadable file, the network stack should report | 6230 // If we try to upload an unreadable file, the network stack should report |
6206 // the file size as zero and upload zero bytes for that file. | 6231 // the file size as zero and upload zero bytes for that file. |
6207 SessionDependencies session_deps; | 6232 SessionDependencies session_deps; |
6208 scoped_ptr<HttpTransaction> trans( | 6233 scoped_ptr<HttpTransaction> trans( |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6245 EXPECT_EQ(OK, rv); | 6270 EXPECT_EQ(OK, rv); |
6246 | 6271 |
6247 const HttpResponseInfo* response = trans->GetResponseInfo(); | 6272 const HttpResponseInfo* response = trans->GetResponseInfo(); |
6248 ASSERT_TRUE(response != NULL); | 6273 ASSERT_TRUE(response != NULL); |
6249 EXPECT_TRUE(response->headers != NULL); | 6274 EXPECT_TRUE(response->headers != NULL); |
6250 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); | 6275 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); |
6251 | 6276 |
6252 file_util::Delete(temp_file, false); | 6277 file_util::Delete(temp_file, false); |
6253 } | 6278 } |
6254 | 6279 |
6255 TEST_F(HttpNetworkTransactionTest, UnreadableUploadFileAfterAuthRestart) { | 6280 TEST_F(HttpNetworkTransactionSpdy2Test, UnreadableUploadFileAfterAuthRestart) { |
6256 HttpRequestInfo request; | 6281 HttpRequestInfo request; |
6257 request.method = "POST"; | 6282 request.method = "POST"; |
6258 request.url = GURL("http://www.google.com/upload"); | 6283 request.url = GURL("http://www.google.com/upload"); |
6259 request.upload_data = new UploadData; | 6284 request.upload_data = new UploadData; |
6260 request.load_flags = 0; | 6285 request.load_flags = 0; |
6261 | 6286 |
6262 SessionDependencies session_deps; | 6287 SessionDependencies session_deps; |
6263 scoped_ptr<HttpTransaction> trans( | 6288 scoped_ptr<HttpTransaction> trans( |
6264 new HttpNetworkTransaction(CreateSession(&session_deps))); | 6289 new HttpNetworkTransaction(CreateSession(&session_deps))); |
6265 | 6290 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6334 response = trans->GetResponseInfo(); | 6359 response = trans->GetResponseInfo(); |
6335 ASSERT_TRUE(response != NULL); | 6360 ASSERT_TRUE(response != NULL); |
6336 EXPECT_TRUE(response->headers != NULL); | 6361 EXPECT_TRUE(response->headers != NULL); |
6337 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 6362 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
6338 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 6363 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
6339 | 6364 |
6340 file_util::Delete(temp_file, false); | 6365 file_util::Delete(temp_file, false); |
6341 } | 6366 } |
6342 | 6367 |
6343 // Tests that changes to Auth realms are treated like auth rejections. | 6368 // Tests that changes to Auth realms are treated like auth rejections. |
6344 TEST_F(HttpNetworkTransactionTest, ChangeAuthRealms) { | 6369 TEST_F(HttpNetworkTransactionSpdy2Test, ChangeAuthRealms) { |
6345 SessionDependencies session_deps; | 6370 SessionDependencies session_deps; |
6346 | 6371 |
6347 HttpRequestInfo request; | 6372 HttpRequestInfo request; |
6348 request.method = "GET"; | 6373 request.method = "GET"; |
6349 request.url = GURL("http://www.google.com/"); | 6374 request.url = GURL("http://www.google.com/"); |
6350 request.load_flags = 0; | 6375 request.load_flags = 0; |
6351 | 6376 |
6352 // First transaction will request a resource and receive a Basic challenge | 6377 // First transaction will request a resource and receive a Basic challenge |
6353 // with realm="first_realm". | 6378 // with realm="first_realm". |
6354 MockWrite data_writes1[] = { | 6379 MockWrite data_writes1[] = { |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6486 rv = trans->RestartWithAuth( | 6511 rv = trans->RestartWithAuth( |
6487 AuthCredentials(kFirst, kBar), callback4.callback()); | 6512 AuthCredentials(kFirst, kBar), callback4.callback()); |
6488 EXPECT_EQ(ERR_IO_PENDING, rv); | 6513 EXPECT_EQ(ERR_IO_PENDING, rv); |
6489 rv = callback4.WaitForResult(); | 6514 rv = callback4.WaitForResult(); |
6490 EXPECT_EQ(OK, rv); | 6515 EXPECT_EQ(OK, rv); |
6491 response = trans->GetResponseInfo(); | 6516 response = trans->GetResponseInfo(); |
6492 ASSERT_TRUE(response != NULL); | 6517 ASSERT_TRUE(response != NULL); |
6493 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 6518 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
6494 } | 6519 } |
6495 | 6520 |
6496 TEST_F(HttpNetworkTransactionTest, HonorAlternateProtocolHeader) { | 6521 TEST_F(HttpNetworkTransactionSpdy2Test, HonorAlternateProtocolHeader) { |
6497 HttpStreamFactory::set_next_protos(MakeNextProtos("foo", "bar", NULL)); | 6522 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); |
6498 HttpStreamFactory::set_use_alternate_protocols(true); | 6523 HttpStreamFactory::set_use_alternate_protocols(true); |
6499 | 6524 |
6500 SessionDependencies session_deps; | 6525 SessionDependencies session_deps; |
6501 | 6526 |
6502 MockRead data_reads[] = { | 6527 MockRead data_reads[] = { |
6503 MockRead("HTTP/1.1 200 OK\r\n"), | 6528 MockRead("HTTP/1.1 200 OK\r\n"), |
6504 MockRead(kAlternateProtocolHttpHeader), | 6529 MockRead(kAlternateProtocolHttpHeader), |
6505 MockRead("hello world"), | 6530 MockRead("hello world"), |
6506 MockRead(SYNCHRONOUS, OK), | 6531 MockRead(SYNCHRONOUS, OK), |
6507 }; | 6532 }; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6540 | 6565 |
6541 std::string response_data; | 6566 std::string response_data; |
6542 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 6567 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
6543 EXPECT_EQ("hello world", response_data); | 6568 EXPECT_EQ("hello world", response_data); |
6544 | 6569 |
6545 ASSERT_TRUE(http_server_properties.HasAlternateProtocol(http_host_port_pair)); | 6570 ASSERT_TRUE(http_server_properties.HasAlternateProtocol(http_host_port_pair)); |
6546 const PortAlternateProtocolPair alternate = | 6571 const PortAlternateProtocolPair alternate = |
6547 http_server_properties.GetAlternateProtocol(http_host_port_pair); | 6572 http_server_properties.GetAlternateProtocol(http_host_port_pair); |
6548 PortAlternateProtocolPair expected_alternate; | 6573 PortAlternateProtocolPair expected_alternate; |
6549 expected_alternate.port = 443; | 6574 expected_alternate.port = 443; |
6550 expected_alternate.protocol = NPN_SPDY_21; | 6575 expected_alternate.protocol = NPN_SPDY_2; |
6551 EXPECT_TRUE(expected_alternate.Equals(alternate)); | 6576 EXPECT_TRUE(expected_alternate.Equals(alternate)); |
6552 | 6577 |
6553 HttpStreamFactory::set_use_alternate_protocols(false); | 6578 HttpStreamFactory::set_use_alternate_protocols(false); |
6554 HttpStreamFactory::set_next_protos(std::vector<std::string>()); | 6579 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); |
6555 } | 6580 } |
6556 | 6581 |
6557 TEST_F(HttpNetworkTransactionTest, MarkBrokenAlternateProtocolAndFallback) { | 6582 TEST_F(HttpNetworkTransactionSpdy2Test, |
| 6583 MarkBrokenAlternateProtocolAndFallback) { |
6558 HttpStreamFactory::set_use_alternate_protocols(true); | 6584 HttpStreamFactory::set_use_alternate_protocols(true); |
6559 SessionDependencies session_deps; | 6585 SessionDependencies session_deps; |
6560 | 6586 |
6561 HttpRequestInfo request; | 6587 HttpRequestInfo request; |
6562 request.method = "GET"; | 6588 request.method = "GET"; |
6563 request.url = GURL("http://www.google.com/"); | 6589 request.url = GURL("http://www.google.com/"); |
6564 request.load_flags = 0; | 6590 request.load_flags = 0; |
6565 | 6591 |
6566 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); | 6592 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); |
6567 StaticSocketDataProvider first_data; | 6593 StaticSocketDataProvider first_data; |
(...skipping 11 matching lines...) Expand all Loading... |
6579 | 6605 |
6580 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 6606 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
6581 | 6607 |
6582 HttpServerProperties* http_server_properties = | 6608 HttpServerProperties* http_server_properties = |
6583 session->http_server_properties(); | 6609 session->http_server_properties(); |
6584 // Port must be < 1024, or the header will be ignored (since initial port was | 6610 // Port must be < 1024, or the header will be ignored (since initial port was |
6585 // port 80 (another restricted port). | 6611 // port 80 (another restricted port). |
6586 http_server_properties->SetAlternateProtocol( | 6612 http_server_properties->SetAlternateProtocol( |
6587 HostPortPair::FromURL(request.url), | 6613 HostPortPair::FromURL(request.url), |
6588 666 /* port is ignored by MockConnect anyway */, | 6614 666 /* port is ignored by MockConnect anyway */, |
6589 NPN_SPDY_21); | 6615 NPN_SPDY_2); |
6590 | 6616 |
6591 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 6617 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
6592 TestCompletionCallback callback; | 6618 TestCompletionCallback callback; |
6593 | 6619 |
6594 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 6620 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
6595 EXPECT_EQ(ERR_IO_PENDING, rv); | 6621 EXPECT_EQ(ERR_IO_PENDING, rv); |
6596 EXPECT_EQ(OK, callback.WaitForResult()); | 6622 EXPECT_EQ(OK, callback.WaitForResult()); |
6597 | 6623 |
6598 const HttpResponseInfo* response = trans->GetResponseInfo(); | 6624 const HttpResponseInfo* response = trans->GetResponseInfo(); |
6599 ASSERT_TRUE(response != NULL); | 6625 ASSERT_TRUE(response != NULL); |
6600 ASSERT_TRUE(response->headers != NULL); | 6626 ASSERT_TRUE(response->headers != NULL); |
6601 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 6627 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
6602 | 6628 |
6603 std::string response_data; | 6629 std::string response_data; |
6604 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 6630 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
6605 EXPECT_EQ("hello world", response_data); | 6631 EXPECT_EQ("hello world", response_data); |
6606 | 6632 |
6607 ASSERT_TRUE(http_server_properties->HasAlternateProtocol( | 6633 ASSERT_TRUE(http_server_properties->HasAlternateProtocol( |
6608 HostPortPair::FromURL(request.url))); | 6634 HostPortPair::FromURL(request.url))); |
6609 const PortAlternateProtocolPair alternate = | 6635 const PortAlternateProtocolPair alternate = |
6610 http_server_properties->GetAlternateProtocol( | 6636 http_server_properties->GetAlternateProtocol( |
6611 HostPortPair::FromURL(request.url)); | 6637 HostPortPair::FromURL(request.url)); |
6612 EXPECT_EQ(ALTERNATE_PROTOCOL_BROKEN, alternate.protocol); | 6638 EXPECT_EQ(ALTERNATE_PROTOCOL_BROKEN, alternate.protocol); |
6613 HttpStreamFactory::set_use_alternate_protocols(false); | 6639 HttpStreamFactory::set_use_alternate_protocols(false); |
6614 } | 6640 } |
6615 | 6641 |
6616 TEST_F(HttpNetworkTransactionTest, AlternateProtocolPortRestrictedBlocked) { | 6642 TEST_F(HttpNetworkTransactionSpdy2Test, |
| 6643 AlternateProtocolPortRestrictedBlocked) { |
6617 // Ensure that we're not allowed to redirect traffic via an alternate | 6644 // Ensure that we're not allowed to redirect traffic via an alternate |
6618 // protocol to an unrestricted (port >= 1024) when the original traffic was | 6645 // protocol to an unrestricted (port >= 1024) when the original traffic was |
6619 // on a restricted port (port < 1024). Ensure that we can redirect in all | 6646 // on a restricted port (port < 1024). Ensure that we can redirect in all |
6620 // other cases. | 6647 // other cases. |
6621 HttpStreamFactory::set_use_alternate_protocols(true); | 6648 HttpStreamFactory::set_use_alternate_protocols(true); |
6622 SessionDependencies session_deps; | 6649 SessionDependencies session_deps; |
6623 | 6650 |
6624 HttpRequestInfo restricted_port_request; | 6651 HttpRequestInfo restricted_port_request; |
6625 restricted_port_request.method = "GET"; | 6652 restricted_port_request.method = "GET"; |
6626 restricted_port_request.url = GURL("http://www.google.com:1023/"); | 6653 restricted_port_request.url = GURL("http://www.google.com:1023/"); |
(...skipping 14 matching lines...) Expand all Loading... |
6641 session_deps.socket_factory.AddSocketDataProvider(&second_data); | 6668 session_deps.socket_factory.AddSocketDataProvider(&second_data); |
6642 | 6669 |
6643 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 6670 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
6644 | 6671 |
6645 HttpServerProperties* http_server_properties = | 6672 HttpServerProperties* http_server_properties = |
6646 session->http_server_properties(); | 6673 session->http_server_properties(); |
6647 const int kUnrestrictedAlternatePort = 1024; | 6674 const int kUnrestrictedAlternatePort = 1024; |
6648 http_server_properties->SetAlternateProtocol( | 6675 http_server_properties->SetAlternateProtocol( |
6649 HostPortPair::FromURL(restricted_port_request.url), | 6676 HostPortPair::FromURL(restricted_port_request.url), |
6650 kUnrestrictedAlternatePort, | 6677 kUnrestrictedAlternatePort, |
6651 NPN_SPDY_21); | 6678 NPN_SPDY_2); |
6652 | 6679 |
6653 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 6680 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
6654 TestCompletionCallback callback; | 6681 TestCompletionCallback callback; |
6655 | 6682 |
6656 int rv = trans->Start( | 6683 int rv = trans->Start( |
6657 &restricted_port_request, callback.callback(), BoundNetLog()); | 6684 &restricted_port_request, callback.callback(), BoundNetLog()); |
6658 EXPECT_EQ(ERR_IO_PENDING, rv); | 6685 EXPECT_EQ(ERR_IO_PENDING, rv); |
6659 // Invalid change to unrestricted port should fail. | 6686 // Invalid change to unrestricted port should fail. |
6660 EXPECT_EQ(ERR_CONNECTION_REFUSED, callback.WaitForResult()); | 6687 EXPECT_EQ(ERR_CONNECTION_REFUSED, callback.WaitForResult()); |
6661 | 6688 |
6662 HttpStreamFactory::set_use_alternate_protocols(false); | 6689 HttpStreamFactory::set_use_alternate_protocols(false); |
6663 } | 6690 } |
6664 | 6691 |
6665 TEST_F(HttpNetworkTransactionTest, AlternateProtocolPortRestrictedAllowed) { | 6692 TEST_F(HttpNetworkTransactionSpdy2Test, |
| 6693 AlternateProtocolPortRestrictedAllowed) { |
6666 // Ensure that we're not allowed to redirect traffic via an alternate | 6694 // Ensure that we're not allowed to redirect traffic via an alternate |
6667 // protocol to an unrestricted (port >= 1024) when the original traffic was | 6695 // protocol to an unrestricted (port >= 1024) when the original traffic was |
6668 // on a restricted port (port < 1024). Ensure that we can redirect in all | 6696 // on a restricted port (port < 1024). Ensure that we can redirect in all |
6669 // other cases. | 6697 // other cases. |
6670 HttpStreamFactory::set_use_alternate_protocols(true); | 6698 HttpStreamFactory::set_use_alternate_protocols(true); |
6671 SessionDependencies session_deps; | 6699 SessionDependencies session_deps; |
6672 | 6700 |
6673 HttpRequestInfo restricted_port_request; | 6701 HttpRequestInfo restricted_port_request; |
6674 restricted_port_request.method = "GET"; | 6702 restricted_port_request.method = "GET"; |
6675 restricted_port_request.url = GURL("http://www.google.com:1023/"); | 6703 restricted_port_request.url = GURL("http://www.google.com:1023/"); |
(...skipping 14 matching lines...) Expand all Loading... |
6690 session_deps.socket_factory.AddSocketDataProvider(&second_data); | 6718 session_deps.socket_factory.AddSocketDataProvider(&second_data); |
6691 | 6719 |
6692 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 6720 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
6693 | 6721 |
6694 HttpServerProperties* http_server_properties = | 6722 HttpServerProperties* http_server_properties = |
6695 session->http_server_properties(); | 6723 session->http_server_properties(); |
6696 const int kRestrictedAlternatePort = 80; | 6724 const int kRestrictedAlternatePort = 80; |
6697 http_server_properties->SetAlternateProtocol( | 6725 http_server_properties->SetAlternateProtocol( |
6698 HostPortPair::FromURL(restricted_port_request.url), | 6726 HostPortPair::FromURL(restricted_port_request.url), |
6699 kRestrictedAlternatePort, | 6727 kRestrictedAlternatePort, |
6700 NPN_SPDY_21); | 6728 NPN_SPDY_2); |
6701 | 6729 |
6702 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 6730 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
6703 TestCompletionCallback callback; | 6731 TestCompletionCallback callback; |
6704 | 6732 |
6705 int rv = trans->Start( | 6733 int rv = trans->Start( |
6706 &restricted_port_request, callback.callback(), BoundNetLog()); | 6734 &restricted_port_request, callback.callback(), BoundNetLog()); |
6707 EXPECT_EQ(ERR_IO_PENDING, rv); | 6735 EXPECT_EQ(ERR_IO_PENDING, rv); |
6708 // Valid change to restricted port should pass. | 6736 // Valid change to restricted port should pass. |
6709 EXPECT_EQ(OK, callback.WaitForResult()); | 6737 EXPECT_EQ(OK, callback.WaitForResult()); |
6710 | 6738 |
6711 HttpStreamFactory::set_use_alternate_protocols(false); | 6739 HttpStreamFactory::set_use_alternate_protocols(false); |
6712 } | 6740 } |
6713 | 6741 |
6714 TEST_F(HttpNetworkTransactionTest, AlternateProtocolPortUnrestrictedAllowed1) { | 6742 TEST_F(HttpNetworkTransactionSpdy2Test, |
| 6743 AlternateProtocolPortUnrestrictedAllowed1) { |
6715 // Ensure that we're not allowed to redirect traffic via an alternate | 6744 // Ensure that we're not allowed to redirect traffic via an alternate |
6716 // protocol to an unrestricted (port >= 1024) when the original traffic was | 6745 // protocol to an unrestricted (port >= 1024) when the original traffic was |
6717 // on a restricted port (port < 1024). Ensure that we can redirect in all | 6746 // on a restricted port (port < 1024). Ensure that we can redirect in all |
6718 // other cases. | 6747 // other cases. |
6719 HttpStreamFactory::set_use_alternate_protocols(true); | 6748 HttpStreamFactory::set_use_alternate_protocols(true); |
6720 SessionDependencies session_deps; | 6749 SessionDependencies session_deps; |
6721 | 6750 |
6722 HttpRequestInfo unrestricted_port_request; | 6751 HttpRequestInfo unrestricted_port_request; |
6723 unrestricted_port_request.method = "GET"; | 6752 unrestricted_port_request.method = "GET"; |
6724 unrestricted_port_request.url = GURL("http://www.google.com:1024/"); | 6753 unrestricted_port_request.url = GURL("http://www.google.com:1024/"); |
(...skipping 14 matching lines...) Expand all Loading... |
6739 session_deps.socket_factory.AddSocketDataProvider(&second_data); | 6768 session_deps.socket_factory.AddSocketDataProvider(&second_data); |
6740 | 6769 |
6741 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 6770 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
6742 | 6771 |
6743 HttpServerProperties* http_server_properties = | 6772 HttpServerProperties* http_server_properties = |
6744 session->http_server_properties(); | 6773 session->http_server_properties(); |
6745 const int kRestrictedAlternatePort = 80; | 6774 const int kRestrictedAlternatePort = 80; |
6746 http_server_properties->SetAlternateProtocol( | 6775 http_server_properties->SetAlternateProtocol( |
6747 HostPortPair::FromURL(unrestricted_port_request.url), | 6776 HostPortPair::FromURL(unrestricted_port_request.url), |
6748 kRestrictedAlternatePort, | 6777 kRestrictedAlternatePort, |
6749 NPN_SPDY_21); | 6778 NPN_SPDY_2); |
6750 | 6779 |
6751 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 6780 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
6752 TestCompletionCallback callback; | 6781 TestCompletionCallback callback; |
6753 | 6782 |
6754 int rv = trans->Start( | 6783 int rv = trans->Start( |
6755 &unrestricted_port_request, callback.callback(), BoundNetLog()); | 6784 &unrestricted_port_request, callback.callback(), BoundNetLog()); |
6756 EXPECT_EQ(ERR_IO_PENDING, rv); | 6785 EXPECT_EQ(ERR_IO_PENDING, rv); |
6757 // Valid change to restricted port should pass. | 6786 // Valid change to restricted port should pass. |
6758 EXPECT_EQ(OK, callback.WaitForResult()); | 6787 EXPECT_EQ(OK, callback.WaitForResult()); |
6759 | 6788 |
6760 HttpStreamFactory::set_use_alternate_protocols(false); | 6789 HttpStreamFactory::set_use_alternate_protocols(false); |
6761 } | 6790 } |
6762 | 6791 |
6763 TEST_F(HttpNetworkTransactionTest, AlternateProtocolPortUnrestrictedAllowed2) { | 6792 TEST_F(HttpNetworkTransactionSpdy2Test, |
| 6793 AlternateProtocolPortUnrestrictedAllowed2) { |
6764 // Ensure that we're not allowed to redirect traffic via an alternate | 6794 // Ensure that we're not allowed to redirect traffic via an alternate |
6765 // protocol to an unrestricted (port >= 1024) when the original traffic was | 6795 // protocol to an unrestricted (port >= 1024) when the original traffic was |
6766 // on a restricted port (port < 1024). Ensure that we can redirect in all | 6796 // on a restricted port (port < 1024). Ensure that we can redirect in all |
6767 // other cases. | 6797 // other cases. |
6768 HttpStreamFactory::set_use_alternate_protocols(true); | 6798 HttpStreamFactory::set_use_alternate_protocols(true); |
6769 SessionDependencies session_deps; | 6799 SessionDependencies session_deps; |
6770 | 6800 |
6771 HttpRequestInfo unrestricted_port_request; | 6801 HttpRequestInfo unrestricted_port_request; |
6772 unrestricted_port_request.method = "GET"; | 6802 unrestricted_port_request.method = "GET"; |
6773 unrestricted_port_request.url = GURL("http://www.google.com:1024/"); | 6803 unrestricted_port_request.url = GURL("http://www.google.com:1024/"); |
(...skipping 14 matching lines...) Expand all Loading... |
6788 session_deps.socket_factory.AddSocketDataProvider(&second_data); | 6818 session_deps.socket_factory.AddSocketDataProvider(&second_data); |
6789 | 6819 |
6790 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 6820 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
6791 | 6821 |
6792 HttpServerProperties* http_server_properties = | 6822 HttpServerProperties* http_server_properties = |
6793 session->http_server_properties(); | 6823 session->http_server_properties(); |
6794 const int kUnrestrictedAlternatePort = 1024; | 6824 const int kUnrestrictedAlternatePort = 1024; |
6795 http_server_properties->SetAlternateProtocol( | 6825 http_server_properties->SetAlternateProtocol( |
6796 HostPortPair::FromURL(unrestricted_port_request.url), | 6826 HostPortPair::FromURL(unrestricted_port_request.url), |
6797 kUnrestrictedAlternatePort, | 6827 kUnrestrictedAlternatePort, |
6798 NPN_SPDY_21); | 6828 NPN_SPDY_2); |
6799 | 6829 |
6800 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 6830 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
6801 TestCompletionCallback callback; | 6831 TestCompletionCallback callback; |
6802 | 6832 |
6803 int rv = trans->Start( | 6833 int rv = trans->Start( |
6804 &unrestricted_port_request, callback.callback(), BoundNetLog()); | 6834 &unrestricted_port_request, callback.callback(), BoundNetLog()); |
6805 EXPECT_EQ(ERR_IO_PENDING, rv); | 6835 EXPECT_EQ(ERR_IO_PENDING, rv); |
6806 // Valid change to an unrestricted port should pass. | 6836 // Valid change to an unrestricted port should pass. |
6807 EXPECT_EQ(OK, callback.WaitForResult()); | 6837 EXPECT_EQ(OK, callback.WaitForResult()); |
6808 | 6838 |
6809 HttpStreamFactory::set_use_alternate_protocols(false); | 6839 HttpStreamFactory::set_use_alternate_protocols(false); |
6810 } | 6840 } |
6811 | 6841 |
6812 TEST_F(HttpNetworkTransactionTest, AlternateProtocolUnsafeBlocked) { | 6842 TEST_F(HttpNetworkTransactionSpdy2Test, |
| 6843 AlternateProtocolUnsafeBlocked) { |
6813 // Ensure that we're not allowed to redirect traffic via an alternate | 6844 // Ensure that we're not allowed to redirect traffic via an alternate |
6814 // protocol to an unsafe port, and that we resume the second | 6845 // protocol to an unsafe port, and that we resume the second |
6815 // HttpStreamFactoryImpl::Job once the alternate protocol request fails. | 6846 // HttpStreamFactoryImpl::Job once the alternate protocol request fails. |
6816 HttpStreamFactory::set_use_alternate_protocols(true); | 6847 HttpStreamFactory::set_use_alternate_protocols(true); |
6817 SessionDependencies session_deps; | 6848 SessionDependencies session_deps; |
6818 | 6849 |
6819 HttpRequestInfo request; | 6850 HttpRequestInfo request; |
6820 request.method = "GET"; | 6851 request.method = "GET"; |
6821 request.url = GURL("http://www.google.com/"); | 6852 request.url = GURL("http://www.google.com/"); |
6822 request.load_flags = 0; | 6853 request.load_flags = 0; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6856 const HttpResponseInfo* response = trans->GetResponseInfo(); | 6887 const HttpResponseInfo* response = trans->GetResponseInfo(); |
6857 ASSERT_TRUE(response != NULL); | 6888 ASSERT_TRUE(response != NULL); |
6858 ASSERT_TRUE(response->headers != NULL); | 6889 ASSERT_TRUE(response->headers != NULL); |
6859 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 6890 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
6860 | 6891 |
6861 std::string response_data; | 6892 std::string response_data; |
6862 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 6893 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
6863 EXPECT_EQ("hello world", response_data); | 6894 EXPECT_EQ("hello world", response_data); |
6864 } | 6895 } |
6865 | 6896 |
6866 TEST_F(HttpNetworkTransactionTest, UseAlternateProtocolForNpnSpdy) { | 6897 TEST_F(HttpNetworkTransactionSpdy2Test, UseAlternateProtocolForNpnSpdy) { |
6867 HttpStreamFactory::set_use_alternate_protocols(true); | 6898 HttpStreamFactory::set_use_alternate_protocols(true); |
6868 HttpStreamFactory::set_next_protos(SpdyNextProtos()); | 6899 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); |
6869 SessionDependencies session_deps; | 6900 SessionDependencies session_deps; |
6870 | 6901 |
6871 HttpRequestInfo request; | 6902 HttpRequestInfo request; |
6872 request.method = "GET"; | 6903 request.method = "GET"; |
6873 request.url = GURL("http://www.google.com/"); | 6904 request.url = GURL("http://www.google.com/"); |
6874 request.load_flags = 0; | 6905 request.load_flags = 0; |
6875 | 6906 |
6876 MockRead data_reads[] = { | 6907 MockRead data_reads[] = { |
6877 MockRead("HTTP/1.1 200 OK\r\n"), | 6908 MockRead("HTTP/1.1 200 OK\r\n"), |
6878 MockRead(kAlternateProtocolHttpHeader), | 6909 MockRead(kAlternateProtocolHttpHeader), |
6879 MockRead("hello world"), | 6910 MockRead("hello world"), |
6880 MockRead(ASYNC, OK), | 6911 MockRead(ASYNC, OK), |
6881 }; | 6912 }; |
6882 | 6913 |
6883 StaticSocketDataProvider first_transaction( | 6914 StaticSocketDataProvider first_transaction( |
6884 data_reads, arraysize(data_reads), NULL, 0); | 6915 data_reads, arraysize(data_reads), NULL, 0); |
6885 session_deps.socket_factory.AddSocketDataProvider(&first_transaction); | 6916 session_deps.socket_factory.AddSocketDataProvider(&first_transaction); |
6886 | 6917 |
6887 SSLSocketDataProvider ssl(ASYNC, OK); | 6918 SSLSocketDataProvider ssl(ASYNC, OK); |
6888 ssl.SetNextProto(SSLClientSocket::kProtoSPDY21); | 6919 ssl.SetNextProto(SSLClientSocket::kProtoSPDY2); |
6889 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 6920 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
6890 | 6921 |
6891 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 6922 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
6892 MockWrite spdy_writes[] = { CreateMockWrite(*req) }; | 6923 MockWrite spdy_writes[] = { CreateMockWrite(*req) }; |
6893 | 6924 |
6894 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 6925 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
6895 scoped_ptr<spdy::SpdyFrame> data(ConstructSpdyBodyFrame(1, true)); | 6926 scoped_ptr<spdy::SpdyFrame> data(ConstructSpdyBodyFrame(1, true)); |
6896 MockRead spdy_reads[] = { | 6927 MockRead spdy_reads[] = { |
6897 CreateMockRead(*resp), | 6928 CreateMockRead(*resp), |
6898 CreateMockRead(*data), | 6929 CreateMockRead(*data), |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6941 response = trans->GetResponseInfo(); | 6972 response = trans->GetResponseInfo(); |
6942 ASSERT_TRUE(response != NULL); | 6973 ASSERT_TRUE(response != NULL); |
6943 ASSERT_TRUE(response->headers != NULL); | 6974 ASSERT_TRUE(response->headers != NULL); |
6944 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 6975 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
6945 EXPECT_TRUE(response->was_fetched_via_spdy); | 6976 EXPECT_TRUE(response->was_fetched_via_spdy); |
6946 EXPECT_TRUE(response->was_npn_negotiated); | 6977 EXPECT_TRUE(response->was_npn_negotiated); |
6947 | 6978 |
6948 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 6979 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
6949 EXPECT_EQ("hello!", response_data); | 6980 EXPECT_EQ("hello!", response_data); |
6950 | 6981 |
6951 HttpStreamFactory::set_next_protos(std::vector<std::string>()); | 6982 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); |
6952 HttpStreamFactory::set_use_alternate_protocols(false); | 6983 HttpStreamFactory::set_use_alternate_protocols(false); |
6953 } | 6984 } |
6954 | 6985 |
6955 TEST_F(HttpNetworkTransactionTest, AlternateProtocolWithSpdyLateBinding) { | 6986 TEST_F(HttpNetworkTransactionSpdy2Test, AlternateProtocolWithSpdyLateBinding) { |
6956 HttpStreamFactory::set_use_alternate_protocols(true); | 6987 HttpStreamFactory::set_use_alternate_protocols(true); |
6957 HttpStreamFactory::set_next_protos(SpdyNextProtos()); | 6988 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); |
6958 SessionDependencies session_deps; | 6989 SessionDependencies session_deps; |
6959 | 6990 |
6960 HttpRequestInfo request; | 6991 HttpRequestInfo request; |
6961 request.method = "GET"; | 6992 request.method = "GET"; |
6962 request.url = GURL("http://www.google.com/"); | 6993 request.url = GURL("http://www.google.com/"); |
6963 request.load_flags = 0; | 6994 request.load_flags = 0; |
6964 | 6995 |
6965 MockRead data_reads[] = { | 6996 MockRead data_reads[] = { |
6966 MockRead("HTTP/1.1 200 OK\r\n"), | 6997 MockRead("HTTP/1.1 200 OK\r\n"), |
6967 MockRead(kAlternateProtocolHttpHeader), | 6998 MockRead(kAlternateProtocolHttpHeader), |
6968 MockRead("hello world"), | 6999 MockRead("hello world"), |
6969 MockRead(ASYNC, OK), | 7000 MockRead(ASYNC, OK), |
6970 }; | 7001 }; |
6971 | 7002 |
6972 StaticSocketDataProvider first_transaction( | 7003 StaticSocketDataProvider first_transaction( |
6973 data_reads, arraysize(data_reads), NULL, 0); | 7004 data_reads, arraysize(data_reads), NULL, 0); |
6974 // Socket 1 is the HTTP transaction with the Alternate-Protocol header. | 7005 // Socket 1 is the HTTP transaction with the Alternate-Protocol header. |
6975 session_deps.socket_factory.AddSocketDataProvider(&first_transaction); | 7006 session_deps.socket_factory.AddSocketDataProvider(&first_transaction); |
6976 | 7007 |
6977 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); | 7008 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); |
6978 StaticSocketDataProvider hanging_socket( | 7009 StaticSocketDataProvider hanging_socket( |
6979 NULL, 0, NULL, 0); | 7010 NULL, 0, NULL, 0); |
6980 hanging_socket.set_connect_data(never_finishing_connect); | 7011 hanging_socket.set_connect_data(never_finishing_connect); |
6981 // Socket 2 and 3 are the hanging Alternate-Protocol and | 7012 // Socket 2 and 3 are the hanging Alternate-Protocol and |
6982 // non-Alternate-Protocol jobs from the 2nd transaction. | 7013 // non-Alternate-Protocol jobs from the 2nd transaction. |
6983 session_deps.socket_factory.AddSocketDataProvider(&hanging_socket); | 7014 session_deps.socket_factory.AddSocketDataProvider(&hanging_socket); |
6984 session_deps.socket_factory.AddSocketDataProvider(&hanging_socket); | 7015 session_deps.socket_factory.AddSocketDataProvider(&hanging_socket); |
6985 | 7016 |
6986 SSLSocketDataProvider ssl(ASYNC, OK); | 7017 SSLSocketDataProvider ssl(ASYNC, OK); |
6987 ssl.SetNextProto(SSLClientSocket::kProtoSPDY21); | 7018 ssl.SetNextProto(SSLClientSocket::kProtoSPDY2); |
6988 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 7019 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
6989 | 7020 |
6990 scoped_ptr<spdy::SpdyFrame> req1(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 7021 scoped_ptr<spdy::SpdyFrame> req1(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
6991 scoped_ptr<spdy::SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST)); | 7022 scoped_ptr<spdy::SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST)); |
6992 MockWrite spdy_writes[] = { | 7023 MockWrite spdy_writes[] = { |
6993 CreateMockWrite(*req1), | 7024 CreateMockWrite(*req1), |
6994 CreateMockWrite(*req2), | 7025 CreateMockWrite(*req2), |
6995 }; | 7026 }; |
6996 scoped_ptr<spdy::SpdyFrame> resp1(ConstructSpdyGetSynReply(NULL, 0, 1)); | 7027 scoped_ptr<spdy::SpdyFrame> resp1(ConstructSpdyGetSynReply(NULL, 0, 1)); |
6997 scoped_ptr<spdy::SpdyFrame> data1(ConstructSpdyBodyFrame(1, true)); | 7028 scoped_ptr<spdy::SpdyFrame> data1(ConstructSpdyBodyFrame(1, true)); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7057 | 7088 |
7058 response = trans3.GetResponseInfo(); | 7089 response = trans3.GetResponseInfo(); |
7059 ASSERT_TRUE(response != NULL); | 7090 ASSERT_TRUE(response != NULL); |
7060 ASSERT_TRUE(response->headers != NULL); | 7091 ASSERT_TRUE(response->headers != NULL); |
7061 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 7092 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
7062 EXPECT_TRUE(response->was_fetched_via_spdy); | 7093 EXPECT_TRUE(response->was_fetched_via_spdy); |
7063 EXPECT_TRUE(response->was_npn_negotiated); | 7094 EXPECT_TRUE(response->was_npn_negotiated); |
7064 ASSERT_EQ(OK, ReadTransaction(&trans3, &response_data)); | 7095 ASSERT_EQ(OK, ReadTransaction(&trans3, &response_data)); |
7065 EXPECT_EQ("hello!", response_data); | 7096 EXPECT_EQ("hello!", response_data); |
7066 | 7097 |
7067 HttpStreamFactory::set_next_protos(std::vector<std::string>()); | 7098 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); |
7068 HttpStreamFactory::set_use_alternate_protocols(false); | 7099 HttpStreamFactory::set_use_alternate_protocols(false); |
7069 } | 7100 } |
7070 | 7101 |
7071 TEST_F(HttpNetworkTransactionTest, StallAlternateProtocolForNpnSpdy) { | 7102 TEST_F(HttpNetworkTransactionSpdy2Test, StallAlternateProtocolForNpnSpdy) { |
7072 HttpStreamFactory::set_use_alternate_protocols(true); | 7103 HttpStreamFactory::set_use_alternate_protocols(true); |
7073 HttpStreamFactory::set_next_protos(SpdyNextProtos()); | 7104 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); |
7074 SessionDependencies session_deps; | 7105 SessionDependencies session_deps; |
7075 | 7106 |
7076 HttpRequestInfo request; | 7107 HttpRequestInfo request; |
7077 request.method = "GET"; | 7108 request.method = "GET"; |
7078 request.url = GURL("http://www.google.com/"); | 7109 request.url = GURL("http://www.google.com/"); |
7079 request.load_flags = 0; | 7110 request.load_flags = 0; |
7080 | 7111 |
7081 MockRead data_reads[] = { | 7112 MockRead data_reads[] = { |
7082 MockRead("HTTP/1.1 200 OK\r\n"), | 7113 MockRead("HTTP/1.1 200 OK\r\n"), |
7083 MockRead(kAlternateProtocolHttpHeader), | 7114 MockRead(kAlternateProtocolHttpHeader), |
7084 MockRead("hello world"), | 7115 MockRead("hello world"), |
7085 MockRead(ASYNC, OK), | 7116 MockRead(ASYNC, OK), |
7086 }; | 7117 }; |
7087 | 7118 |
7088 StaticSocketDataProvider first_transaction( | 7119 StaticSocketDataProvider first_transaction( |
7089 data_reads, arraysize(data_reads), NULL, 0); | 7120 data_reads, arraysize(data_reads), NULL, 0); |
7090 session_deps.socket_factory.AddSocketDataProvider(&first_transaction); | 7121 session_deps.socket_factory.AddSocketDataProvider(&first_transaction); |
7091 | 7122 |
7092 SSLSocketDataProvider ssl(ASYNC, OK); | 7123 SSLSocketDataProvider ssl(ASYNC, OK); |
7093 ssl.SetNextProto(SSLClientSocket::kProtoSPDY21); | 7124 ssl.SetNextProto(SSLClientSocket::kProtoSPDY2); |
7094 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 7125 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
7095 | 7126 |
7096 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); | 7127 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); |
7097 StaticSocketDataProvider hanging_alternate_protocol_socket( | 7128 StaticSocketDataProvider hanging_alternate_protocol_socket( |
7098 NULL, 0, NULL, 0); | 7129 NULL, 0, NULL, 0); |
7099 hanging_alternate_protocol_socket.set_connect_data( | 7130 hanging_alternate_protocol_socket.set_connect_data( |
7100 never_finishing_connect); | 7131 never_finishing_connect); |
7101 session_deps.socket_factory.AddSocketDataProvider( | 7132 session_deps.socket_factory.AddSocketDataProvider( |
7102 &hanging_alternate_protocol_socket); | 7133 &hanging_alternate_protocol_socket); |
7103 | 7134 |
(...skipping 27 matching lines...) Expand all Loading... |
7131 response = trans->GetResponseInfo(); | 7162 response = trans->GetResponseInfo(); |
7132 ASSERT_TRUE(response != NULL); | 7163 ASSERT_TRUE(response != NULL); |
7133 ASSERT_TRUE(response->headers != NULL); | 7164 ASSERT_TRUE(response->headers != NULL); |
7134 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 7165 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
7135 EXPECT_FALSE(response->was_fetched_via_spdy); | 7166 EXPECT_FALSE(response->was_fetched_via_spdy); |
7136 EXPECT_FALSE(response->was_npn_negotiated); | 7167 EXPECT_FALSE(response->was_npn_negotiated); |
7137 | 7168 |
7138 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 7169 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
7139 EXPECT_EQ("hello world", response_data); | 7170 EXPECT_EQ("hello world", response_data); |
7140 | 7171 |
7141 HttpStreamFactory::set_next_protos(std::vector<std::string>()); | 7172 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); |
7142 HttpStreamFactory::set_use_alternate_protocols(false); | 7173 HttpStreamFactory::set_use_alternate_protocols(false); |
7143 } | 7174 } |
7144 | 7175 |
7145 class CapturingProxyResolver : public ProxyResolver { | 7176 class CapturingProxyResolver : public ProxyResolver { |
7146 public: | 7177 public: |
7147 CapturingProxyResolver() : ProxyResolver(false /* expects_pac_bytes */) {} | 7178 CapturingProxyResolver() : ProxyResolver(false /* expects_pac_bytes */) {} |
7148 virtual ~CapturingProxyResolver() {} | 7179 virtual ~CapturingProxyResolver() {} |
7149 | 7180 |
7150 virtual int GetProxyForURL(const GURL& url, | 7181 virtual int GetProxyForURL(const GURL& url, |
7151 ProxyInfo* results, | 7182 ProxyInfo* results, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7184 } | 7215 } |
7185 | 7216 |
7186 const std::vector<GURL>& resolved() const { return resolved_; } | 7217 const std::vector<GURL>& resolved() const { return resolved_; } |
7187 | 7218 |
7188 private: | 7219 private: |
7189 std::vector<GURL> resolved_; | 7220 std::vector<GURL> resolved_; |
7190 | 7221 |
7191 DISALLOW_COPY_AND_ASSIGN(CapturingProxyResolver); | 7222 DISALLOW_COPY_AND_ASSIGN(CapturingProxyResolver); |
7192 }; | 7223 }; |
7193 | 7224 |
7194 TEST_F(HttpNetworkTransactionTest, UseAlternateProtocolForTunneledNpnSpdy) { | 7225 TEST_F(HttpNetworkTransactionSpdy2Test, |
| 7226 UseAlternateProtocolForTunneledNpnSpdy) { |
7195 HttpStreamFactory::set_use_alternate_protocols(true); | 7227 HttpStreamFactory::set_use_alternate_protocols(true); |
7196 HttpStreamFactory::set_next_protos(SpdyNextProtos()); | 7228 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); |
7197 | 7229 |
7198 ProxyConfig proxy_config; | 7230 ProxyConfig proxy_config; |
7199 proxy_config.set_auto_detect(true); | 7231 proxy_config.set_auto_detect(true); |
7200 proxy_config.set_pac_url(GURL("http://fooproxyurl")); | 7232 proxy_config.set_pac_url(GURL("http://fooproxyurl")); |
7201 | 7233 |
7202 CapturingProxyResolver* capturing_proxy_resolver = | 7234 CapturingProxyResolver* capturing_proxy_resolver = |
7203 new CapturingProxyResolver(); | 7235 new CapturingProxyResolver(); |
7204 SessionDependencies session_deps(new ProxyService( | 7236 SessionDependencies session_deps(new ProxyService( |
7205 new ProxyConfigServiceFixed(proxy_config), capturing_proxy_resolver, | 7237 new ProxyConfigServiceFixed(proxy_config), capturing_proxy_resolver, |
7206 NULL)); | 7238 NULL)); |
7207 | 7239 |
7208 HttpRequestInfo request; | 7240 HttpRequestInfo request; |
7209 request.method = "GET"; | 7241 request.method = "GET"; |
7210 request.url = GURL("http://www.google.com/"); | 7242 request.url = GURL("http://www.google.com/"); |
7211 request.load_flags = 0; | 7243 request.load_flags = 0; |
7212 | 7244 |
7213 MockRead data_reads[] = { | 7245 MockRead data_reads[] = { |
7214 MockRead("HTTP/1.1 200 OK\r\n"), | 7246 MockRead("HTTP/1.1 200 OK\r\n"), |
7215 MockRead(kAlternateProtocolHttpHeader), | 7247 MockRead(kAlternateProtocolHttpHeader), |
7216 MockRead("hello world"), | 7248 MockRead("hello world"), |
7217 MockRead(ASYNC, OK), | 7249 MockRead(ASYNC, OK), |
7218 }; | 7250 }; |
7219 | 7251 |
7220 StaticSocketDataProvider first_transaction( | 7252 StaticSocketDataProvider first_transaction( |
7221 data_reads, arraysize(data_reads), NULL, 0); | 7253 data_reads, arraysize(data_reads), NULL, 0); |
7222 session_deps.socket_factory.AddSocketDataProvider(&first_transaction); | 7254 session_deps.socket_factory.AddSocketDataProvider(&first_transaction); |
7223 | 7255 |
7224 SSLSocketDataProvider ssl(ASYNC, OK); | 7256 SSLSocketDataProvider ssl(ASYNC, OK); |
7225 ssl.SetNextProto(SSLClientSocket::kProtoSPDY21); | 7257 ssl.SetNextProto(SSLClientSocket::kProtoSPDY2); |
7226 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 7258 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
7227 | 7259 |
7228 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 7260 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
7229 MockWrite spdy_writes[] = { | 7261 MockWrite spdy_writes[] = { |
7230 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 7262 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
7231 "Host: www.google.com\r\n" | 7263 "Host: www.google.com\r\n" |
7232 "Proxy-Connection: keep-alive\r\n\r\n"), // 0 | 7264 "Proxy-Connection: keep-alive\r\n\r\n"), // 0 |
7233 CreateMockWrite(*req) // 3 | 7265 CreateMockWrite(*req) // 3 |
7234 }; | 7266 }; |
7235 | 7267 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7292 EXPECT_TRUE(response->was_npn_negotiated); | 7324 EXPECT_TRUE(response->was_npn_negotiated); |
7293 | 7325 |
7294 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 7326 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
7295 EXPECT_EQ("hello!", response_data); | 7327 EXPECT_EQ("hello!", response_data); |
7296 ASSERT_EQ(3u, capturing_proxy_resolver->resolved().size()); | 7328 ASSERT_EQ(3u, capturing_proxy_resolver->resolved().size()); |
7297 EXPECT_EQ("http://www.google.com/", | 7329 EXPECT_EQ("http://www.google.com/", |
7298 capturing_proxy_resolver->resolved()[0].spec()); | 7330 capturing_proxy_resolver->resolved()[0].spec()); |
7299 EXPECT_EQ("https://www.google.com/", | 7331 EXPECT_EQ("https://www.google.com/", |
7300 capturing_proxy_resolver->resolved()[1].spec()); | 7332 capturing_proxy_resolver->resolved()[1].spec()); |
7301 | 7333 |
7302 HttpStreamFactory::set_next_protos(std::vector<std::string>()); | 7334 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); |
7303 HttpStreamFactory::set_use_alternate_protocols(false); | 7335 HttpStreamFactory::set_use_alternate_protocols(false); |
7304 } | 7336 } |
7305 | 7337 |
7306 TEST_F(HttpNetworkTransactionTest, | 7338 TEST_F(HttpNetworkTransactionSpdy2Test, |
7307 UseAlternateProtocolForNpnSpdyWithExistingSpdySession) { | 7339 UseAlternateProtocolForNpnSpdyWithExistingSpdySession) { |
7308 HttpStreamFactory::set_use_alternate_protocols(true); | 7340 HttpStreamFactory::set_use_alternate_protocols(true); |
7309 HttpStreamFactory::set_next_protos(SpdyNextProtos()); | 7341 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); |
7310 SessionDependencies session_deps; | 7342 SessionDependencies session_deps; |
7311 | 7343 |
7312 HttpRequestInfo request; | 7344 HttpRequestInfo request; |
7313 request.method = "GET"; | 7345 request.method = "GET"; |
7314 request.url = GURL("http://www.google.com/"); | 7346 request.url = GURL("http://www.google.com/"); |
7315 request.load_flags = 0; | 7347 request.load_flags = 0; |
7316 | 7348 |
7317 MockRead data_reads[] = { | 7349 MockRead data_reads[] = { |
7318 MockRead("HTTP/1.1 200 OK\r\n"), | 7350 MockRead("HTTP/1.1 200 OK\r\n"), |
7319 MockRead(kAlternateProtocolHttpHeader), | 7351 MockRead(kAlternateProtocolHttpHeader), |
7320 MockRead("hello world"), | 7352 MockRead("hello world"), |
7321 MockRead(ASYNC, OK), | 7353 MockRead(ASYNC, OK), |
7322 }; | 7354 }; |
7323 | 7355 |
7324 StaticSocketDataProvider first_transaction( | 7356 StaticSocketDataProvider first_transaction( |
7325 data_reads, arraysize(data_reads), NULL, 0); | 7357 data_reads, arraysize(data_reads), NULL, 0); |
7326 session_deps.socket_factory.AddSocketDataProvider(&first_transaction); | 7358 session_deps.socket_factory.AddSocketDataProvider(&first_transaction); |
7327 | 7359 |
7328 SSLSocketDataProvider ssl(ASYNC, OK); | 7360 SSLSocketDataProvider ssl(ASYNC, OK); |
7329 ssl.SetNextProto(SSLClientSocket::kProtoSPDY21); | 7361 ssl.SetNextProto(SSLClientSocket::kProtoSPDY2); |
7330 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 7362 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
7331 // Make sure we use ssl for spdy here. | 7363 // Make sure we use ssl for spdy here. |
7332 SpdySession::SetSSLMode(true); | 7364 SpdySession::SetSSLMode(true); |
7333 | 7365 |
7334 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 7366 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
7335 MockWrite spdy_writes[] = { CreateMockWrite(*req) }; | 7367 MockWrite spdy_writes[] = { CreateMockWrite(*req) }; |
7336 | 7368 |
7337 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 7369 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
7338 scoped_ptr<spdy::SpdyFrame> data(ConstructSpdyBodyFrame(1, true)); | 7370 scoped_ptr<spdy::SpdyFrame> data(ConstructSpdyBodyFrame(1, true)); |
7339 MockRead spdy_reads[] = { | 7371 MockRead spdy_reads[] = { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7410 response = trans->GetResponseInfo(); | 7442 response = trans->GetResponseInfo(); |
7411 ASSERT_TRUE(response != NULL); | 7443 ASSERT_TRUE(response != NULL); |
7412 ASSERT_TRUE(response->headers != NULL); | 7444 ASSERT_TRUE(response->headers != NULL); |
7413 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 7445 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
7414 EXPECT_TRUE(response->was_fetched_via_spdy); | 7446 EXPECT_TRUE(response->was_fetched_via_spdy); |
7415 EXPECT_TRUE(response->was_npn_negotiated); | 7447 EXPECT_TRUE(response->was_npn_negotiated); |
7416 | 7448 |
7417 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 7449 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
7418 EXPECT_EQ("hello!", response_data); | 7450 EXPECT_EQ("hello!", response_data); |
7419 | 7451 |
7420 HttpStreamFactory::set_next_protos(std::vector<std::string>()); | 7452 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); |
7421 HttpStreamFactory::set_use_alternate_protocols(false); | 7453 HttpStreamFactory::set_use_alternate_protocols(false); |
7422 } | 7454 } |
7423 | 7455 |
7424 // GenerateAuthToken is a mighty big test. | 7456 // GenerateAuthToken is a mighty big test. |
7425 // It tests all permutation of GenerateAuthToken behavior: | 7457 // It tests all permutation of GenerateAuthToken behavior: |
7426 // - Synchronous and Asynchronous completion. | 7458 // - Synchronous and Asynchronous completion. |
7427 // - OK or error on completion. | 7459 // - OK or error on completion. |
7428 // - Direct connection, non-authenticating proxy, and authenticating proxy. | 7460 // - Direct connection, non-authenticating proxy, and authenticating proxy. |
7429 // - HTTP or HTTPS backend (to include proxy tunneling). | 7461 // - HTTP or HTTPS backend (to include proxy tunneling). |
7430 // - Non-authenticating and authenticating backend. | 7462 // - Non-authenticating and authenticating backend. |
7431 // | 7463 // |
7432 // In all, there are 44 reasonable permuations (for example, if there are | 7464 // In all, there are 44 reasonable permuations (for example, if there are |
7433 // problems generating an auth token for an authenticating proxy, we don't | 7465 // problems generating an auth token for an authenticating proxy, we don't |
7434 // need to test all permutations of the backend server). | 7466 // need to test all permutations of the backend server). |
7435 // | 7467 // |
7436 // The test proceeds by going over each of the configuration cases, and | 7468 // The test proceeds by going over each of the configuration cases, and |
7437 // potentially running up to three rounds in each of the tests. The TestConfig | 7469 // potentially running up to three rounds in each of the tests. The TestConfig |
7438 // specifies both the configuration for the test as well as the expectations | 7470 // specifies both the configuration for the test as well as the expectations |
7439 // for the results. | 7471 // for the results. |
7440 TEST_F(HttpNetworkTransactionTest, GenerateAuthToken) { | 7472 TEST_F(HttpNetworkTransactionSpdy2Test, GenerateAuthToken) { |
7441 static const char kServer[] = "http://www.example.com"; | 7473 static const char kServer[] = "http://www.example.com"; |
7442 static const char kSecureServer[] = "https://www.example.com"; | 7474 static const char kSecureServer[] = "https://www.example.com"; |
7443 static const char kProxy[] = "myproxy:70"; | 7475 static const char kProxy[] = "myproxy:70"; |
7444 const int kAuthErr = ERR_INVALID_AUTH_CREDENTIALS; | 7476 const int kAuthErr = ERR_INVALID_AUTH_CREDENTIALS; |
7445 | 7477 |
7446 enum AuthTiming { | 7478 enum AuthTiming { |
7447 AUTH_NONE, | 7479 AUTH_NONE, |
7448 AUTH_SYNC, | 7480 AUTH_SYNC, |
7449 AUTH_ASYNC, | 7481 AUTH_ASYNC, |
7450 }; | 7482 }; |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7828 } | 7860 } |
7829 if (round + 1 < test_config.num_auth_rounds) { | 7861 if (round + 1 < test_config.num_auth_rounds) { |
7830 EXPECT_FALSE(response->auth_challenge.get() == NULL); | 7862 EXPECT_FALSE(response->auth_challenge.get() == NULL); |
7831 } else { | 7863 } else { |
7832 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 7864 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
7833 } | 7865 } |
7834 } | 7866 } |
7835 } | 7867 } |
7836 } | 7868 } |
7837 | 7869 |
7838 TEST_F(HttpNetworkTransactionTest, MultiRoundAuth) { | 7870 TEST_F(HttpNetworkTransactionSpdy2Test, MultiRoundAuth) { |
7839 // Do multi-round authentication and make sure it works correctly. | 7871 // Do multi-round authentication and make sure it works correctly. |
7840 SessionDependencies session_deps; | 7872 SessionDependencies session_deps; |
7841 HttpAuthHandlerMock::Factory* auth_factory( | 7873 HttpAuthHandlerMock::Factory* auth_factory( |
7842 new HttpAuthHandlerMock::Factory()); | 7874 new HttpAuthHandlerMock::Factory()); |
7843 session_deps.http_auth_handler_factory.reset(auth_factory); | 7875 session_deps.http_auth_handler_factory.reset(auth_factory); |
7844 session_deps.proxy_service.reset(ProxyService::CreateDirect()); | 7876 session_deps.proxy_service.reset(ProxyService::CreateDirect()); |
7845 session_deps.host_resolver->rules()->AddRule("www.example.com", "10.0.0.1"); | 7877 session_deps.host_resolver->rules()->AddRule("www.example.com", "10.0.0.1"); |
7846 session_deps.host_resolver->set_synchronous_mode(true); | 7878 session_deps.host_resolver->set_synchronous_mode(true); |
7847 | 7879 |
7848 HttpAuthHandlerMock* auth_handler(new HttpAuthHandlerMock()); | 7880 HttpAuthHandlerMock* auth_handler(new HttpAuthHandlerMock()); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8042 void Reset() { | 8074 void Reset() { |
8043 } | 8075 } |
8044 | 8076 |
8045 private: | 8077 private: |
8046 const bool fail_all_; | 8078 const bool fail_all_; |
8047 }; | 8079 }; |
8048 | 8080 |
8049 // Test that we restart a connection when we see a decompression failure from | 8081 // Test that we restart a connection when we see a decompression failure from |
8050 // the peer during the handshake. (In the real world we'll restart with SSLv3 | 8082 // the peer during the handshake. (In the real world we'll restart with SSLv3 |
8051 // and we won't offer DEFLATE in that case.) | 8083 // and we won't offer DEFLATE in that case.) |
8052 TEST_F(HttpNetworkTransactionTest, RestartAfterTLSDecompressionFailure) { | 8084 TEST_F(HttpNetworkTransactionSpdy2Test, RestartAfterTLSDecompressionFailure) { |
8053 HttpRequestInfo request; | 8085 HttpRequestInfo request; |
8054 request.method = "GET"; | 8086 request.method = "GET"; |
8055 request.url = GURL("https://tlsdecompressionfailure.example.com/"); | 8087 request.url = GURL("https://tlsdecompressionfailure.example.com/"); |
8056 request.load_flags = 0; | 8088 request.load_flags = 0; |
8057 | 8089 |
8058 SessionDependencies session_deps; | 8090 SessionDependencies session_deps; |
8059 TLSDecompressionFailureSocketDataProvider socket_data_provider1( | 8091 TLSDecompressionFailureSocketDataProvider socket_data_provider1( |
8060 false /* fail all reads */); | 8092 false /* fail all reads */); |
8061 TLSDecompressionFailureSocketDataProvider socket_data_provider2(false); | 8093 TLSDecompressionFailureSocketDataProvider socket_data_provider2(false); |
8062 SSLSocketDataProvider ssl_socket_data_provider1( | 8094 SSLSocketDataProvider ssl_socket_data_provider1( |
(...skipping 26 matching lines...) Expand all Loading... |
8089 | 8121 |
8090 std::string response_data; | 8122 std::string response_data; |
8091 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 8123 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
8092 EXPECT_EQ("ok.", response_data); | 8124 EXPECT_EQ("ok.", response_data); |
8093 } | 8125 } |
8094 | 8126 |
8095 // Test that we restart a connection if we get a decompression failure from the | 8127 // Test that we restart a connection if we get a decompression failure from the |
8096 // peer while reading the first bytes from the connection. This occurs when the | 8128 // peer while reading the first bytes from the connection. This occurs when the |
8097 // peer cannot handle DEFLATE but we're using False Start, so we don't notice | 8129 // peer cannot handle DEFLATE but we're using False Start, so we don't notice |
8098 // in the handshake. | 8130 // in the handshake. |
8099 TEST_F(HttpNetworkTransactionTest, | 8131 TEST_F(HttpNetworkTransactionSpdy2Test, |
8100 RestartAfterTLSDecompressionFailureWithFalseStart) { | 8132 RestartAfterTLSDecompressionFailureWithFalseStart) { |
8101 HttpRequestInfo request; | 8133 HttpRequestInfo request; |
8102 request.method = "GET"; | 8134 request.method = "GET"; |
8103 request.url = GURL("https://tlsdecompressionfailure2.example.com/"); | 8135 request.url = GURL("https://tlsdecompressionfailure2.example.com/"); |
8104 request.load_flags = 0; | 8136 request.load_flags = 0; |
8105 | 8137 |
8106 SessionDependencies session_deps; | 8138 SessionDependencies session_deps; |
8107 TLSDecompressionFailureSocketDataProvider socket_data_provider1( | 8139 TLSDecompressionFailureSocketDataProvider socket_data_provider1( |
8108 true /* fail all reads */); | 8140 true /* fail all reads */); |
8109 TLSDecompressionFailureSocketDataProvider socket_data_provider2(false); | 8141 TLSDecompressionFailureSocketDataProvider socket_data_provider2(false); |
(...skipping 19 matching lines...) Expand all Loading... |
8129 ASSERT_TRUE(response->headers != NULL); | 8161 ASSERT_TRUE(response->headers != NULL); |
8130 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 8162 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
8131 | 8163 |
8132 std::string response_data; | 8164 std::string response_data; |
8133 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 8165 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
8134 EXPECT_EQ("ok.", response_data); | 8166 EXPECT_EQ("ok.", response_data); |
8135 } | 8167 } |
8136 | 8168 |
8137 // This tests the case that a request is issued via http instead of spdy after | 8169 // This tests the case that a request is issued via http instead of spdy after |
8138 // npn is negotiated. | 8170 // npn is negotiated. |
8139 TEST_F(HttpNetworkTransactionTest, NpnWithHttpOverSSL) { | 8171 TEST_F(HttpNetworkTransactionSpdy2Test, NpnWithHttpOverSSL) { |
8140 HttpStreamFactory::set_use_alternate_protocols(true); | 8172 HttpStreamFactory::set_use_alternate_protocols(true); |
8141 HttpStreamFactory::set_next_protos( | 8173 HttpStreamFactory::SetNextProtos( |
8142 MakeNextProtos("http/1.1", "http1.1", NULL)); | 8174 MakeNextProtos("http/1.1", "http1.1", NULL)); |
8143 SessionDependencies session_deps; | 8175 SessionDependencies session_deps; |
8144 HttpRequestInfo request; | 8176 HttpRequestInfo request; |
8145 request.method = "GET"; | 8177 request.method = "GET"; |
8146 request.url = GURL("https://www.google.com/"); | 8178 request.url = GURL("https://www.google.com/"); |
8147 request.load_flags = 0; | 8179 request.load_flags = 0; |
8148 | 8180 |
8149 MockWrite data_writes[] = { | 8181 MockWrite data_writes[] = { |
8150 MockWrite("GET / HTTP/1.1\r\n" | 8182 MockWrite("GET / HTTP/1.1\r\n" |
8151 "Host: www.google.com\r\n" | 8183 "Host: www.google.com\r\n" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8185 ASSERT_TRUE(response->headers != NULL); | 8217 ASSERT_TRUE(response->headers != NULL); |
8186 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 8218 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
8187 | 8219 |
8188 std::string response_data; | 8220 std::string response_data; |
8189 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 8221 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
8190 EXPECT_EQ("hello world", response_data); | 8222 EXPECT_EQ("hello world", response_data); |
8191 | 8223 |
8192 EXPECT_FALSE(response->was_fetched_via_spdy); | 8224 EXPECT_FALSE(response->was_fetched_via_spdy); |
8193 EXPECT_TRUE(response->was_npn_negotiated); | 8225 EXPECT_TRUE(response->was_npn_negotiated); |
8194 | 8226 |
8195 HttpStreamFactory::set_next_protos(std::vector<std::string>()); | 8227 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); |
8196 HttpStreamFactory::set_use_alternate_protocols(false); | 8228 HttpStreamFactory::set_use_alternate_protocols(false); |
8197 } | 8229 } |
8198 | 8230 |
8199 TEST_F(HttpNetworkTransactionTest, SpdyPostNPNServerHangup) { | 8231 TEST_F(HttpNetworkTransactionSpdy2Test, SpdyPostNPNServerHangup) { |
8200 // Simulate the SSL handshake completing with an NPN negotiation | 8232 // Simulate the SSL handshake completing with an NPN negotiation |
8201 // followed by an immediate server closing of the socket. | 8233 // followed by an immediate server closing of the socket. |
8202 // Fix crash: http://crbug.com/46369 | 8234 // Fix crash: http://crbug.com/46369 |
8203 HttpStreamFactory::set_use_alternate_protocols(true); | 8235 HttpStreamFactory::set_use_alternate_protocols(true); |
8204 HttpStreamFactory::set_next_protos(SpdyNextProtos()); | 8236 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); |
8205 SessionDependencies session_deps; | 8237 SessionDependencies session_deps; |
8206 | 8238 |
8207 HttpRequestInfo request; | 8239 HttpRequestInfo request; |
8208 request.method = "GET"; | 8240 request.method = "GET"; |
8209 request.url = GURL("https://www.google.com/"); | 8241 request.url = GURL("https://www.google.com/"); |
8210 request.load_flags = 0; | 8242 request.load_flags = 0; |
8211 | 8243 |
8212 SSLSocketDataProvider ssl(ASYNC, OK); | 8244 SSLSocketDataProvider ssl(ASYNC, OK); |
8213 ssl.SetNextProto(SSLClientSocket::kProtoSPDY21); | 8245 ssl.SetNextProto(SSLClientSocket::kProtoSPDY2); |
8214 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 8246 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
8215 | 8247 |
8216 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 8248 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
8217 MockWrite spdy_writes[] = { CreateMockWrite(*req) }; | 8249 MockWrite spdy_writes[] = { CreateMockWrite(*req) }; |
8218 | 8250 |
8219 MockRead spdy_reads[] = { | 8251 MockRead spdy_reads[] = { |
8220 MockRead(SYNCHRONOUS, 0, 0) // Not async - return 0 immediately. | 8252 MockRead(SYNCHRONOUS, 0, 0) // Not async - return 0 immediately. |
8221 }; | 8253 }; |
8222 | 8254 |
8223 scoped_ptr<DelayedSocketData> spdy_data( | 8255 scoped_ptr<DelayedSocketData> spdy_data( |
8224 new DelayedSocketData( | 8256 new DelayedSocketData( |
8225 0, // don't wait in this case, immediate hangup. | 8257 0, // don't wait in this case, immediate hangup. |
8226 spdy_reads, arraysize(spdy_reads), | 8258 spdy_reads, arraysize(spdy_reads), |
8227 spdy_writes, arraysize(spdy_writes))); | 8259 spdy_writes, arraysize(spdy_writes))); |
8228 session_deps.socket_factory.AddSocketDataProvider(spdy_data.get()); | 8260 session_deps.socket_factory.AddSocketDataProvider(spdy_data.get()); |
8229 | 8261 |
8230 TestCompletionCallback callback; | 8262 TestCompletionCallback callback; |
8231 | 8263 |
8232 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 8264 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
8233 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); | 8265 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); |
8234 | 8266 |
8235 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 8267 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
8236 EXPECT_EQ(ERR_IO_PENDING, rv); | 8268 EXPECT_EQ(ERR_IO_PENDING, rv); |
8237 EXPECT_EQ(ERR_CONNECTION_CLOSED, callback.WaitForResult()); | 8269 EXPECT_EQ(ERR_CONNECTION_CLOSED, callback.WaitForResult()); |
8238 | 8270 |
8239 HttpStreamFactory::set_next_protos(std::vector<std::string>()); | 8271 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); |
8240 HttpStreamFactory::set_use_alternate_protocols(false); | 8272 HttpStreamFactory::set_use_alternate_protocols(false); |
8241 } | 8273 } |
8242 | 8274 |
8243 TEST_F(HttpNetworkTransactionTest, SpdyAlternateProtocolThroughProxy) { | 8275 TEST_F(HttpNetworkTransactionSpdy2Test, SpdyAlternateProtocolThroughProxy) { |
8244 // This test ensures that the URL passed into the proxy is upgraded | 8276 // This test ensures that the URL passed into the proxy is upgraded |
8245 // to https when doing an Alternate Protocol upgrade. | 8277 // to https when doing an Alternate Protocol upgrade. |
8246 HttpStreamFactory::set_use_alternate_protocols(true); | 8278 HttpStreamFactory::set_use_alternate_protocols(true); |
8247 HttpStreamFactory::set_next_protos( | 8279 HttpStreamFactory::SetNextProtos( |
8248 MakeNextProtos( | 8280 MakeNextProtos( |
8249 "http/1.1", "http1.1", "spdy/2.1", "spdy/2", "spdy", NULL)); | 8281 "http/1.1", "http1.1", "spdy/2", "spdy", NULL)); |
8250 | 8282 |
8251 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 8283 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
8252 HttpAuthHandlerMock::Factory* auth_factory = | 8284 HttpAuthHandlerMock::Factory* auth_factory = |
8253 new HttpAuthHandlerMock::Factory(); | 8285 new HttpAuthHandlerMock::Factory(); |
8254 HttpAuthHandlerMock* auth_handler = new HttpAuthHandlerMock(); | 8286 HttpAuthHandlerMock* auth_handler = new HttpAuthHandlerMock(); |
8255 auth_factory->AddMockHandler(auth_handler, HttpAuth::AUTH_PROXY); | 8287 auth_factory->AddMockHandler(auth_handler, HttpAuth::AUTH_PROXY); |
8256 auth_factory->set_do_init_from_challenge(true); | 8288 auth_factory->set_do_init_from_challenge(true); |
8257 session_deps.http_auth_handler_factory.reset(auth_factory); | 8289 session_deps.http_auth_handler_factory.reset(auth_factory); |
8258 | 8290 |
8259 HttpRequestInfo request; | 8291 HttpRequestInfo request; |
8260 request.method = "GET"; | 8292 request.method = "GET"; |
8261 request.url = GURL("http://www.google.com"); | 8293 request.url = GURL("http://www.google.com"); |
8262 request.load_flags = 0; | 8294 request.load_flags = 0; |
8263 | 8295 |
8264 // First round goes unauthenticated through the proxy. | 8296 // First round goes unauthenticated through the proxy. |
8265 MockWrite data_writes_1[] = { | 8297 MockWrite data_writes_1[] = { |
8266 MockWrite("GET http://www.google.com/ HTTP/1.1\r\n" | 8298 MockWrite("GET http://www.google.com/ HTTP/1.1\r\n" |
8267 "Host: www.google.com\r\n" | 8299 "Host: www.google.com\r\n" |
8268 "Proxy-Connection: keep-alive\r\n" | 8300 "Proxy-Connection: keep-alive\r\n" |
8269 "\r\n"), | 8301 "\r\n"), |
8270 }; | 8302 }; |
8271 MockRead data_reads_1[] = { | 8303 MockRead data_reads_1[] = { |
8272 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), | 8304 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
8273 MockRead("HTTP/1.1 200 OK\r\n" | 8305 MockRead("HTTP/1.1 200 OK\r\n" |
8274 "Alternate-Protocol: 443:npn-spdy/2.1\r\n" | 8306 "Alternate-Protocol: 443:npn-spdy/2\r\n" |
8275 "Proxy-Connection: close\r\n" | 8307 "Proxy-Connection: close\r\n" |
8276 "\r\n"), | 8308 "\r\n"), |
8277 }; | 8309 }; |
8278 StaticSocketDataProvider data_1(data_reads_1, arraysize(data_reads_1), | 8310 StaticSocketDataProvider data_1(data_reads_1, arraysize(data_reads_1), |
8279 data_writes_1, arraysize(data_writes_1)); | 8311 data_writes_1, arraysize(data_writes_1)); |
8280 | 8312 |
8281 // Second round tries to tunnel to www.google.com due to the | 8313 // Second round tries to tunnel to www.google.com due to the |
8282 // Alternate-Protocol announcement in the first round. It fails due | 8314 // Alternate-Protocol announcement in the first round. It fails due |
8283 // to a proxy authentication challenge. | 8315 // to a proxy authentication challenge. |
8284 // After the failure, a tunnel is established to www.google.com using | 8316 // After the failure, a tunnel is established to www.google.com using |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8334 // SPDY response | 8366 // SPDY response |
8335 CreateMockRead(*resp.get(), 6), | 8367 CreateMockRead(*resp.get(), 6), |
8336 CreateMockRead(*data.get(), 6), | 8368 CreateMockRead(*data.get(), 6), |
8337 MockRead(ASYNC, 0, 0, 6), | 8369 MockRead(ASYNC, 0, 0, 6), |
8338 }; | 8370 }; |
8339 scoped_ptr<OrderedSocketData> data_2( | 8371 scoped_ptr<OrderedSocketData> data_2( |
8340 new OrderedSocketData(data_reads_2, arraysize(data_reads_2), | 8372 new OrderedSocketData(data_reads_2, arraysize(data_reads_2), |
8341 data_writes_2, arraysize(data_writes_2))); | 8373 data_writes_2, arraysize(data_writes_2))); |
8342 | 8374 |
8343 SSLSocketDataProvider ssl(ASYNC, OK); | 8375 SSLSocketDataProvider ssl(ASYNC, OK); |
8344 ssl.SetNextProto(SSLClientSocket::kProtoSPDY21); | 8376 ssl.SetNextProto(SSLClientSocket::kProtoSPDY2); |
8345 | 8377 |
8346 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); | 8378 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); |
8347 StaticSocketDataProvider hanging_non_alternate_protocol_socket( | 8379 StaticSocketDataProvider hanging_non_alternate_protocol_socket( |
8348 NULL, 0, NULL, 0); | 8380 NULL, 0, NULL, 0); |
8349 hanging_non_alternate_protocol_socket.set_connect_data( | 8381 hanging_non_alternate_protocol_socket.set_connect_data( |
8350 never_finishing_connect); | 8382 never_finishing_connect); |
8351 | 8383 |
8352 session_deps.socket_factory.AddSocketDataProvider(&data_1); | 8384 session_deps.socket_factory.AddSocketDataProvider(&data_1); |
8353 session_deps.socket_factory.AddSocketDataProvider(data_2.get()); | 8385 session_deps.socket_factory.AddSocketDataProvider(data_2.get()); |
8354 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 8386 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
(...skipping 24 matching lines...) Expand all Loading... |
8379 AuthCredentials(kFoo, kBar), callback_3.callback()); | 8411 AuthCredentials(kFoo, kBar), callback_3.callback()); |
8380 EXPECT_EQ(ERR_IO_PENDING, rv); | 8412 EXPECT_EQ(ERR_IO_PENDING, rv); |
8381 EXPECT_EQ(OK, callback_3.WaitForResult()); | 8413 EXPECT_EQ(OK, callback_3.WaitForResult()); |
8382 | 8414 |
8383 // After all that work, these two lines (or actually, just the scheme) are | 8415 // After all that work, these two lines (or actually, just the scheme) are |
8384 // what this test is all about. Make sure it happens correctly. | 8416 // what this test is all about. Make sure it happens correctly. |
8385 const GURL& request_url = auth_handler->request_url(); | 8417 const GURL& request_url = auth_handler->request_url(); |
8386 EXPECT_EQ("https", request_url.scheme()); | 8418 EXPECT_EQ("https", request_url.scheme()); |
8387 EXPECT_EQ("www.google.com", request_url.host()); | 8419 EXPECT_EQ("www.google.com", request_url.host()); |
8388 | 8420 |
8389 HttpStreamFactory::set_next_protos(std::vector<std::string>()); | 8421 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); |
8390 HttpStreamFactory::set_use_alternate_protocols(false); | 8422 HttpStreamFactory::set_use_alternate_protocols(false); |
8391 } | 8423 } |
8392 | 8424 |
8393 // Test that if we cancel the transaction as the connection is completing, that | 8425 // Test that if we cancel the transaction as the connection is completing, that |
8394 // everything tears down correctly. | 8426 // everything tears down correctly. |
8395 TEST_F(HttpNetworkTransactionTest, SimpleCancel) { | 8427 TEST_F(HttpNetworkTransactionSpdy2Test, SimpleCancel) { |
8396 // Setup everything about the connection to complete synchronously, so that | 8428 // Setup everything about the connection to complete synchronously, so that |
8397 // after calling HttpNetworkTransaction::Start, the only thing we're waiting | 8429 // after calling HttpNetworkTransaction::Start, the only thing we're waiting |
8398 // for is the callback from the HttpStreamRequest. | 8430 // for is the callback from the HttpStreamRequest. |
8399 // Then cancel the transaction. | 8431 // Then cancel the transaction. |
8400 // Verify that we don't crash. | 8432 // Verify that we don't crash. |
8401 MockConnect mock_connect(SYNCHRONOUS, OK); | 8433 MockConnect mock_connect(SYNCHRONOUS, OK); |
8402 MockRead data_reads[] = { | 8434 MockRead data_reads[] = { |
8403 MockRead(SYNCHRONOUS, "HTTP/1.0 200 OK\r\n\r\n"), | 8435 MockRead(SYNCHRONOUS, "HTTP/1.0 200 OK\r\n\r\n"), |
8404 MockRead(SYNCHRONOUS, "hello world"), | 8436 MockRead(SYNCHRONOUS, "hello world"), |
8405 MockRead(SYNCHRONOUS, OK), | 8437 MockRead(SYNCHRONOUS, OK), |
(...skipping 17 matching lines...) Expand all Loading... |
8423 | 8455 |
8424 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 8456 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); |
8425 int rv = trans->Start(&request, callback.callback(), log.bound()); | 8457 int rv = trans->Start(&request, callback.callback(), log.bound()); |
8426 EXPECT_EQ(ERR_IO_PENDING, rv); | 8458 EXPECT_EQ(ERR_IO_PENDING, rv); |
8427 trans.reset(); // Cancel the transaction here. | 8459 trans.reset(); // Cancel the transaction here. |
8428 | 8460 |
8429 MessageLoop::current()->RunAllPending(); | 8461 MessageLoop::current()->RunAllPending(); |
8430 } | 8462 } |
8431 | 8463 |
8432 // Test a basic GET request through a proxy. | 8464 // Test a basic GET request through a proxy. |
8433 TEST_F(HttpNetworkTransactionTest, ProxyGet) { | 8465 TEST_F(HttpNetworkTransactionSpdy2Test, ProxyGet) { |
8434 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 8466 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
8435 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 8467 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); |
8436 session_deps.net_log = log.bound().net_log(); | 8468 session_deps.net_log = log.bound().net_log(); |
8437 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 8469 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
8438 | 8470 |
8439 HttpRequestInfo request; | 8471 HttpRequestInfo request; |
8440 request.method = "GET"; | 8472 request.method = "GET"; |
8441 request.url = GURL("http://www.google.com/"); | 8473 request.url = GURL("http://www.google.com/"); |
8442 | 8474 |
8443 MockWrite data_writes1[] = { | 8475 MockWrite data_writes1[] = { |
(...skipping 27 matching lines...) Expand all Loading... |
8471 ASSERT_TRUE(response != NULL); | 8503 ASSERT_TRUE(response != NULL); |
8472 | 8504 |
8473 EXPECT_TRUE(response->headers->IsKeepAlive()); | 8505 EXPECT_TRUE(response->headers->IsKeepAlive()); |
8474 EXPECT_EQ(200, response->headers->response_code()); | 8506 EXPECT_EQ(200, response->headers->response_code()); |
8475 EXPECT_EQ(100, response->headers->GetContentLength()); | 8507 EXPECT_EQ(100, response->headers->GetContentLength()); |
8476 EXPECT_TRUE(response->was_fetched_via_proxy); | 8508 EXPECT_TRUE(response->was_fetched_via_proxy); |
8477 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 8509 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
8478 } | 8510 } |
8479 | 8511 |
8480 // Test a basic HTTPS GET request through a proxy. | 8512 // Test a basic HTTPS GET request through a proxy. |
8481 TEST_F(HttpNetworkTransactionTest, ProxyTunnelGet) { | 8513 TEST_F(HttpNetworkTransactionSpdy2Test, ProxyTunnelGet) { |
8482 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 8514 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
8483 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 8515 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); |
8484 session_deps.net_log = log.bound().net_log(); | 8516 session_deps.net_log = log.bound().net_log(); |
8485 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 8517 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
8486 | 8518 |
8487 HttpRequestInfo request; | 8519 HttpRequestInfo request; |
8488 request.method = "GET"; | 8520 request.method = "GET"; |
8489 request.url = GURL("https://www.google.com/"); | 8521 request.url = GURL("https://www.google.com/"); |
8490 | 8522 |
8491 // Since we have proxy, should try to establish tunnel. | 8523 // Since we have proxy, should try to establish tunnel. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8538 | 8570 |
8539 EXPECT_TRUE(response->headers->IsKeepAlive()); | 8571 EXPECT_TRUE(response->headers->IsKeepAlive()); |
8540 EXPECT_EQ(200, response->headers->response_code()); | 8572 EXPECT_EQ(200, response->headers->response_code()); |
8541 EXPECT_EQ(100, response->headers->GetContentLength()); | 8573 EXPECT_EQ(100, response->headers->GetContentLength()); |
8542 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 8574 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
8543 EXPECT_TRUE(response->was_fetched_via_proxy); | 8575 EXPECT_TRUE(response->was_fetched_via_proxy); |
8544 } | 8576 } |
8545 | 8577 |
8546 // Test a basic HTTPS GET request through a proxy, but the server hangs up | 8578 // Test a basic HTTPS GET request through a proxy, but the server hangs up |
8547 // while establishing the tunnel. | 8579 // while establishing the tunnel. |
8548 TEST_F(HttpNetworkTransactionTest, ProxyTunnelGetHangup) { | 8580 TEST_F(HttpNetworkTransactionSpdy2Test, ProxyTunnelGetHangup) { |
8549 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 8581 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
8550 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 8582 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); |
8551 session_deps.net_log = log.bound().net_log(); | 8583 session_deps.net_log = log.bound().net_log(); |
8552 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 8584 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
8553 | 8585 |
8554 HttpRequestInfo request; | 8586 HttpRequestInfo request; |
8555 request.method = "GET"; | 8587 request.method = "GET"; |
8556 request.url = GURL("https://www.google.com/"); | 8588 request.url = GURL("https://www.google.com/"); |
8557 | 8589 |
8558 // Since we have proxy, should try to establish tunnel. | 8590 // Since we have proxy, should try to establish tunnel. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8592 size_t pos = ExpectLogContainsSomewhere( | 8624 size_t pos = ExpectLogContainsSomewhere( |
8593 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 8625 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
8594 NetLog::PHASE_NONE); | 8626 NetLog::PHASE_NONE); |
8595 ExpectLogContainsSomewhere( | 8627 ExpectLogContainsSomewhere( |
8596 entries, pos, | 8628 entries, pos, |
8597 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 8629 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
8598 NetLog::PHASE_NONE); | 8630 NetLog::PHASE_NONE); |
8599 } | 8631 } |
8600 | 8632 |
8601 // Test for crbug.com/55424. | 8633 // Test for crbug.com/55424. |
8602 TEST_F(HttpNetworkTransactionTest, PreconnectWithExistingSpdySession) { | 8634 TEST_F(HttpNetworkTransactionSpdy2Test, PreconnectWithExistingSpdySession) { |
8603 SessionDependencies session_deps; | 8635 SessionDependencies session_deps; |
8604 | 8636 |
8605 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet( | 8637 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet( |
8606 "https://www.google.com", false, 1, LOWEST)); | 8638 "https://www.google.com", false, 1, LOWEST)); |
8607 MockWrite spdy_writes[] = { CreateMockWrite(*req) }; | 8639 MockWrite spdy_writes[] = { CreateMockWrite(*req) }; |
8608 | 8640 |
8609 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 8641 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
8610 scoped_ptr<spdy::SpdyFrame> data(ConstructSpdyBodyFrame(1, true)); | 8642 scoped_ptr<spdy::SpdyFrame> data(ConstructSpdyBodyFrame(1, true)); |
8611 MockRead spdy_reads[] = { | 8643 MockRead spdy_reads[] = { |
8612 CreateMockRead(*resp), | 8644 CreateMockRead(*resp), |
8613 CreateMockRead(*data), | 8645 CreateMockRead(*data), |
8614 MockRead(ASYNC, 0, 0), | 8646 MockRead(ASYNC, 0, 0), |
8615 }; | 8647 }; |
8616 | 8648 |
8617 scoped_ptr<DelayedSocketData> spdy_data( | 8649 scoped_ptr<DelayedSocketData> spdy_data( |
8618 new DelayedSocketData( | 8650 new DelayedSocketData( |
8619 1, // wait for one write to finish before reading. | 8651 1, // wait for one write to finish before reading. |
8620 spdy_reads, arraysize(spdy_reads), | 8652 spdy_reads, arraysize(spdy_reads), |
8621 spdy_writes, arraysize(spdy_writes))); | 8653 spdy_writes, arraysize(spdy_writes))); |
8622 session_deps.socket_factory.AddSocketDataProvider(spdy_data.get()); | 8654 session_deps.socket_factory.AddSocketDataProvider(spdy_data.get()); |
8623 | 8655 |
8624 SSLSocketDataProvider ssl(ASYNC, OK); | 8656 SSLSocketDataProvider ssl(ASYNC, OK); |
8625 ssl.SetNextProto(SSLClientSocket::kProtoSPDY21); | 8657 ssl.SetNextProto(SSLClientSocket::kProtoSPDY2); |
8626 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 8658 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
8627 | 8659 |
8628 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 8660 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
8629 | 8661 |
8630 // Set up an initial SpdySession in the pool to reuse. | 8662 // Set up an initial SpdySession in the pool to reuse. |
8631 HostPortPair host_port_pair("www.google.com", 443); | 8663 HostPortPair host_port_pair("www.google.com", 443); |
8632 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct()); | 8664 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct()); |
8633 scoped_refptr<SpdySession> spdy_session = | 8665 scoped_refptr<SpdySession> spdy_session = |
8634 session->spdy_session_pool()->Get(pair, BoundNetLog()); | 8666 session->spdy_session_pool()->Get(pair, BoundNetLog()); |
8635 scoped_refptr<TransportSocketParams> transport_params( | 8667 scoped_refptr<TransportSocketParams> transport_params( |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8681 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 8713 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
8682 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); | 8714 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); |
8683 | 8715 |
8684 TestCompletionCallback callback; | 8716 TestCompletionCallback callback; |
8685 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); | 8717 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); |
8686 if (rv == net::ERR_IO_PENDING) | 8718 if (rv == net::ERR_IO_PENDING) |
8687 rv = callback.WaitForResult(); | 8719 rv = callback.WaitForResult(); |
8688 ASSERT_EQ(error, rv); | 8720 ASSERT_EQ(error, rv); |
8689 } | 8721 } |
8690 | 8722 |
8691 TEST_F(HttpNetworkTransactionTest, SSLWriteCertError) { | 8723 TEST_F(HttpNetworkTransactionSpdy2Test, SSLWriteCertError) { |
8692 // Just check a grab bag of cert errors. | 8724 // Just check a grab bag of cert errors. |
8693 static const int kErrors[] = { | 8725 static const int kErrors[] = { |
8694 ERR_CERT_COMMON_NAME_INVALID, | 8726 ERR_CERT_COMMON_NAME_INVALID, |
8695 ERR_CERT_AUTHORITY_INVALID, | 8727 ERR_CERT_AUTHORITY_INVALID, |
8696 ERR_CERT_DATE_INVALID, | 8728 ERR_CERT_DATE_INVALID, |
8697 }; | 8729 }; |
8698 for (size_t i = 0; i < arraysize(kErrors); i++) { | 8730 for (size_t i = 0; i < arraysize(kErrors); i++) { |
8699 CheckErrorIsPassedBack(kErrors[i], ASYNC); | 8731 CheckErrorIsPassedBack(kErrors[i], ASYNC); |
8700 CheckErrorIsPassedBack(kErrors[i], SYNCHRONOUS); | 8732 CheckErrorIsPassedBack(kErrors[i], SYNCHRONOUS); |
8701 } | 8733 } |
8702 } | 8734 } |
8703 | 8735 |
8704 // Ensure that a client certificate is removed from the SSL client auth | 8736 // Ensure that a client certificate is removed from the SSL client auth |
8705 // cache when: | 8737 // cache when: |
8706 // 1) No proxy is involved. | 8738 // 1) No proxy is involved. |
8707 // 2) TLS False Start is disabled. | 8739 // 2) TLS False Start is disabled. |
8708 // 3) The initial TLS handshake requests a client certificate. | 8740 // 3) The initial TLS handshake requests a client certificate. |
8709 // 4) The client supplies an invalid/unacceptable certificate. | 8741 // 4) The client supplies an invalid/unacceptable certificate. |
8710 TEST_F(HttpNetworkTransactionTest, ClientAuthCertCache_Direct_NoFalseStart) { | 8742 TEST_F(HttpNetworkTransactionSpdy2Test, |
| 8743 ClientAuthCertCache_Direct_NoFalseStart) { |
8711 net::HttpRequestInfo request_info; | 8744 net::HttpRequestInfo request_info; |
8712 request_info.url = GURL("https://www.example.com/"); | 8745 request_info.url = GURL("https://www.example.com/"); |
8713 request_info.method = "GET"; | 8746 request_info.method = "GET"; |
8714 request_info.load_flags = net::LOAD_NORMAL; | 8747 request_info.load_flags = net::LOAD_NORMAL; |
8715 | 8748 |
8716 SessionDependencies session_deps; | 8749 SessionDependencies session_deps; |
8717 | 8750 |
8718 scoped_refptr<SSLCertRequestInfo> cert_request(new SSLCertRequestInfo()); | 8751 scoped_refptr<SSLCertRequestInfo> cert_request(new SSLCertRequestInfo()); |
8719 cert_request->host_and_port = "www.example.com:443"; | 8752 cert_request->host_and_port = "www.example.com:443"; |
8720 | 8753 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8790 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup("www.example.com:443", | 8823 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup("www.example.com:443", |
8791 &client_cert)); | 8824 &client_cert)); |
8792 } | 8825 } |
8793 | 8826 |
8794 // Ensure that a client certificate is removed from the SSL client auth | 8827 // Ensure that a client certificate is removed from the SSL client auth |
8795 // cache when: | 8828 // cache when: |
8796 // 1) No proxy is involved. | 8829 // 1) No proxy is involved. |
8797 // 2) TLS False Start is enabled. | 8830 // 2) TLS False Start is enabled. |
8798 // 3) The initial TLS handshake requests a client certificate. | 8831 // 3) The initial TLS handshake requests a client certificate. |
8799 // 4) The client supplies an invalid/unacceptable certificate. | 8832 // 4) The client supplies an invalid/unacceptable certificate. |
8800 TEST_F(HttpNetworkTransactionTest, ClientAuthCertCache_Direct_FalseStart) { | 8833 TEST_F(HttpNetworkTransactionSpdy2Test, |
| 8834 ClientAuthCertCache_Direct_FalseStart) { |
8801 net::HttpRequestInfo request_info; | 8835 net::HttpRequestInfo request_info; |
8802 request_info.url = GURL("https://www.example.com/"); | 8836 request_info.url = GURL("https://www.example.com/"); |
8803 request_info.method = "GET"; | 8837 request_info.method = "GET"; |
8804 request_info.load_flags = net::LOAD_NORMAL; | 8838 request_info.load_flags = net::LOAD_NORMAL; |
8805 | 8839 |
8806 SessionDependencies session_deps; | 8840 SessionDependencies session_deps; |
8807 | 8841 |
8808 scoped_refptr<SSLCertRequestInfo> cert_request(new SSLCertRequestInfo()); | 8842 scoped_refptr<SSLCertRequestInfo> cert_request(new SSLCertRequestInfo()); |
8809 cert_request->host_and_port = "www.example.com:443"; | 8843 cert_request->host_and_port = "www.example.com:443"; |
8810 | 8844 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8897 } | 8931 } |
8898 | 8932 |
8899 // Ensure that a client certificate is removed from the SSL client auth | 8933 // Ensure that a client certificate is removed from the SSL client auth |
8900 // cache when: | 8934 // cache when: |
8901 // 1) An HTTPS proxy is involved. | 8935 // 1) An HTTPS proxy is involved. |
8902 // 3) The HTTPS proxy requests a client certificate. | 8936 // 3) The HTTPS proxy requests a client certificate. |
8903 // 4) The client supplies an invalid/unacceptable certificate for the | 8937 // 4) The client supplies an invalid/unacceptable certificate for the |
8904 // proxy. | 8938 // proxy. |
8905 // The test is repeated twice, first for connecting to an HTTPS endpoint, | 8939 // The test is repeated twice, first for connecting to an HTTPS endpoint, |
8906 // then for connecting to an HTTP endpoint. | 8940 // then for connecting to an HTTP endpoint. |
8907 TEST_F(HttpNetworkTransactionTest, ClientAuthCertCache_Proxy_Fail) { | 8941 TEST_F(HttpNetworkTransactionSpdy2Test, ClientAuthCertCache_Proxy_Fail) { |
8908 SessionDependencies session_deps( | 8942 SessionDependencies session_deps( |
8909 ProxyService::CreateFixed("https://proxy:70")); | 8943 ProxyService::CreateFixed("https://proxy:70")); |
8910 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 8944 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); |
8911 session_deps.net_log = log.bound().net_log(); | 8945 session_deps.net_log = log.bound().net_log(); |
8912 | 8946 |
8913 scoped_refptr<SSLCertRequestInfo> cert_request(new SSLCertRequestInfo()); | 8947 scoped_refptr<SSLCertRequestInfo> cert_request(new SSLCertRequestInfo()); |
8914 cert_request->host_and_port = "proxy:70"; | 8948 cert_request->host_and_port = "proxy:70"; |
8915 | 8949 |
8916 // See ClientAuthCertCache_Direct_NoFalseStart for the explanation of | 8950 // See ClientAuthCertCache_Direct_NoFalseStart for the explanation of |
8917 // [ssl_]data[1-3]. Rather than represending the endpoint | 8951 // [ssl_]data[1-3]. Rather than represending the endpoint |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8987 | 9021 |
8988 // Now that the new handshake has failed, ensure that the client | 9022 // Now that the new handshake has failed, ensure that the client |
8989 // certificate was removed from the client auth cache. | 9023 // certificate was removed from the client auth cache. |
8990 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup("proxy:70", | 9024 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup("proxy:70", |
8991 &client_cert)); | 9025 &client_cert)); |
8992 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup("www.example.com:443", | 9026 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup("www.example.com:443", |
8993 &client_cert)); | 9027 &client_cert)); |
8994 } | 9028 } |
8995 } | 9029 } |
8996 | 9030 |
| 9031 namespace { |
| 9032 |
8997 void IPPoolingAddAlias(MockCachingHostResolver* host_resolver, | 9033 void IPPoolingAddAlias(MockCachingHostResolver* host_resolver, |
8998 SpdySessionPoolPeer* pool_peer, | 9034 SpdySessionPoolPeer* pool_peer, |
8999 std::string host, | 9035 std::string host, |
9000 int port, | 9036 int port, |
9001 std::string iplist) { | 9037 std::string iplist) { |
9002 // Create a host resolver dependency that returns address |iplist| for | 9038 // Create a host resolver dependency that returns address |iplist| for |
9003 // resolutions of |host|. | 9039 // resolutions of |host|. |
9004 host_resolver->rules()->AddIPLiteralRule(host, iplist, ""); | 9040 host_resolver->rules()->AddIPLiteralRule(host, iplist, ""); |
9005 | 9041 |
9006 // Setup a HostPortProxyPair. | 9042 // Setup a HostPortProxyPair. |
(...skipping 13 matching lines...) Expand all Loading... |
9020 | 9056 |
9021 // Add the first address as an alias. It would have been better to call | 9057 // Add the first address as an alias. It would have been better to call |
9022 // MockClientSocket::GetPeerAddress but that returns 192.0.2.33 whereas | 9058 // MockClientSocket::GetPeerAddress but that returns 192.0.2.33 whereas |
9023 // MockHostResolver returns 127.0.0.1 (MockHostResolverBase::Reset). So we use | 9059 // MockHostResolver returns 127.0.0.1 (MockHostResolverBase::Reset). So we use |
9024 // the first address (127.0.0.1) returned by MockHostResolver as an alias for | 9060 // the first address (127.0.0.1) returned by MockHostResolver as an alias for |
9025 // the |pair|. | 9061 // the |pair|. |
9026 const addrinfo* address = addresses.head(); | 9062 const addrinfo* address = addresses.head(); |
9027 pool_peer->AddAlias(address, pair); | 9063 pool_peer->AddAlias(address, pair); |
9028 } | 9064 } |
9029 | 9065 |
9030 TEST_F(HttpNetworkTransactionTest, UseIPConnectionPooling) { | 9066 } // namespace |
| 9067 |
| 9068 TEST_F(HttpNetworkTransactionSpdy2Test, UseIPConnectionPooling) { |
9031 HttpStreamFactory::set_use_alternate_protocols(true); | 9069 HttpStreamFactory::set_use_alternate_protocols(true); |
9032 HttpStreamFactory::set_next_protos(SpdyNextProtos()); | 9070 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); |
9033 | 9071 |
9034 // Set up a special HttpNetworkSession with a MockCachingHostResolver. | 9072 // Set up a special HttpNetworkSession with a MockCachingHostResolver. |
9035 SessionDependencies session_deps; | 9073 SessionDependencies session_deps; |
9036 MockCachingHostResolver host_resolver; | 9074 MockCachingHostResolver host_resolver; |
9037 net::HttpNetworkSession::Params params; | 9075 net::HttpNetworkSession::Params params; |
9038 params.client_socket_factory = &session_deps.socket_factory; | 9076 params.client_socket_factory = &session_deps.socket_factory; |
9039 params.host_resolver = &host_resolver; | 9077 params.host_resolver = &host_resolver; |
9040 params.cert_verifier = session_deps.cert_verifier.get(); | 9078 params.cert_verifier = session_deps.cert_verifier.get(); |
9041 params.proxy_service = session_deps.proxy_service.get(); | 9079 params.proxy_service = session_deps.proxy_service.get(); |
9042 params.ssl_config_service = session_deps.ssl_config_service; | 9080 params.ssl_config_service = session_deps.ssl_config_service; |
9043 params.http_auth_handler_factory = | 9081 params.http_auth_handler_factory = |
9044 session_deps.http_auth_handler_factory.get(); | 9082 session_deps.http_auth_handler_factory.get(); |
9045 params.http_server_properties = &session_deps.http_server_properties; | 9083 params.http_server_properties = &session_deps.http_server_properties; |
9046 params.net_log = session_deps.net_log; | 9084 params.net_log = session_deps.net_log; |
9047 scoped_refptr<HttpNetworkSession> session(new HttpNetworkSession(params)); | 9085 scoped_refptr<HttpNetworkSession> session(new HttpNetworkSession(params)); |
9048 SpdySessionPoolPeer pool_peer(session->spdy_session_pool()); | 9086 SpdySessionPoolPeer pool_peer(session->spdy_session_pool()); |
9049 pool_peer.DisableDomainAuthenticationVerification(); | 9087 pool_peer.DisableDomainAuthenticationVerification(); |
9050 | 9088 |
9051 SSLSocketDataProvider ssl(ASYNC, OK); | 9089 SSLSocketDataProvider ssl(ASYNC, OK); |
9052 ssl.SetNextProto(SSLClientSocket::kProtoSPDY21); | 9090 ssl.SetNextProto(SSLClientSocket::kProtoSPDY2); |
9053 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 9091 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
9054 | 9092 |
9055 scoped_ptr<spdy::SpdyFrame> host1_req(ConstructSpdyGet( | 9093 scoped_ptr<spdy::SpdyFrame> host1_req(ConstructSpdyGet( |
9056 "https://www.google.com", false, 1, LOWEST)); | 9094 "https://www.google.com", false, 1, LOWEST)); |
9057 scoped_ptr<spdy::SpdyFrame> host2_req(ConstructSpdyGet( | 9095 scoped_ptr<spdy::SpdyFrame> host2_req(ConstructSpdyGet( |
9058 "https://www.gmail.com", false, 3, LOWEST)); | 9096 "https://www.gmail.com", false, 3, LOWEST)); |
9059 MockWrite spdy_writes[] = { | 9097 MockWrite spdy_writes[] = { |
9060 CreateMockWrite(*host1_req, 1), | 9098 CreateMockWrite(*host1_req, 1), |
9061 CreateMockWrite(*host2_req, 4), | 9099 CreateMockWrite(*host2_req, 4), |
9062 }; | 9100 }; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9126 | 9164 |
9127 response = trans2.GetResponseInfo(); | 9165 response = trans2.GetResponseInfo(); |
9128 ASSERT_TRUE(response != NULL); | 9166 ASSERT_TRUE(response != NULL); |
9129 ASSERT_TRUE(response->headers != NULL); | 9167 ASSERT_TRUE(response->headers != NULL); |
9130 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 9168 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
9131 EXPECT_TRUE(response->was_fetched_via_spdy); | 9169 EXPECT_TRUE(response->was_fetched_via_spdy); |
9132 EXPECT_TRUE(response->was_npn_negotiated); | 9170 EXPECT_TRUE(response->was_npn_negotiated); |
9133 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); | 9171 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); |
9134 EXPECT_EQ("hello!", response_data); | 9172 EXPECT_EQ("hello!", response_data); |
9135 | 9173 |
9136 HttpStreamFactory::set_next_protos(std::vector<std::string>()); | 9174 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); |
9137 HttpStreamFactory::set_use_alternate_protocols(false); | 9175 HttpStreamFactory::set_use_alternate_protocols(false); |
9138 } | 9176 } |
9139 | 9177 |
9140 class OneTimeCachingHostResolver : public net::HostResolver { | 9178 class OneTimeCachingHostResolver : public net::HostResolver { |
9141 public: | 9179 public: |
9142 explicit OneTimeCachingHostResolver(const HostPortPair& host_port) | 9180 explicit OneTimeCachingHostResolver(const HostPortPair& host_port) |
9143 : host_port_(host_port) {} | 9181 : host_port_(host_port) {} |
9144 virtual ~OneTimeCachingHostResolver() {} | 9182 virtual ~OneTimeCachingHostResolver() {} |
9145 | 9183 |
9146 RuleBasedHostResolverProc* rules() { return host_resolver_.rules(); } | 9184 RuleBasedHostResolverProc* rules() { return host_resolver_.rules(); } |
(...skipping 23 matching lines...) Expand all Loading... |
9170 | 9208 |
9171 MockCachingHostResolver* GetMockHostResolver() { | 9209 MockCachingHostResolver* GetMockHostResolver() { |
9172 return &host_resolver_; | 9210 return &host_resolver_; |
9173 } | 9211 } |
9174 | 9212 |
9175 private: | 9213 private: |
9176 MockCachingHostResolver host_resolver_; | 9214 MockCachingHostResolver host_resolver_; |
9177 const HostPortPair host_port_; | 9215 const HostPortPair host_port_; |
9178 }; | 9216 }; |
9179 | 9217 |
9180 TEST_F(HttpNetworkTransactionTest, | 9218 TEST_F(HttpNetworkTransactionSpdy2Test, |
9181 UseIPConnectionPoolingWithHostCacheExpiration) { | 9219 UseIPConnectionPoolingWithHostCacheExpiration) { |
9182 HttpStreamFactory::set_use_alternate_protocols(true); | 9220 HttpStreamFactory::set_use_alternate_protocols(true); |
9183 HttpStreamFactory::set_next_protos(SpdyNextProtos()); | 9221 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); |
9184 | 9222 |
9185 // Set up a special HttpNetworkSession with a OneTimeCachingHostResolver. | 9223 // Set up a special HttpNetworkSession with a OneTimeCachingHostResolver. |
9186 SessionDependencies session_deps; | 9224 SessionDependencies session_deps; |
9187 OneTimeCachingHostResolver host_resolver(HostPortPair("www.gmail.com", 443)); | 9225 OneTimeCachingHostResolver host_resolver(HostPortPair("www.gmail.com", 443)); |
9188 net::HttpNetworkSession::Params params; | 9226 net::HttpNetworkSession::Params params; |
9189 params.client_socket_factory = &session_deps.socket_factory; | 9227 params.client_socket_factory = &session_deps.socket_factory; |
9190 params.host_resolver = &host_resolver; | 9228 params.host_resolver = &host_resolver; |
9191 params.cert_verifier = session_deps.cert_verifier.get(); | 9229 params.cert_verifier = session_deps.cert_verifier.get(); |
9192 params.proxy_service = session_deps.proxy_service.get(); | 9230 params.proxy_service = session_deps.proxy_service.get(); |
9193 params.ssl_config_service = session_deps.ssl_config_service; | 9231 params.ssl_config_service = session_deps.ssl_config_service; |
9194 params.http_auth_handler_factory = | 9232 params.http_auth_handler_factory = |
9195 session_deps.http_auth_handler_factory.get(); | 9233 session_deps.http_auth_handler_factory.get(); |
9196 params.http_server_properties = &session_deps.http_server_properties; | 9234 params.http_server_properties = &session_deps.http_server_properties; |
9197 params.net_log = session_deps.net_log; | 9235 params.net_log = session_deps.net_log; |
9198 scoped_refptr<HttpNetworkSession> session(new HttpNetworkSession(params)); | 9236 scoped_refptr<HttpNetworkSession> session(new HttpNetworkSession(params)); |
9199 SpdySessionPoolPeer pool_peer(session->spdy_session_pool()); | 9237 SpdySessionPoolPeer pool_peer(session->spdy_session_pool()); |
9200 pool_peer.DisableDomainAuthenticationVerification(); | 9238 pool_peer.DisableDomainAuthenticationVerification(); |
9201 | 9239 |
9202 SSLSocketDataProvider ssl(ASYNC, OK); | 9240 SSLSocketDataProvider ssl(ASYNC, OK); |
9203 ssl.SetNextProto(SSLClientSocket::kProtoSPDY21); | 9241 ssl.SetNextProto(SSLClientSocket::kProtoSPDY2); |
9204 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 9242 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
9205 | 9243 |
9206 scoped_ptr<spdy::SpdyFrame> host1_req(ConstructSpdyGet( | 9244 scoped_ptr<spdy::SpdyFrame> host1_req(ConstructSpdyGet( |
9207 "https://www.google.com", false, 1, LOWEST)); | 9245 "https://www.google.com", false, 1, LOWEST)); |
9208 scoped_ptr<spdy::SpdyFrame> host2_req(ConstructSpdyGet( | 9246 scoped_ptr<spdy::SpdyFrame> host2_req(ConstructSpdyGet( |
9209 "https://www.gmail.com", false, 3, LOWEST)); | 9247 "https://www.gmail.com", false, 3, LOWEST)); |
9210 MockWrite spdy_writes[] = { | 9248 MockWrite spdy_writes[] = { |
9211 CreateMockWrite(*host1_req, 1), | 9249 CreateMockWrite(*host1_req, 1), |
9212 CreateMockWrite(*host2_req, 4), | 9250 CreateMockWrite(*host2_req, 4), |
9213 }; | 9251 }; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9276 | 9314 |
9277 response = trans2.GetResponseInfo(); | 9315 response = trans2.GetResponseInfo(); |
9278 ASSERT_TRUE(response != NULL); | 9316 ASSERT_TRUE(response != NULL); |
9279 ASSERT_TRUE(response->headers != NULL); | 9317 ASSERT_TRUE(response->headers != NULL); |
9280 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 9318 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
9281 EXPECT_TRUE(response->was_fetched_via_spdy); | 9319 EXPECT_TRUE(response->was_fetched_via_spdy); |
9282 EXPECT_TRUE(response->was_npn_negotiated); | 9320 EXPECT_TRUE(response->was_npn_negotiated); |
9283 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); | 9321 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); |
9284 EXPECT_EQ("hello!", response_data); | 9322 EXPECT_EQ("hello!", response_data); |
9285 | 9323 |
9286 HttpStreamFactory::set_next_protos(std::vector<std::string>()); | 9324 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); |
9287 HttpStreamFactory::set_use_alternate_protocols(false); | 9325 HttpStreamFactory::set_use_alternate_protocols(false); |
9288 } | 9326 } |
9289 | 9327 |
9290 TEST_F(HttpNetworkTransactionTest, ReadPipelineEvictionFallback) { | 9328 TEST_F(HttpNetworkTransactionSpdy2Test, ReadPipelineEvictionFallback) { |
9291 MockRead data_reads1[] = { | 9329 MockRead data_reads1[] = { |
9292 MockRead(SYNCHRONOUS, ERR_PIPELINE_EVICTION), | 9330 MockRead(SYNCHRONOUS, ERR_PIPELINE_EVICTION), |
9293 }; | 9331 }; |
9294 MockRead data_reads2[] = { | 9332 MockRead data_reads2[] = { |
9295 MockRead("HTTP/1.0 200 OK\r\n\r\n"), | 9333 MockRead("HTTP/1.0 200 OK\r\n\r\n"), |
9296 MockRead("hello world"), | 9334 MockRead("hello world"), |
9297 MockRead(SYNCHRONOUS, OK), | 9335 MockRead(SYNCHRONOUS, OK), |
9298 }; | 9336 }; |
9299 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), NULL, 0); | 9337 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), NULL, 0); |
9300 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), NULL, 0); | 9338 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), NULL, 0); |
9301 StaticSocketDataProvider* data[] = { &data1, &data2 }; | 9339 StaticSocketDataProvider* data[] = { &data1, &data2 }; |
9302 | 9340 |
9303 SimpleGetHelperResult out = SimpleGetHelperForData(data, arraysize(data)); | 9341 SimpleGetHelperResult out = SimpleGetHelperForData(data, arraysize(data)); |
9304 | 9342 |
9305 EXPECT_EQ(OK, out.rv); | 9343 EXPECT_EQ(OK, out.rv); |
9306 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line); | 9344 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line); |
9307 EXPECT_EQ("hello world", out.response_data); | 9345 EXPECT_EQ("hello world", out.response_data); |
9308 } | 9346 } |
9309 | 9347 |
9310 TEST_F(HttpNetworkTransactionTest, SendPipelineEvictionFallback) { | 9348 TEST_F(HttpNetworkTransactionSpdy2Test, SendPipelineEvictionFallback) { |
9311 MockWrite data_writes1[] = { | 9349 MockWrite data_writes1[] = { |
9312 MockWrite(SYNCHRONOUS, ERR_PIPELINE_EVICTION), | 9350 MockWrite(SYNCHRONOUS, ERR_PIPELINE_EVICTION), |
9313 }; | 9351 }; |
9314 MockWrite data_writes2[] = { | 9352 MockWrite data_writes2[] = { |
9315 MockWrite("GET / HTTP/1.1\r\n" | 9353 MockWrite("GET / HTTP/1.1\r\n" |
9316 "Host: www.google.com\r\n" | 9354 "Host: www.google.com\r\n" |
9317 "Connection: keep-alive\r\n\r\n"), | 9355 "Connection: keep-alive\r\n\r\n"), |
9318 }; | 9356 }; |
9319 MockRead data_reads2[] = { | 9357 MockRead data_reads2[] = { |
9320 MockRead("HTTP/1.0 200 OK\r\n\r\n"), | 9358 MockRead("HTTP/1.0 200 OK\r\n\r\n"), |
9321 MockRead("hello world"), | 9359 MockRead("hello world"), |
9322 MockRead(SYNCHRONOUS, OK), | 9360 MockRead(SYNCHRONOUS, OK), |
9323 }; | 9361 }; |
9324 StaticSocketDataProvider data1(NULL, 0, | 9362 StaticSocketDataProvider data1(NULL, 0, |
9325 data_writes1, arraysize(data_writes1)); | 9363 data_writes1, arraysize(data_writes1)); |
9326 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 9364 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
9327 data_writes2, arraysize(data_writes2)); | 9365 data_writes2, arraysize(data_writes2)); |
9328 StaticSocketDataProvider* data[] = { &data1, &data2 }; | 9366 StaticSocketDataProvider* data[] = { &data1, &data2 }; |
9329 | 9367 |
9330 SimpleGetHelperResult out = SimpleGetHelperForData(data, arraysize(data)); | 9368 SimpleGetHelperResult out = SimpleGetHelperForData(data, arraysize(data)); |
9331 | 9369 |
9332 EXPECT_EQ(OK, out.rv); | 9370 EXPECT_EQ(OK, out.rv); |
9333 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line); | 9371 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line); |
9334 EXPECT_EQ("hello world", out.response_data); | 9372 EXPECT_EQ("hello world", out.response_data); |
9335 } | 9373 } |
9336 | 9374 |
9337 } // namespace net | 9375 } // namespace net |
OLD | NEW |