summaryrefslogtreecommitdiffstats
path: root/net/url_request/url_request_file_job.cc
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-25 22:04:37 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-25 22:04:37 +0000
commit7e2639413fc87b91d1327a57303493d84823f070 (patch)
tree2c8f494e45fbd787ca2c1efbbbbee72826afd045 /net/url_request/url_request_file_job.cc
parent7fe2c0b8630fabd9919dc61757392ea2aac9d72b (diff)
downloadchromium_src-7e2639413fc87b91d1327a57303493d84823f070.zip
chromium_src-7e2639413fc87b91d1327a57303493d84823f070.tar.gz
chromium_src-7e2639413fc87b91d1327a57303493d84823f070.tar.bz2
Append a trailing slash on file directory URLs. Thus a link to /directory will work just as well as a link to /directory/
Review URL: http://codereview.chromium.org/12620 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5999 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/url_request/url_request_file_job.cc')
-rw-r--r--net/url_request/url_request_file_job.cc26
1 files changed, 5 insertions, 21 deletions
diff --git a/net/url_request/url_request_file_job.cc b/net/url_request/url_request_file_job.cc
index 3c37468..d0841e5 100644
--- a/net/url_request/url_request_file_job.cc
+++ b/net/url_request/url_request_file_job.cc
@@ -72,12 +72,9 @@ class URLRequestFileJob::AsyncResolver :
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 @@ void URLRequestFileJob::DidResolve(
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 @@ void URLRequestFileJob::DidRead(int result) {
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());