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

Unified Diff: chrome/browser/renderer_host/buffered_resource_handler.cc

Issue 274075: Sniff 204 responses as text/plain to avoid creating unwanted downloads.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 2 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 | « no previous file | chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/renderer_host/buffered_resource_handler.cc
===================================================================
--- chrome/browser/renderer_host/buffered_resource_handler.cc (revision 29247)
+++ chrome/browser/renderer_host/buffered_resource_handler.cc (working copy)
@@ -154,12 +154,11 @@
const bool sniffing_blocked =
LowerCaseEqualsASCII(content_type_options, "nosniff");
- const bool no_data =
- response_->response_head.headers && // Can be NULL if FTP.
- (response_->response_head.headers->response_code() == 304 ||
- response_->response_head.headers->response_code() == 204);
- const bool we_would_like_to_sniff =
- no_data ? false : net::ShouldSniffMimeType(request_->url(), mime_type);
+ const bool not_modified_status =
+ response_->response_head.headers &&
+ response_->response_head.headers->response_code() == 304;
+ const bool we_would_like_to_sniff = not_modified_status ?
+ false : net::ShouldSniffMimeType(request_->url(), mime_type);
RecordSnifferMetrics(sniffing_blocked, we_would_like_to_sniff, mime_type);
@@ -172,7 +171,7 @@
return true;
}
- if (sniffing_blocked && mime_type.empty() && !no_data) {
+ if (sniffing_blocked && mime_type.empty() && !not_modified_status) {
// Ugg. The server told us not to sniff the content but didn't give us a
// mime type. What's a browser to do? Turns out, we're supposed to treat
// the response as "text/plain". This is the most secure option.
@@ -202,7 +201,7 @@
return true;
}
- if (!no_data && ShouldWaitForPlugins()) {
+ if (!not_modified_status && ShouldWaitForPlugins()) {
wait_for_plugins_ = true;
return true;
}
« no previous file with comments | « no previous file | chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698