Chromium Code Reviews| Index: net/url_request/url_request_http_job.cc |
| =================================================================== |
| --- net/url_request/url_request_http_job.cc (revision 83675) |
| +++ net/url_request/url_request_http_job.cc (working copy) |
| @@ -106,6 +106,10 @@ |
| virtual int GetResponseCode() const; |
| virtual void RecordPacketStats(StatisticSelector statistic) const; |
| + // Method to allow us to reset context to false when there is an update due |
| + // to an explicit HTTP header. |
|
wtc
2011/05/04 18:27:00
Nit: this comment doesn't even mention SDCH.
jar (doing other things)
2011/05/04 18:31:51
Done.
|
| + void SetSdchResponse(bool active); |
| + |
| private: |
| URLRequestHttpJob* job_; |
| @@ -144,6 +148,14 @@ |
| return (job_->request_info_.load_flags & LOAD_IS_DOWNLOAD) != 0; |
| } |
| +void URLRequestHttpJob::HttpFilterContext::SetSdchResponse(bool active) { |
| + // Currently only for use to reset the context to false, after seeing an |
| + // explicit HTTP header. |
| + DCHECK(job_->sdch_dictionary_advertised_); |
| + DCHECK(!active); |
|
wtc
2011/05/04 18:27:00
It's strange to assert that a function argument ca
jar (doing other things)
2011/05/04 18:31:51
Done.
|
| + job_->sdch_dictionary_advertised_ = active; |
| +} |
| + |
| bool URLRequestHttpJob::HttpFilterContext::IsSdchResponse() const { |
| return job_->sdch_dictionary_advertised_; |
| } |
| @@ -387,7 +399,7 @@ |
| 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 +878,23 @@ |
| 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_->SetSdchResponse(false); |
| + 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 |