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

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: Fixed nits Created 5 years 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 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
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)
599 advertise_brotli = request()->url().SchemeIsCryptographic();
600
594 // Supply Accept-Encoding headers first so that it is more likely that they 601 // 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 602 // 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 603 // easier to filter and analyze the streams to assure that a proxy has not
597 // damaged these headers. Some proxies deliberately corrupt Accept-Encoding 604 // damaged these headers. Some proxies deliberately corrupt Accept-Encoding
598 // headers. 605 // headers.
599 if (!advertise_sdch) { 606 std::string advertised_encodings = "gzip, deflate";
600 // Tell the server what compression formats we support (other than SDCH). 607 if (advertise_sdch)
608 advertised_encodings += ", sdch";
609 if (advertise_brotli)
610 advertised_encodings += ", br";
611 // Tell the server what compression formats are supported.
612 request_info_.extra_headers.SetHeader(HttpRequestHeaders::kAcceptEncoding,
613 advertised_encodings);
614
615 if (dictionaries_advertised_) {
601 request_info_.extra_headers.SetHeader( 616 request_info_.extra_headers.SetHeader(
602 HttpRequestHeaders::kAcceptEncoding, "gzip, deflate"); 617 kAvailDictionaryHeader,
603 } else { 618 dictionaries_advertised_->GetDictionaryClientHashList());
604 // Include SDCH in acceptable list. 619 // Since we're tagging this transaction as advertising a dictionary,
605 request_info_.extra_headers.SetHeader( 620 // we'll definitely employ an SDCH filter (or tentative sdch filter)
606 HttpRequestHeaders::kAcceptEncoding, "gzip, deflate, sdch"); 621 // when we get a response. When done, we'll record histograms via
607 if (dictionaries_advertised_) { 622 // SDCH_DECODE or SDCH_PASSTHROUGH. Hence we need to record packet
608 request_info_.extra_headers.SetHeader( 623 // arrival times.
609 kAvailDictionaryHeader, 624 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 } 625 }
619 } 626 }
620 627
621 if (http_user_agent_settings_) { 628 if (http_user_agent_settings_) {
622 // Only add default Accept-Language if the request didn't have it 629 // Only add default Accept-Language if the request didn't have it
623 // specified. 630 // specified.
624 std::string accept_language = 631 std::string accept_language =
625 http_user_agent_settings_->GetAcceptLanguage(); 632 http_user_agent_settings_->GetAcceptLanguage();
626 if (!accept_language.empty()) { 633 if (!accept_language.empty()) {
627 request_info_.extra_headers.SetHeaderIfMissing( 634 request_info_.extra_headers.SetHeaderIfMissing(
(...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after
1578 return override_response_headers_.get() ? 1585 return override_response_headers_.get() ?
1579 override_response_headers_.get() : 1586 override_response_headers_.get() :
1580 transaction_->GetResponseInfo()->headers.get(); 1587 transaction_->GetResponseInfo()->headers.get();
1581 } 1588 }
1582 1589
1583 void URLRequestHttpJob::NotifyURLRequestDestroyed() { 1590 void URLRequestHttpJob::NotifyURLRequestDestroyed() {
1584 awaiting_callback_ = false; 1591 awaiting_callback_ = false;
1585 } 1592 }
1586 1593
1587 } // namespace net 1594 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698