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

Side by Side Diff: net/base/sdch_filter.cc

Issue 518016: Avoid meta-refresh when back-button gets non-sdch content... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | net/base/sdch_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <limits.h> 5 #include <limits.h>
6 #include <ctype.h> 6 #include <ctype.h>
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/histogram.h" 10 #include "base/histogram.h"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 DCHECK(dest_buffer_excess_.empty()); 153 DCHECK(dest_buffer_excess_.empty());
154 // This is where we try very hard to do error recovery, and make this 154 // This is where we try very hard to do error recovery, and make this
155 // protocol robust in the face of proxies that do many different things. 155 // protocol robust in the face of proxies that do many different things.
156 // If we decide that things are looking very bad (too hard to recover), 156 // If we decide that things are looking very bad (too hard to recover),
157 // we may even issue a "meta-refresh" to reload the page without an SDCH 157 // we may even issue a "meta-refresh" to reload the page without an SDCH
158 // advertisement (so that we are sure we're not hurting anything). 158 // advertisement (so that we are sure we're not hurting anything).
159 // 159 //
160 // Watch out for an error page inserted by the proxy as part of a 40x 160 // Watch out for an error page inserted by the proxy as part of a 40x
161 // error response. When we see such content molestation, we certainly 161 // error response. When we see such content molestation, we certainly
162 // need to fall into the meta-refresh case. 162 // need to fall into the meta-refresh case.
163 bool successful_response = filter_context().GetResponseCode() == 200;
164 if (filter_context().GetResponseCode() == 404) { 163 if (filter_context().GetResponseCode() == 404) {
165 // We could be more generous, but for now, only a "NOT FOUND" code will 164 // We could be more generous, but for now, only a "NOT FOUND" code will
166 // cause a pass through. All other codes will fall into a meta-refresh 165 // cause a pass through. All other bad codes will fall into a
167 // attempt. 166 // meta-refresh.
168 SdchManager::SdchErrorRecovery(SdchManager::PASS_THROUGH_404_CODE); 167 SdchManager::SdchErrorRecovery(SdchManager::PASS_THROUGH_404_CODE);
169 decoding_status_ = PASS_THROUGH; 168 decoding_status_ = PASS_THROUGH;
170 } else if (possible_pass_through_ && successful_response) { 169 } else if (filter_context().GetResponseCode() != 200) {
170 // We need to meta-refresh, with SDCH disabled.
171 } else if (filter_context().IsCachedContent()
172 && !dictionary_hash_is_plausible_) {
173 // We must have hit the back button, and gotten content that was fetched
174 // before we *really* advertised SDCH and a dictionary.
175 SdchManager::SdchErrorRecovery(SdchManager::PASS_THROUGH_OLD_CACHED);
176 decoding_status_ = PASS_THROUGH;
177 } else if (possible_pass_through_) {
171 // This is the potentially most graceful response. There really was no 178 // This is the potentially most graceful response. There really was no
172 // error. We were just overly cautious when we added a TENTATIVE_SDCH. 179 // error. We were just overly cautious when we added a TENTATIVE_SDCH.
173 // We added the sdch coding tag, and it should not have been added. 180 // We added the sdch coding tag, and it should not have been added.
174 // This can happen in server experiments, where the server decides 181 // This can happen in server experiments, where the server decides
175 // not to use sdch, even though there is a dictionary. To be 182 // not to use sdch, even though there is a dictionary. To be
176 // conservative, we locally added the tentative sdch (fearing that a 183 // conservative, we locally added the tentative sdch (fearing that a
177 // proxy stripped it!) and we must now recant (pass through). 184 // proxy stripped it!) and we must now recant (pass through).
178 SdchManager::SdchErrorRecovery(SdchManager::DISCARD_TENTATIVE_SDCH); 185 SdchManager::SdchErrorRecovery(SdchManager::DISCARD_TENTATIVE_SDCH);
179 // However.... just to be sure we don't get burned by proxies that 186 // However.... just to be sure we don't get burned by proxies that
180 // re-compress with gzip or other system, we can sniff to see if this 187 // re-compress with gzip or other system, we can sniff to see if this
181 // is compressed data etc. For now, we do nothing, which gets us into 188 // is compressed data etc. For now, we do nothing, which gets us into
182 // the meta-refresh result. 189 // the meta-refresh result.
183 // TODO(jar): Improve robustness by sniffing for valid text that we can 190 // TODO(jar): Improve robustness by sniffing for valid text that we can
184 // actual use re: decoding_status_ = PASS_THROUGH; 191 // actual use re: decoding_status_ = PASS_THROUGH;
185 } else if (successful_response && !dictionary_hash_is_plausible_) { 192 } else if (!dictionary_hash_is_plausible_) {
186 // One of the first 9 bytes precluded consideration as a hash. 193 // One of the first 9 bytes precluded consideration as a hash.
187 // This can't be an SDCH payload, even though the server said it was. 194 // This can't be an SDCH payload, even though the server said it was.
188 // This is a major error, as the server or proxy tagged this SDCH even 195 // This is a major error, as the server or proxy tagged this SDCH even
189 // though it is not! 196 // though it is not!
190 SdchManager::SdchErrorRecovery(SdchManager::PASSING_THROUGH_NON_SDCH); 197 SdchManager::SdchErrorRecovery(SdchManager::PASSING_THROUGH_NON_SDCH);
191 // Meta-refresh won't help... we didn't advertise an SDCH dictionary!! 198 // Meta-refresh won't help... we didn't advertise an SDCH dictionary!!
192 decoding_status_ = PASS_THROUGH; 199 decoding_status_ = PASS_THROUGH;
193 } 200 }
194 201
195 if (decoding_status_ == PASS_THROUGH) { 202 if (decoding_status_ == PASS_THROUGH) {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 memcpy(dest_buffer, dest_buffer_excess_.data() + dest_buffer_excess_index_, 361 memcpy(dest_buffer, dest_buffer_excess_.data() + dest_buffer_excess_index_,
355 amount); 362 amount);
356 dest_buffer_excess_index_ += amount; 363 dest_buffer_excess_index_ += amount;
357 if (dest_buffer_excess_.size() <= dest_buffer_excess_index_) { 364 if (dest_buffer_excess_.size() <= dest_buffer_excess_index_) {
358 DCHECK(dest_buffer_excess_.size() == dest_buffer_excess_index_); 365 DCHECK(dest_buffer_excess_.size() == dest_buffer_excess_index_);
359 dest_buffer_excess_.clear(); 366 dest_buffer_excess_.clear();
360 dest_buffer_excess_index_ = 0; 367 dest_buffer_excess_index_ = 0;
361 } 368 }
362 return amount; 369 return amount;
363 } 370 }
OLDNEW
« no previous file with comments | « no previous file | net/base/sdch_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698