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

Unified Diff: net/base/sdch_filter.cc

Issue 56043: Use HTTP status return code to make SDCH handling more robust... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/gzip_filter_unittest.cc ('k') | net/base/sdch_filter_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/sdch_filter.cc
===================================================================
--- net/base/sdch_filter.cc (revision 12762)
+++ net/base/sdch_filter.cc (working copy)
@@ -227,7 +227,21 @@
DCHECK(DECODING_ERROR == decoding_status_);
DCHECK(0 == dest_buffer_excess_index_);
DCHECK(dest_buffer_excess_.empty());
- if (possible_pass_through_) {
+ // This is where we try very hard to do error recovery, and make this
+ // protocol robust in teh face of proxies that do many different things.
+ // If we decide that things are looking very bad (too hard to recover),
+ // we may even issue a "meta-refresh" to reload the page without an SDCH
+ // advertisement (so that we are sure we're not hurting anything). First
+ // we try for some light weight recovery, and teh final else clause below
+ // supports the last ditch meta-refresh approach.
+ //
+ // Watch out for an error page inserted by the proxy as part of a 40x
+ // error response. When we see such content molestation, we certainly
+ // need to fall into the meta-refresh case.
+ bool successful_response = filter_context().GetResponseCode() == 200;
+ if (possible_pass_through_ && successful_response) {
+ // This is the most graceful response. There really was no error. We
+ // were just overly cautious.
// We added the sdch coding tag, and it should not have been added.
// This can happen in server experiments, where the server decides
// not to use sdch, even though there is a dictionary. To be
@@ -236,7 +250,7 @@
SdchManager::SdchErrorRecovery(SdchManager::DISCARD_TENTATIVE_SDCH);
decoding_status_ = PASS_THROUGH;
dest_buffer_excess_ = dictionary_hash_; // Send what we scanned.
- } else if (!dictionary_hash_is_plausible_) {
+ } else if (successful_response && !dictionary_hash_is_plausible_) {
// One of the first 9 bytes precluded consideration as a hash.
// This can't be an SDCH payload, even though the server said it was.
// This is a major error, as the server or proxy tagged this SDCH even
@@ -246,11 +260,16 @@
decoding_status_ = PASS_THROUGH;
dest_buffer_excess_ = dictionary_hash_; // Send what we scanned.
} else {
- // We don't have the dictionary that was demanded.
+ // This is where we try to do the expensive meta-refresh.
+ // Either this was an error response (probably an error page inserted
+ // by a proxy, as in bug 8916) or else we don't have the dictionary that
+ // was demanded.
// With very low probability, random garbage data looked like a
// dictionary specifier (8 ASCII characters followed by a null), but
// that is sufficiently unlikely that we ignore it.
- if (std::string::npos == mime_type_.find_first_of("text/html")) {
+ if (std::string::npos == mime_type_.find("text/html")) {
+ // Since we can't do a meta-refresh (along with an exponential
+ // backoff), we'll just make sure this NEVER happens again.
SdchManager::BlacklistDomainForever(url_);
if (was_cached_)
SdchManager::SdchErrorRecovery(
« no previous file with comments | « net/base/gzip_filter_unittest.cc ('k') | net/base/sdch_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698