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

Unified Diff: net/url_request/url_request_file_job.cc

Issue 12620: Append a trailing slash on file directory URLs. Thus a link to /directory wil... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 1 month 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
Index: net/url_request/url_request_file_job.cc
===================================================================
--- net/url_request/url_request_file_job.cc (revision 5946)
+++ net/url_request/url_request_file_job.cc (working copy)
@@ -72,12 +72,9 @@
URLRequestJob* URLRequestFileJob::Factory(
URLRequest* request, const std::string& scheme) {
FilePath file_path;
- if (net::FileURLToFilePath(request->url(), &file_path)) {
- if (file_util::DirectoryExists(file_path)) {
- // Only directories have trailing slashes.
+ if (net::FileURLToFilePath(request->url(), &file_path) &&
+ file_util::EnsureEndsWithSeparator(&file_path))
return new URLRequestFileDirJob(request, file_path);
- }
- }
// Use a regular file request job for all non-directories (including invalid
// file names).
@@ -167,13 +164,13 @@
if (!request_)
return;
- is_directory_ = file_info.is_directory;
+ DCHECK(!file_info.is_directory);
int rv = net::OK;
if (!exists) {
rv = net::ERR_FILE_NOT_FOUND;
- } else if (!is_directory_) {
- int flags = base::PLATFORM_FILE_OPEN |
+ } else {
+ int flags = base::PLATFORM_FILE_OPEN |
base::PLATFORM_FILE_READ |
base::PLATFORM_FILE_ASYNC;
rv = stream_.Open(file_path_.ToWStringHack(), flags);
@@ -200,19 +197,6 @@
bool URLRequestFileJob::IsRedirectResponse(
GURL* location, int* http_status_code) {
- if (is_directory_) {
- // This happens when we discovered the file is a directory, so needs a
- // slash at the end of the path.
- std::string new_path = request_->url().path();
- new_path.push_back('/');
- GURL::Replacements replacements;
- replacements.SetPathStr(new_path);
-
- *location = request_->url().ReplaceComponents(replacements);
- *http_status_code = 301; // simulate a permanent redirect
- return true;
- }
-
#if defined(OS_WIN)
std::wstring extension =
file_util::GetFileExtensionFromPath(file_path_.value());

Powered by Google App Engine
This is Rietveld 408576698