Chromium Code Reviews| Index: net/url_request/url_request_http_job.cc |
| diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc |
| index 5c4ddd11c499c3cd997133376c8e5407bab861cb..97e6e11fc21a39ae747b9c4829cebe9569f0f023 100644 |
| --- a/net/url_request/url_request_http_job.cc |
| +++ b/net/url_request/url_request_http_job.cc |
| @@ -591,30 +591,38 @@ void URLRequestHttpJob::AddExtraHeaders() { |
| } |
| } |
| + // Advertise "br" encoding only if transferred data is opaque to proxy. |
| + bool advertise_brotli = false; |
| + const HttpNetworkSession::Params* network_session_params = |
| + request()->context()->GetNetworkSessionParams(); |
| + 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.
|
| + 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
|
| + } |
| + |
| // Supply Accept-Encoding headers first so that it is more likely that they |
| // will be in the first transmitted packet. This can sometimes make it |
| // easier to filter and analyze the streams to assure that a proxy has not |
| // damaged these headers. Some proxies deliberately corrupt Accept-Encoding |
| // headers. |
| - if (!advertise_sdch) { |
| - // Tell the server what compression formats we support (other than SDCH). |
| - request_info_.extra_headers.SetHeader( |
| - HttpRequestHeaders::kAcceptEncoding, "gzip, deflate"); |
| - } else { |
| - // Include SDCH in acceptable list. |
| + std::string advertised_encodings = "gzip, deflate"; |
| + if (advertise_sdch) |
| + advertised_encodings += ", sdch"; |
| + if (advertise_brotli) |
| + advertised_encodings += ", br"; |
| + // 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.
|
| + request_info_.extra_headers.SetHeader(HttpRequestHeaders::kAcceptEncoding, |
| + advertised_encodings); |
| + |
| + if (dictionaries_advertised_) { |
| request_info_.extra_headers.SetHeader( |
| - HttpRequestHeaders::kAcceptEncoding, "gzip, deflate, sdch"); |
| - if (dictionaries_advertised_) { |
| - request_info_.extra_headers.SetHeader( |
| - kAvailDictionaryHeader, |
| - dictionaries_advertised_->GetDictionaryClientHashList()); |
| - // Since we're tagging this transaction as advertising a dictionary, |
| - // we'll definitely employ an SDCH filter (or tentative sdch filter) |
| - // when we get a response. When done, we'll record histograms via |
| - // SDCH_DECODE or SDCH_PASSTHROUGH. Hence we need to record packet |
| - // arrival times. |
| - packet_timing_enabled_ = true; |
| - } |
| + kAvailDictionaryHeader, |
| + dictionaries_advertised_->GetDictionaryClientHashList()); |
| + // Since we're tagging this transaction as advertising a dictionary, |
| + // we'll definitely employ an SDCH filter (or tentative sdch filter) |
| + // when we get a response. When done, we'll record histograms via |
| + // SDCH_DECODE or SDCH_PASSTHROUGH. Hence we need to record packet |
| + // arrival times. |
| + packet_timing_enabled_ = true; |
| } |
| } |