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/url_request/url_request_http_job.h" | 5 #include "net/url_request/url_request_http_job.h" |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
584 packet_timing_enabled_ = true; | 584 packet_timing_enabled_ = true; |
585 if (base::RandDouble() < .01) { | 585 if (base::RandDouble() < .01) { |
586 sdch_test_control_ = true; // 1% probability. | 586 sdch_test_control_ = true; // 1% probability. |
587 dictionaries_advertised_.reset(); | 587 dictionaries_advertised_.reset(); |
588 advertise_sdch = false; | 588 advertise_sdch = false; |
589 } else { | 589 } else { |
590 sdch_test_activated_ = true; | 590 sdch_test_activated_ = true; |
591 } | 591 } |
592 } | 592 } |
593 | 593 |
594 // Advertise "br" encoding only if transferred data is opaque to proxy. | |
595 bool advertise_brotli = false; | |
596 const HttpNetworkSession::Params* network_session_params = | |
597 request()->context()->GetNetworkSessionParams(); | |
598 if (network_session_params && network_session_params->enable_brotli) { | |
Randy Smith (Not in Mondays)
2015/12/04 16:07:52
nit: No curly braces needed if both conditional an
eustas
2015/12/07 12:30:38
Done.
| |
599 advertise_brotli = !request()->url().SchemeIs(url::kHttpScheme); | |
Randy Smith (Not in Mondays)
2015/12/04 16:07:52
I *think* you want SchemeIsCryptographic(); that's
eustas
2015/12/07 12:30:38
I'm not sure. The reason of this check is to avoid
Randy Smith (Not in Mondays)
2015/12/07 22:27:28
So I'm confused as to why ws: or ftp: (both of whi
Ryan Sleevi
2015/12/08 18:58:50
+1 - I agree with Randy here.
!SchemeIs(url::kHtt
| |
600 } | |
601 | |
594 // Supply Accept-Encoding headers first so that it is more likely that they | 602 // Supply Accept-Encoding headers first so that it is more likely that they |
595 // will be in the first transmitted packet. This can sometimes make it | 603 // will be in the first transmitted packet. This can sometimes make it |
596 // easier to filter and analyze the streams to assure that a proxy has not | 604 // easier to filter and analyze the streams to assure that a proxy has not |
597 // damaged these headers. Some proxies deliberately corrupt Accept-Encoding | 605 // damaged these headers. Some proxies deliberately corrupt Accept-Encoding |
598 // headers. | 606 // headers. |
599 if (!advertise_sdch) { | 607 std::string advertised_encodings = "gzip, deflate"; |
600 // Tell the server what compression formats we support (other than SDCH). | 608 if (advertise_sdch) |
609 advertised_encodings += ", sdch"; | |
610 if (advertise_brotli) | |
611 advertised_encodings += ", br"; | |
612 // Tell the server what compression formats we support. | |
xunjieli
2015/12/04 15:21:19
nit: avoid using first person pronouns. Maybe chan
eustas
2015/12/04 16:14:31
Nice! Fixed.
| |
613 request_info_.extra_headers.SetHeader(HttpRequestHeaders::kAcceptEncoding, | |
614 advertised_encodings); | |
615 | |
616 if (dictionaries_advertised_) { | |
601 request_info_.extra_headers.SetHeader( | 617 request_info_.extra_headers.SetHeader( |
602 HttpRequestHeaders::kAcceptEncoding, "gzip, deflate"); | 618 kAvailDictionaryHeader, |
603 } else { | 619 dictionaries_advertised_->GetDictionaryClientHashList()); |
604 // Include SDCH in acceptable list. | 620 // Since we're tagging this transaction as advertising a dictionary, |
605 request_info_.extra_headers.SetHeader( | 621 // we'll definitely employ an SDCH filter (or tentative sdch filter) |
606 HttpRequestHeaders::kAcceptEncoding, "gzip, deflate, sdch"); | 622 // when we get a response. When done, we'll record histograms via |
607 if (dictionaries_advertised_) { | 623 // SDCH_DECODE or SDCH_PASSTHROUGH. Hence we need to record packet |
608 request_info_.extra_headers.SetHeader( | 624 // arrival times. |
609 kAvailDictionaryHeader, | 625 packet_timing_enabled_ = true; |
610 dictionaries_advertised_->GetDictionaryClientHashList()); | |
611 // Since we're tagging this transaction as advertising a dictionary, | |
612 // we'll definitely employ an SDCH filter (or tentative sdch filter) | |
613 // when we get a response. When done, we'll record histograms via | |
614 // SDCH_DECODE or SDCH_PASSTHROUGH. Hence we need to record packet | |
615 // arrival times. | |
616 packet_timing_enabled_ = true; | |
617 } | |
618 } | 626 } |
619 } | 627 } |
620 | 628 |
621 if (http_user_agent_settings_) { | 629 if (http_user_agent_settings_) { |
622 // Only add default Accept-Language if the request didn't have it | 630 // Only add default Accept-Language if the request didn't have it |
623 // specified. | 631 // specified. |
624 std::string accept_language = | 632 std::string accept_language = |
625 http_user_agent_settings_->GetAcceptLanguage(); | 633 http_user_agent_settings_->GetAcceptLanguage(); |
626 if (!accept_language.empty()) { | 634 if (!accept_language.empty()) { |
627 request_info_.extra_headers.SetHeaderIfMissing( | 635 request_info_.extra_headers.SetHeaderIfMissing( |
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1565 return override_response_headers_.get() ? | 1573 return override_response_headers_.get() ? |
1566 override_response_headers_.get() : | 1574 override_response_headers_.get() : |
1567 transaction_->GetResponseInfo()->headers.get(); | 1575 transaction_->GetResponseInfo()->headers.get(); |
1568 } | 1576 } |
1569 | 1577 |
1570 void URLRequestHttpJob::NotifyURLRequestDestroyed() { | 1578 void URLRequestHttpJob::NotifyURLRequestDestroyed() { |
1571 awaiting_callback_ = false; | 1579 awaiting_callback_ = false; |
1572 } | 1580 } |
1573 | 1581 |
1574 } // namespace net | 1582 } // namespace net |
OLD | NEW |