Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/data_reduction_proxy/browser/data_reduction_proxy_protocol. h" | 5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_protocol. h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 } // namespace | 50 } // namespace |
| 51 | 51 |
| 52 | 52 |
| 53 namespace data_reduction_proxy { | 53 namespace data_reduction_proxy { |
| 54 | 54 |
| 55 // A test network delegate that exercises the bypass logic of the data | 55 // A test network delegate that exercises the bypass logic of the data |
| 56 // reduction proxy. | 56 // reduction proxy. |
| 57 class TestDataReductionProxyNetworkDelegate : public net::NetworkDelegate { | 57 class TestDataReductionProxyNetworkDelegate : public net::NetworkDelegate { |
| 58 public: | 58 public: |
| 59 TestDataReductionProxyNetworkDelegate( | 59 TestDataReductionProxyNetworkDelegate( |
| 60 TestDataReductionProxyParams* test_params) | 60 TestDataReductionProxyParams* test_params, |
| 61 : net::NetworkDelegate(), test_data_reduction_proxy_params_(test_params) { | 61 ProxyService::DataReductionProxyBypassType* bypass_type) |
| 62 : net::NetworkDelegate(), | |
| 63 test_data_reduction_proxy_params_(test_params), | |
| 64 bypass_type_(bypass_type) { | |
| 62 } | 65 } |
| 63 | 66 |
| 64 virtual int OnHeadersReceived( | 67 virtual int OnHeadersReceived( |
| 65 URLRequest* request, | 68 URLRequest* request, |
| 66 const net::CompletionCallback& callback, | 69 const net::CompletionCallback& callback, |
| 67 const HttpResponseHeaders* original_response_headers, | 70 const HttpResponseHeaders* original_response_headers, |
| 68 scoped_refptr<HttpResponseHeaders>* override_response_headers, | 71 scoped_refptr<HttpResponseHeaders>* override_response_headers, |
| 69 GURL* allowed_unsafe_redirect_url) OVERRIDE { | 72 GURL* allowed_unsafe_redirect_url) OVERRIDE { |
| 70 data_reduction_proxy::MaybeBypassProxyAndPrepareToRetry( | 73 data_reduction_proxy::MaybeBypassProxyAndPrepareToRetry( |
| 71 test_data_reduction_proxy_params_, | 74 test_data_reduction_proxy_params_, |
| 72 request, | 75 request, |
| 73 original_response_headers, | 76 original_response_headers, |
| 74 override_response_headers); | 77 override_response_headers, |
| 78 bypass_type_); | |
| 75 return net::OK; | 79 return net::OK; |
| 76 } | 80 } |
| 77 | 81 |
| 78 TestDataReductionProxyParams* test_data_reduction_proxy_params_; | 82 TestDataReductionProxyParams* test_data_reduction_proxy_params_; |
| 83 ProxyService::DataReductionProxyBypassType* bypass_type_; | |
| 79 }; | 84 }; |
| 80 | 85 |
| 81 // Constructs a |TestURLRequestContext| that uses a |MockSocketFactory| to | 86 // Constructs a |TestURLRequestContext| that uses a |MockSocketFactory| to |
| 82 // simulate requests and responses. | 87 // simulate requests and responses. |
| 83 class DataReductionProxyProtocolTest : public testing::Test { | 88 class DataReductionProxyProtocolTest : public testing::Test { |
| 84 public: | 89 public: |
| 85 DataReductionProxyProtocolTest() : http_user_agent_settings_("", "") { | 90 DataReductionProxyProtocolTest() : http_user_agent_settings_("", "") { |
| 86 proxy_params_.reset( | 91 proxy_params_.reset( |
| 87 new TestDataReductionProxyParams( | 92 new TestDataReductionProxyParams( |
| 88 DataReductionProxyParams::kAllowed | | 93 DataReductionProxyParams::kAllowed | |
| 89 DataReductionProxyParams::kFallbackAllowed | | 94 DataReductionProxyParams::kFallbackAllowed | |
| 90 DataReductionProxyParams::kPromoAllowed, | 95 DataReductionProxyParams::kPromoAllowed, |
| 91 TestDataReductionProxyParams::HAS_EVERYTHING & | 96 TestDataReductionProxyParams::HAS_EVERYTHING & |
| 92 ~TestDataReductionProxyParams::HAS_DEV_ORIGIN)); | 97 ~TestDataReductionProxyParams::HAS_DEV_ORIGIN)); |
| 93 } | 98 } |
| 94 | 99 |
| 95 // Sets up the |TestURLRequestContext| with the provided |ProxyService|. | 100 // Sets up the |TestURLRequestContext| with the provided |ProxyService|. |
|
bengr
2014/07/21 22:23:57
Mention the bypass_type
megjablon
2014/07/22 02:11:30
Done.
| |
| 96 void ConfigureTestDependencies(ProxyService* proxy_service) { | 101 void ConfigureTestDependencies( |
| 102 ProxyService* proxy_service, | |
| 103 ProxyService::DataReductionProxyBypassType* bypass_type) { | |
| 97 // Create a context with delayed initialization. | 104 // Create a context with delayed initialization. |
| 98 context_.reset(new TestURLRequestContext(true)); | 105 context_.reset(new TestURLRequestContext(true)); |
| 99 | 106 |
| 100 proxy_service_.reset(proxy_service); | 107 proxy_service_.reset(proxy_service); |
| 101 network_delegate_.reset(new TestDataReductionProxyNetworkDelegate( | 108 network_delegate_.reset(new TestDataReductionProxyNetworkDelegate( |
| 102 proxy_params_.get())); | 109 proxy_params_.get(), bypass_type)); |
| 103 | 110 |
| 104 context_->set_client_socket_factory(&mock_socket_factory_); | 111 context_->set_client_socket_factory(&mock_socket_factory_); |
| 105 context_->set_proxy_service(proxy_service_.get()); | 112 context_->set_proxy_service(proxy_service_.get()); |
| 106 context_->set_network_delegate(network_delegate_.get()); | 113 context_->set_network_delegate(network_delegate_.get()); |
| 107 // This is needed to prevent the test context from adding language headers | 114 // This is needed to prevent the test context from adding language headers |
| 108 // to requests. | 115 // to requests. |
| 109 context_->set_http_user_agent_settings(&http_user_agent_settings_); | 116 context_->set_http_user_agent_settings(&http_user_agent_settings_); |
| 110 | 117 |
| 111 context_->Init(); | 118 context_->Init(); |
| 112 } | 119 } |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 352 // was indicated. In both the single and double bypass cases, if the request | 359 // was indicated. In both the single and double bypass cases, if the request |
| 353 // was idempotent, it will be retried over a direct connection. | 360 // was idempotent, it will be retried over a direct connection. |
| 354 TEST_F(DataReductionProxyProtocolTest, BypassLogic) { | 361 TEST_F(DataReductionProxyProtocolTest, BypassLogic) { |
| 355 const struct { | 362 const struct { |
| 356 const char* method; | 363 const char* method; |
| 357 const char* first_response; | 364 const char* first_response; |
| 358 bool expected_retry; | 365 bool expected_retry; |
| 359 size_t expected_bad_proxy_count; | 366 size_t expected_bad_proxy_count; |
| 360 bool expect_response_body; | 367 bool expect_response_body; |
| 361 int expected_duration; | 368 int expected_duration; |
| 369 ProxyService::DataReductionProxyBypassType expected_bypass_type; | |
| 362 } tests[] = { | 370 } tests[] = { |
| 363 // Valid data reduction proxy response with no bypass message. | 371 // Valid data reduction proxy response with no bypass message. |
| 364 { "GET", | 372 { "GET", |
| 365 "HTTP/1.1 200 OK\r\n" | 373 "HTTP/1.1 200 OK\r\n" |
| 366 "Server: proxy\r\n" | 374 "Server: proxy\r\n" |
| 367 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", | 375 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", |
| 368 false, | 376 false, |
| 369 0u, | 377 0u, |
| 370 true, | 378 true, |
| 371 -1 | 379 -1, |
| 380 ProxyService::BYPASS_EVENT_TYPE_MAX, | |
| 372 }, | 381 }, |
| 373 // Valid data reduction proxy response with older, but still valid via | 382 // Valid data reduction proxy response with older, but still valid via |
| 374 // header. | 383 // header. |
| 375 { "GET", | 384 { "GET", |
| 376 "HTTP/1.1 200 OK\r\n" | 385 "HTTP/1.1 200 OK\r\n" |
| 377 "Server: proxy\r\n" | 386 "Server: proxy\r\n" |
| 378 "Via: 1.1 Chrome Compression Proxy\r\n\r\n", | 387 "Via: 1.1 Chrome Compression Proxy\r\n\r\n", |
| 379 false, | 388 false, |
| 380 0u, | 389 0u, |
| 381 true, | 390 true, |
| 382 -1 | 391 -1, |
| 392 ProxyService::BYPASS_EVENT_TYPE_MAX | |
| 383 }, | 393 }, |
| 384 // Valid data reduction proxy response with chained via header, | 394 // Valid data reduction proxy response with chained via header, |
| 385 // no bypass message. | 395 // no bypass message. |
| 386 { "GET", | 396 { "GET", |
| 387 "HTTP/1.1 200 OK\r\n" | 397 "HTTP/1.1 200 OK\r\n" |
| 388 "Server: proxy\r\n" | 398 "Server: proxy\r\n" |
| 389 "Via: 1.1 Chrome-Compression-Proxy, 1.0 some-other-proxy\r\n\r\n", | 399 "Via: 1.1 Chrome-Compression-Proxy, 1.0 some-other-proxy\r\n\r\n", |
| 390 false, | 400 false, |
| 391 0u, | 401 0u, |
| 392 true, | 402 true, |
| 393 -1 | 403 -1, |
| 404 ProxyService::BYPASS_EVENT_TYPE_MAX | |
| 394 }, | 405 }, |
| 395 // Valid data reduction proxy response with a bypass message. | 406 // Valid data reduction proxy response with a bypass message. |
| 396 { "GET", | 407 { "GET", |
| 397 "HTTP/1.1 200 OK\r\n" | 408 "HTTP/1.1 200 OK\r\n" |
| 398 "Server: proxy\r\n" | 409 "Server: proxy\r\n" |
| 399 "Chrome-Proxy: bypass=0\r\n" | 410 "Chrome-Proxy: bypass=0\r\n" |
| 400 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", | 411 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", |
| 401 true, | 412 true, |
| 402 1u, | 413 1u, |
| 403 true, | 414 true, |
| 404 0 | 415 0, |
| 416 ProxyService::MEDIUM_BYPASS | |
| 405 }, | 417 }, |
| 406 // Valid data reduction proxy response with a bypass message. | 418 // Valid data reduction proxy response with a bypass message. |
| 407 { "GET", | 419 { "GET", |
| 408 "HTTP/1.1 200 OK\r\n" | 420 "HTTP/1.1 200 OK\r\n" |
| 409 "Server: proxy\r\n" | 421 "Server: proxy\r\n" |
| 410 "Chrome-Proxy: bypass=1\r\n" | 422 "Chrome-Proxy: bypass=1\r\n" |
| 411 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", | 423 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", |
| 412 true, | 424 true, |
| 413 1u, | 425 1u, |
| 414 true, | 426 true, |
| 415 1 | 427 1, |
| 428 ProxyService::SHORT_BYPASS | |
| 416 }, | 429 }, |
| 417 // Same as above with the OPTIONS method, which is idempotent. | 430 // Same as above with the OPTIONS method, which is idempotent. |
| 418 { "OPTIONS", | 431 { "OPTIONS", |
| 419 "HTTP/1.1 200 OK\r\n" | 432 "HTTP/1.1 200 OK\r\n" |
| 420 "Server: proxy\r\n" | 433 "Server: proxy\r\n" |
| 421 "Chrome-Proxy: bypass=0\r\n" | 434 "Chrome-Proxy: bypass=0\r\n" |
| 422 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", | 435 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", |
| 423 true, | 436 true, |
| 424 1u, | 437 1u, |
| 425 true, | 438 true, |
| 426 0 | 439 0, |
| 440 ProxyService::MEDIUM_BYPASS | |
| 427 }, | 441 }, |
| 428 // Same as above with the HEAD method, which is idempotent. | 442 // Same as above with the HEAD method, which is idempotent. |
| 429 { "HEAD", | 443 { "HEAD", |
| 430 "HTTP/1.1 200 OK\r\n" | 444 "HTTP/1.1 200 OK\r\n" |
| 431 "Server: proxy\r\n" | 445 "Server: proxy\r\n" |
| 432 "Chrome-Proxy: bypass=0\r\n" | 446 "Chrome-Proxy: bypass=0\r\n" |
| 433 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", | 447 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", |
| 434 true, | 448 true, |
| 435 1u, | 449 1u, |
| 436 false, | 450 false, |
| 437 0 | 451 0, |
| 452 ProxyService::MEDIUM_BYPASS | |
| 438 }, | 453 }, |
| 439 // Same as above with the PUT method, which is idempotent. | 454 // Same as above with the PUT method, which is idempotent. |
| 440 { "PUT", | 455 { "PUT", |
| 441 "HTTP/1.1 200 OK\r\n" | 456 "HTTP/1.1 200 OK\r\n" |
| 442 "Server: proxy\r\n" | 457 "Server: proxy\r\n" |
| 443 "Chrome-Proxy: bypass=0\r\n" | 458 "Chrome-Proxy: bypass=0\r\n" |
| 444 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", | 459 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", |
| 445 true, | 460 true, |
| 446 1u, | 461 1u, |
| 447 true, | 462 true, |
| 448 0 | 463 0, |
| 464 ProxyService::MEDIUM_BYPASS | |
| 449 }, | 465 }, |
| 450 // Same as above with the DELETE method, which is idempotent. | 466 // Same as above with the DELETE method, which is idempotent. |
| 451 { "DELETE", | 467 { "DELETE", |
| 452 "HTTP/1.1 200 OK\r\n" | 468 "HTTP/1.1 200 OK\r\n" |
| 453 "Server: proxy\r\n" | 469 "Server: proxy\r\n" |
| 454 "Chrome-Proxy: bypass=0\r\n" | 470 "Chrome-Proxy: bypass=0\r\n" |
| 455 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", | 471 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", |
| 456 true, | 472 true, |
| 457 1u, | 473 1u, |
| 458 true, | 474 true, |
| 459 0 | 475 0, |
| 476 ProxyService::MEDIUM_BYPASS | |
| 460 }, | 477 }, |
| 461 // Same as above with the TRACE method, which is idempotent. | 478 // Same as above with the TRACE method, which is idempotent. |
| 462 { "TRACE", | 479 { "TRACE", |
| 463 "HTTP/1.1 200 OK\r\n" | 480 "HTTP/1.1 200 OK\r\n" |
| 464 "Server: proxy\r\n" | 481 "Server: proxy\r\n" |
| 465 "Chrome-Proxy: bypass=0\r\n" | 482 "Chrome-Proxy: bypass=0\r\n" |
| 466 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", | 483 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", |
| 467 true, | 484 true, |
| 468 1u, | 485 1u, |
| 469 true, | 486 true, |
| 470 0 | 487 0, |
| 488 ProxyService::MEDIUM_BYPASS | |
| 471 }, | 489 }, |
| 472 // 500 responses should be bypassed. | 490 // 500 responses should be bypassed. |
| 473 { "GET", | 491 { "GET", |
| 474 "HTTP/1.1 500 Internal Server Error\r\n" | 492 "HTTP/1.1 500 Internal Server Error\r\n" |
| 475 "Server: proxy\r\n" | 493 "Server: proxy\r\n" |
| 476 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", | 494 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", |
| 477 true, | 495 true, |
| 478 1u, | 496 1u, |
| 479 true, | 497 true, |
| 480 0 | 498 0, |
| 499 ProxyService::STATUS_500_HTTP_INTERNAL_SERVER_ERROR | |
| 481 }, | 500 }, |
| 482 // 502 responses should be bypassed. | 501 // 502 responses should be bypassed. |
| 483 { "GET", | 502 { "GET", |
| 484 "HTTP/1.1 502 Internal Server Error\r\n" | 503 "HTTP/1.1 502 Internal Server Error\r\n" |
| 485 "Server: proxy\r\n" | 504 "Server: proxy\r\n" |
| 486 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", | 505 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", |
| 487 true, | 506 true, |
| 488 1u, | 507 1u, |
| 489 true, | 508 true, |
| 490 0 | 509 0, |
| 510 ProxyService::STATUS_502_HTTP_BAD_GATEWAY | |
| 491 }, | 511 }, |
| 492 // 503 responses should be bypassed. | 512 // 503 responses should be bypassed. |
| 493 { "GET", | 513 { "GET", |
| 494 "HTTP/1.1 503 Internal Server Error\r\n" | 514 "HTTP/1.1 503 Internal Server Error\r\n" |
| 495 "Server: proxy\r\n" | 515 "Server: proxy\r\n" |
| 496 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", | 516 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", |
| 497 true, | 517 true, |
| 498 1u, | 518 1u, |
| 499 true, | 519 true, |
| 500 0 | 520 0, |
| 521 ProxyService::STATUS_503_HTTP_SERVICE_UNAVAILABLE | |
| 501 }, | 522 }, |
| 502 // Invalid data reduction proxy response. Missing Via header. | 523 // Invalid data reduction proxy response. Missing Via header. |
| 503 { "GET", | 524 { "GET", |
| 504 "HTTP/1.1 200 OK\r\n" | 525 "HTTP/1.1 200 OK\r\n" |
| 505 "Server: proxy\r\n\r\n", | 526 "Server: proxy\r\n\r\n", |
| 506 true, | 527 true, |
| 507 1u, | 528 1u, |
| 508 true, | 529 true, |
| 509 0 | 530 0, |
| 531 ProxyService::MISSING_VIA_HEADER_OTHER | |
| 510 }, | 532 }, |
| 511 // Invalid data reduction proxy response. Wrong Via header. | 533 // Invalid data reduction proxy response. Wrong Via header. |
| 512 { "GET", | 534 { "GET", |
| 513 "HTTP/1.1 200 OK\r\n" | 535 "HTTP/1.1 200 OK\r\n" |
| 514 "Server: proxy\r\n" | 536 "Server: proxy\r\n" |
| 515 "Via: 1.0 some-other-proxy\r\n\r\n", | 537 "Via: 1.0 some-other-proxy\r\n\r\n", |
| 516 true, | 538 true, |
| 517 1u, | 539 1u, |
| 518 true, | 540 true, |
| 519 0 | 541 0, |
| 542 ProxyService::MISSING_VIA_HEADER_OTHER | |
| 520 }, | 543 }, |
| 521 // Valid data reduction proxy response. 304 missing Via header. | 544 // Valid data reduction proxy response. 304 missing Via header. |
| 522 { "GET", | 545 { "GET", |
| 523 "HTTP/1.1 304 Not Modified\r\n" | 546 "HTTP/1.1 304 Not Modified\r\n" |
| 524 "Server: proxy\r\n\r\n", | 547 "Server: proxy\r\n\r\n", |
| 525 false, | 548 false, |
| 526 0u, | 549 0u, |
| 527 false, | 550 false, |
| 528 0 | 551 0, |
| 552 ProxyService::BYPASS_EVENT_TYPE_MAX | |
| 529 }, | 553 }, |
| 530 // Valid data reduction proxy response with a bypass message. It will | 554 // Valid data reduction proxy response with a bypass message. It will |
| 531 // not be retried because the request is non-idempotent. | 555 // not be retried because the request is non-idempotent. |
| 532 { "POST", | 556 { "POST", |
| 533 "HTTP/1.1 200 OK\r\n" | 557 "HTTP/1.1 200 OK\r\n" |
| 534 "Server: proxy\r\n" | 558 "Server: proxy\r\n" |
| 535 "Chrome-Proxy: bypass=0\r\n" | 559 "Chrome-Proxy: bypass=0\r\n" |
| 536 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", | 560 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", |
| 537 false, | 561 false, |
| 538 1u, | 562 1u, |
| 539 true, | 563 true, |
| 540 0 | 564 0, |
| 565 ProxyService::MEDIUM_BYPASS | |
| 541 }, | 566 }, |
| 542 // Valid data reduction proxy response with block message. Both proxies | 567 // Valid data reduction proxy response with block message. Both proxies |
| 543 // should be on the retry list when it completes. | 568 // should be on the retry list when it completes. |
| 544 { "GET", | 569 { "GET", |
| 545 "HTTP/1.1 200 OK\r\n" | 570 "HTTP/1.1 200 OK\r\n" |
| 546 "Server: proxy\r\n" | 571 "Server: proxy\r\n" |
| 547 "Chrome-Proxy: block=1\r\n" | 572 "Chrome-Proxy: block=1\r\n" |
| 548 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", | 573 "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n", |
| 549 true, | 574 true, |
| 550 2u, | 575 2u, |
| 551 true, | 576 true, |
| 552 1 | 577 1, |
| 578 ProxyService::SHORT_BYPASS | |
| 553 } | 579 } |
| 554 }; | 580 }; |
| 555 std::string primary = proxy_params_->DefaultOrigin(); | 581 std::string primary = proxy_params_->DefaultOrigin(); |
| 556 std::string fallback = proxy_params_->DefaultFallbackOrigin(); | 582 std::string fallback = proxy_params_->DefaultFallbackOrigin(); |
| 557 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | 583 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
| 584 ProxyService::DataReductionProxyBypassType bypass_type; | |
| 558 ConfigureTestDependencies(ProxyService::CreateFixedFromPacResult( | 585 ConfigureTestDependencies(ProxyService::CreateFixedFromPacResult( |
| 559 "PROXY " + | 586 "PROXY " + |
| 560 HostPortPair::FromURL(GURL(primary)).ToString() + "; PROXY " + | 587 HostPortPair::FromURL(GURL(primary)).ToString() + "; PROXY " + |
| 561 HostPortPair::FromURL(GURL(fallback)).ToString() + "; DIRECT")); | 588 HostPortPair::FromURL(GURL(fallback)).ToString() + "; DIRECT"), |
| 589 &bypass_type); | |
| 562 TestProxyFallback(tests[i].method, | 590 TestProxyFallback(tests[i].method, |
| 563 tests[i].first_response, | 591 tests[i].first_response, |
| 564 tests[i].expected_retry, | 592 tests[i].expected_retry, |
| 565 tests[i].expect_response_body); | 593 tests[i].expect_response_body); |
| 566 | 594 |
| 595 EXPECT_EQ(tests[i].expected_bypass_type, bypass_type); | |
| 596 | |
| 567 // We should also observe the bad proxy in the retry list. | 597 // We should also observe the bad proxy in the retry list. |
| 568 TestBadProxies(tests[i].expected_bad_proxy_count, | 598 TestBadProxies(tests[i].expected_bad_proxy_count, |
| 569 tests[i].expected_duration, | 599 tests[i].expected_duration, |
| 570 primary, fallback); | 600 primary, fallback); |
| 571 } | 601 } |
| 572 } | 602 } |
| 573 | 603 |
| 574 TEST_F(DataReductionProxyProtocolTest, | 604 TEST_F(DataReductionProxyProtocolTest, |
| 575 ProxyBypassIgnoredOnDirectConnection) { | 605 ProxyBypassIgnoredOnDirectConnection) { |
| 576 // Verify that a Chrome-Proxy header is ignored when returned from a directly | 606 // Verify that a Chrome-Proxy header is ignored when returned from a directly |
| 577 // connected origin server. | 607 // connected origin server. |
| 578 ConfigureTestDependencies(ProxyService::CreateFixedFromPacResult("DIRECT")); | 608 ConfigureTestDependencies(ProxyService::CreateFixedFromPacResult("DIRECT"), |
| 609 NULL); | |
| 579 | 610 |
| 580 MockRead data_reads[] = { | 611 MockRead data_reads[] = { |
| 581 MockRead("HTTP/1.1 200 OK\r\n" | 612 MockRead("HTTP/1.1 200 OK\r\n" |
| 582 "Chrome-Proxy: bypass=0\r\n\r\n"), | 613 "Chrome-Proxy: bypass=0\r\n\r\n"), |
| 583 MockRead("Bypass message"), | 614 MockRead("Bypass message"), |
| 584 MockRead(net::SYNCHRONOUS, net::OK), | 615 MockRead(net::SYNCHRONOUS, net::OK), |
| 585 }; | 616 }; |
| 586 MockWrite data_writes[] = { | 617 MockWrite data_writes[] = { |
| 587 MockWrite("GET / HTTP/1.1\r\n" | 618 MockWrite("GET / HTTP/1.1\r\n" |
| 588 "Host: www.google.com\r\n" | 619 "Host: www.google.com\r\n" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 684 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; | 715 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; |
| 685 | 716 |
| 686 OnResolveProxyHandler(url, load_flags, &test_params, &info2); | 717 OnResolveProxyHandler(url, load_flags, &test_params, &info2); |
| 687 EXPECT_FALSE(info2.is_direct()); | 718 EXPECT_FALSE(info2.is_direct()); |
| 688 | 719 |
| 689 OnResolveProxyHandler(url, load_flags, &test_params, &info1); | 720 OnResolveProxyHandler(url, load_flags, &test_params, &info1); |
| 690 EXPECT_TRUE(info1.is_direct()); | 721 EXPECT_TRUE(info1.is_direct()); |
| 691 } | 722 } |
| 692 | 723 |
| 693 } // namespace data_reduction_proxy | 724 } // namespace data_reduction_proxy |
| OLD | NEW |