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

Unified Diff: net/url_request/url_request_file_dir_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
« no previous file with comments | « net/url_request/url_request_file_dir_job.h ('k') | net/url_request/url_request_file_job.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request_file_dir_job.cc
===================================================================
--- net/url_request/url_request_file_dir_job.cc (revision 5946)
+++ net/url_request/url_request_file_dir_job.cc (working copy)
@@ -199,3 +199,24 @@
}
}
+bool URLRequestFileDirJob::IsRedirectResponse(
+ GURL* location, int* http_status_code) {
+ // If the URL did not have a trailing slash, treat the response as a redirect
+ // to the URL with a trailing slash appended.
+ std::string path = request_->url().path();
+ if (path[path.size() - 1] != '/') {
tony 2008/11/25 21:42:52 Does path always return at least '/' or do you nee
+ // This happens when we discovered the file is a directory, so needs a
+ // slash at the end of the path.
+ std::string new_path = 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;
+ }
+
+ return false;
+}
+
« no previous file with comments | « net/url_request/url_request_file_dir_job.h ('k') | net/url_request/url_request_file_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698