diff options
author | abarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-16 23:33:57 +0000 |
---|---|---|
committer | abarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-16 23:33:57 +0000 |
commit | e19d7133ce2bcb816fbd6e707622cc43a5735c1d (patch) | |
tree | cf72ba0113d3063583225bc6819b3112a3f2e4f0 /chrome/browser/renderer_host/buffered_resource_handler.cc | |
parent | 4772c9574cdd4ef513b5fb5994212a6187bc0b12 (diff) | |
download | chromium_src-e19d7133ce2bcb816fbd6e707622cc43a5735c1d.zip chromium_src-e19d7133ce2bcb816fbd6e707622cc43a5735c1d.tar.gz chromium_src-e19d7133ce2bcb816fbd6e707622cc43a5735c1d.tar.bz2 |
Sniff 204 responses as text/plain to avoid creating unwanted downloads.
BUG=24391
TEST=ResourceDispatcherHostTest.MimeSniff204
Review URL: http://codereview.chromium.org/274075
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29355 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host/buffered_resource_handler.cc')
-rw-r--r-- | chrome/browser/renderer_host/buffered_resource_handler.cc | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/chrome/browser/renderer_host/buffered_resource_handler.cc b/chrome/browser/renderer_host/buffered_resource_handler.cc index ad31e8d..347bf69 100644 --- a/chrome/browser/renderer_host/buffered_resource_handler.cc +++ b/chrome/browser/renderer_host/buffered_resource_handler.cc @@ -154,12 +154,11 @@ bool BufferedResourceHandler::DelayResponse() { 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 @@ bool BufferedResourceHandler::DelayResponse() { 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 @@ bool BufferedResourceHandler::DelayResponse() { return true; } - if (!no_data && ShouldWaitForPlugins()) { + if (!not_modified_status && ShouldWaitForPlugins()) { wait_for_plugins_ = true; return true; } |