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

Side by Side Diff: net/url_request/url_request_http_job.cc

Issue 1431723002: Add brotli content-encoding filter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebaseline Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/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 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 packet_timing_enabled_ = true; 596 packet_timing_enabled_ = true;
597 if (base::RandDouble() < .01) { 597 if (base::RandDouble() < .01) {
598 sdch_test_control_ = true; // 1% probability. 598 sdch_test_control_ = true; // 1% probability.
599 dictionaries_advertised_.reset(); 599 dictionaries_advertised_.reset();
600 advertise_sdch = false; 600 advertise_sdch = false;
601 } else { 601 } else {
602 sdch_test_activated_ = true; 602 sdch_test_activated_ = true;
603 } 603 }
604 } 604 }
605 605
606 // Advertise "br" encoding only if transferred data is opaque to proxy.
607 bool advertise_brotli = false;
608 const HttpNetworkSession::Params* network_session_params =
609 request()->context()->GetNetworkSessionParams();
610 if (network_session_params && network_session_params->enable_brotli)
611 advertise_brotli = request()->url().SchemeIsCryptographic();
612
606 // Supply Accept-Encoding headers first so that it is more likely that they 613 // Supply Accept-Encoding headers first so that it is more likely that they
607 // will be in the first transmitted packet. This can sometimes make it 614 // will be in the first transmitted packet. This can sometimes make it
608 // easier to filter and analyze the streams to assure that a proxy has not 615 // easier to filter and analyze the streams to assure that a proxy has not
609 // damaged these headers. Some proxies deliberately corrupt Accept-Encoding 616 // damaged these headers. Some proxies deliberately corrupt Accept-Encoding
610 // headers. 617 // headers.
611 if (!advertise_sdch) { 618 std::string advertised_encodings = "gzip, deflate";
612 // Tell the server what compression formats we support (other than SDCH). 619 if (advertise_sdch)
620 advertised_encodings += ", sdch";
621 if (advertise_brotli)
622 advertised_encodings += ", br";
623 // Tell the server what compression formats are supported.
624 request_info_.extra_headers.SetHeader(HttpRequestHeaders::kAcceptEncoding,
625 advertised_encodings);
626
627 if (dictionaries_advertised_) {
613 request_info_.extra_headers.SetHeader( 628 request_info_.extra_headers.SetHeader(
614 HttpRequestHeaders::kAcceptEncoding, "gzip, deflate"); 629 kAvailDictionaryHeader,
615 } else { 630 dictionaries_advertised_->GetDictionaryClientHashList());
616 // Include SDCH in acceptable list. 631 // Since we're tagging this transaction as advertising a dictionary,
617 request_info_.extra_headers.SetHeader( 632 // we'll definitely employ an SDCH filter (or tentative sdch filter)
618 HttpRequestHeaders::kAcceptEncoding, "gzip, deflate, sdch"); 633 // when we get a response. When done, we'll record histograms via
619 if (dictionaries_advertised_) { 634 // SDCH_DECODE or SDCH_PASSTHROUGH. Hence we need to record packet
620 request_info_.extra_headers.SetHeader( 635 // arrival times.
621 kAvailDictionaryHeader, 636 packet_timing_enabled_ = true;
622 dictionaries_advertised_->GetDictionaryClientHashList());
623 // Since we're tagging this transaction as advertising a dictionary,
624 // we'll definitely employ an SDCH filter (or tentative sdch filter)
625 // when we get a response. When done, we'll record histograms via
626 // SDCH_DECODE or SDCH_PASSTHROUGH. Hence we need to record packet
627 // arrival times.
628 packet_timing_enabled_ = true;
629 }
630 } 637 }
631 } 638 }
632 639
633 if (http_user_agent_settings_) { 640 if (http_user_agent_settings_) {
634 // Only add default Accept-Language if the request didn't have it 641 // Only add default Accept-Language if the request didn't have it
635 // specified. 642 // specified.
636 std::string accept_language = 643 std::string accept_language =
637 http_user_agent_settings_->GetAcceptLanguage(); 644 http_user_agent_settings_->GetAcceptLanguage();
638 if (!accept_language.empty()) { 645 if (!accept_language.empty()) {
639 request_info_.extra_headers.SetHeaderIfMissing( 646 request_info_.extra_headers.SetHeaderIfMissing(
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after
1603 return override_response_headers_.get() ? 1610 return override_response_headers_.get() ?
1604 override_response_headers_.get() : 1611 override_response_headers_.get() :
1605 transaction_->GetResponseInfo()->headers.get(); 1612 transaction_->GetResponseInfo()->headers.get();
1606 } 1613 }
1607 1614
1608 void URLRequestHttpJob::NotifyURLRequestDestroyed() { 1615 void URLRequestHttpJob::NotifyURLRequestDestroyed() {
1609 awaiting_callback_ = false; 1616 awaiting_callback_ = false;
1610 } 1617 }
1611 1618
1612 } // namespace net 1619 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698