diff options
author | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-04 19:03:23 +0000 |
---|---|---|
committer | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-04 19:03:23 +0000 |
commit | 46668fe5074488da6400b579de2475728188cb45 (patch) | |
tree | 6d35f15b05767d44c41f6ca01efcafacbb0b303f /net | |
parent | 62850bd01281f60c6139d74373abc74222ea8eeb (diff) | |
download | chromium_src-46668fe5074488da6400b579de2475728188cb45.zip chromium_src-46668fe5074488da6400b579de2475728188cb45.tar.gz chromium_src-46668fe5074488da6400b579de2475728188cb45.tar.bz2 |
Allow server to indicate a non-SDCH encoding
When a server decides to not SDCH encode content
despite having an applicable dictionary, it can
send a header:
X-Sdch-Encode: 0
to tell the browser the lack of encoding was not
caused by a transit corruption (bad proxy?).
r=kmixter
bug=78489
Review URL: http://codereview.chromium.org/6909033
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@84102 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/url_request/url_request_http_job.cc | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc index b7f8d4c..cfb6ffc 100644 --- a/net/url_request/url_request_http_job.cc +++ b/net/url_request/url_request_http_job.cc @@ -106,6 +106,10 @@ class URLRequestHttpJob::HttpFilterContext : public FilterContext { virtual int GetResponseCode() const; virtual void RecordPacketStats(StatisticSelector statistic) const; + // Method to allow us to reset filter context for a response that should have + // been SDCH encoded when there is an update due to an explicit HTTP header. + void ResetSdchResponseToFalse(); + private: URLRequestHttpJob* job_; @@ -144,6 +148,11 @@ bool URLRequestHttpJob::HttpFilterContext::IsDownload() const { return (job_->request_info_.load_flags & LOAD_IS_DOWNLOAD) != 0; } +void URLRequestHttpJob::HttpFilterContext::ResetSdchResponseToFalse() { + DCHECK(job_->sdch_dictionary_advertised_); + job_->sdch_dictionary_advertised_ = false; +} + bool URLRequestHttpJob::HttpFilterContext::IsSdchResponse() const { return job_->sdch_dictionary_advertised_; } @@ -387,7 +396,7 @@ void URLRequestHttpJob::AddExtraHeaders() { avail_dictionaries); sdch_dictionary_advertised_ = true; // Since we're tagging this transaction as advertising a dictionary, we'll - // definately employ an SDCH filter (or tentative sdch filter) when we get + // 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; @@ -866,6 +875,23 @@ Filter* URLRequestHttpJob::SetupFilter() const { encoding_types.push_back(Filter::ConvertEncodingToType(encoding_type)); } + if (filter_context_->IsSdchResponse()) { + // We are wary of proxies that discard or damage SDCH encoding. If a server + // explicitly states that this is not SDCH content, then we can correct our + // assumption that this is an SDCH response, and avoid the need to recover + // as though the content is corrupted (when we discover it is not SDCH + // encoded). + std::string sdch_response_status; + iter = NULL; + while (response_info_->headers->EnumerateHeader(&iter, "X-Sdch-Encode", + &sdch_response_status)) { + if (sdch_response_status == "0") { + filter_context_->ResetSdchResponseToFalse(); + break; + } + } + } + // Even if encoding types are empty, there is a chance that we need to add // some decoding, as some proxies strip encoding completely. In such cases, // we may need to add (for example) SDCH filtering (when the context suggests |