diff options
author | abarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-28 14:50:24 +0000 |
---|---|---|
committer | abarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-28 14:50:24 +0000 |
commit | 28ca9fb49dbb272e04f9a096013d681e365674b2 (patch) | |
tree | f289dd97e5e75e0d5dc6bb19194ed942bf68af50 /content | |
parent | d203abfd7d30c9ccd68c8760f4a6f128b056ced8 (diff) | |
download | chromium_src-28ca9fb49dbb272e04f9a096013d681e365674b2.zip chromium_src-28ca9fb49dbb272e04f9a096013d681e365674b2.tar.gz chromium_src-28ca9fb49dbb272e04f9a096013d681e365674b2.tar.bz2 |
BufferedResourceHandler::ShouldDownload shouldn't manually parse Content-Disposition
Now that we have net::HttpContentDisposition to parse the Content-Disposition
header, BufferedResourceHandler::ShouldDownload shouldn't use its own ad-hoc
parser.
Review URL: http://codereview.chromium.org/9297039
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119611 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/renderer_host/buffered_resource_handler.cc | 33 |
1 files changed, 5 insertions, 28 deletions
diff --git a/content/browser/renderer_host/buffered_resource_handler.cc b/content/browser/renderer_host/buffered_resource_handler.cc index a5aa986..5f59bb7 100644 --- a/content/browser/renderer_host/buffered_resource_handler.cc +++ b/content/browser/renderer_host/buffered_resource_handler.cc @@ -26,6 +26,7 @@ #include "net/base/mime_sniffer.h" #include "net/base/mime_util.h" #include "net/base/net_errors.h" +#include "net/http/http_content_disposition.h" #include "net/http/http_response_headers.h" #include "webkit/plugins/webplugininfo.h" @@ -351,37 +352,13 @@ bool BufferedResourceHandler::ShouldDownload(bool* need_plugin_list) { if (need_plugin_list) *need_plugin_list = false; std::string type = StringToLowerASCII(response_->mime_type); + + // First, examine Content-Disposition. std::string disposition; request_->GetResponseHeaderByName("content-disposition", &disposition); - disposition = StringToLowerASCII(disposition); - - // First, examine content-disposition. if (!disposition.empty()) { - bool should_download = true; - - // Some broken sites just send ... - // Content-Disposition: ; filename="file" - // ... screen those out here. - if (disposition[0] == ';') - should_download = false; - - if (disposition.compare(0, 6, "inline") == 0) - should_download = false; - - // Some broken sites just send ... - // Content-Disposition: filename="file" - // ... without a disposition token... Screen those out. - if (disposition.compare(0, 8, "filename") == 0) - should_download = false; - - // Also in use is Content-Disposition: name="file" - if (disposition.compare(0, 4, "name") == 0) - should_download = false; - - // We have a content-disposition of "attachment" or unknown. - // RFC 2183, section 2.8 says that an unknown disposition - // value should be treated as "attachment". - if (should_download) + net::HttpContentDisposition parsed_disposition(disposition, std::string()); + if (parsed_disposition.is_attachment()) return true; } |