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

Unified Diff: net/test/url_request/url_request_mock_http_job.cc

Issue 895853003: Update from https://crrev.com/314320 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 11 months 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/test/url_request/url_request_mock_http_job.h ('k') | net/tools/testserver/testserver.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/test/url_request/url_request_mock_http_job.cc
diff --git a/net/test/url_request/url_request_mock_http_job.cc b/net/test/url_request/url_request_mock_http_job.cc
index 1c6e35cba1d9a703bd4820f8e68649cb855ab42f..9e63c25b3e2dabf2836ceb8c815eaced55045b55 100644
--- a/net/test/url_request/url_request_mock_http_job.cc
+++ b/net/test/url_request/url_request_mock_http_job.cc
@@ -96,16 +96,29 @@ std::string DoFileIO(const base::FilePath& file_path) {
return raw_headers;
}
+// For a given file |path| and |scheme|, return the URL served by the
+// URlRequestMockHTTPJob.
+GURL GetMockUrlForScheme(const base::FilePath& path,
+ const std::string& scheme) {
+ std::string url = scheme + "://" + kMockHostname + "/";
+ std::string path_str = path.MaybeAsASCII();
+ DCHECK(!path_str.empty()); // We only expect ASCII paths in tests.
+ url.append(path_str);
+ return GURL(url);
+}
+
} // namespace
// static
-void URLRequestMockHTTPJob::AddUrlHandler(
+void URLRequestMockHTTPJob::AddUrlHandlers(
const base::FilePath& base_path,
const scoped_refptr<base::SequencedWorkerPool>& worker_pool) {
- // Add kMockHostname to net::URLRequestFilter.
+ // Add kMockHostname to net::URLRequestFilter, for both HTTP and HTTPS.
net::URLRequestFilter* filter = net::URLRequestFilter::GetInstance();
filter->AddHostnameInterceptor(
"http", kMockHostname, CreateInterceptor(base_path, worker_pool));
+ filter->AddHostnameInterceptor("https", kMockHostname,
+ CreateInterceptor(base_path, worker_pool));
}
// static
@@ -120,13 +133,12 @@ void URLRequestMockHTTPJob::AddHostnameToFileHandler(
// static
GURL URLRequestMockHTTPJob::GetMockUrl(const base::FilePath& path) {
- std::string url = "http://";
- url.append(kMockHostname);
- url.append("/");
- std::string path_str = path.MaybeAsASCII();
- DCHECK(!path_str.empty()); // We only expect ASCII paths in tests.
- url.append(path_str);
- return GURL(url);
+ return GetMockUrlForScheme(path, "http");
+}
+
+// static
+GURL URLRequestMockHTTPJob::GetMockHttpsUrl(const base::FilePath& path) {
+ return GetMockUrlForScheme(path, "https");
}
// static
« no previous file with comments | « net/test/url_request/url_request_mock_http_job.h ('k') | net/tools/testserver/testserver.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698