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

Unified Diff: content/browser/net/url_request_insecure_interceptor.cc

Issue 2445993006: [WIP] Upgrade-insecure-request: upgrade insecurely-redirected requests.
Patch Set: bugfix Created 4 years, 2 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
Index: content/browser/net/url_request_insecure_interceptor.cc
diff --git a/content/browser/net/url_request_insecure_interceptor.cc b/content/browser/net/url_request_insecure_interceptor.cc
new file mode 100644
index 0000000000000000000000000000000000000000..854a54b25dea111b19a5402e35d9e1a5fca49155
--- /dev/null
+++ b/content/browser/net/url_request_insecure_interceptor.cc
@@ -0,0 +1,50 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/loader/resource_request_info_impl.h"
+#include "content/browser/net/url_request_insecure_interceptor.h"
+#include "net/url_request/url_request_redirect_job.h"
+
+namespace content {
+
+URLRequestInsecureInterceptor::URLRequestInsecureInterceptor() {}
+URLRequestInsecureInterceptor::~URLRequestInsecureInterceptor() {}
+
+net::URLRequestJob* URLRequestInsecureInterceptor::MaybeInterceptRequest(
+ net::URLRequest* request,
+ net::NetworkDelegate* network_delegate) const {
+ return nullptr;
+}
+
+net::URLRequestJob* URLRequestInsecureInterceptor::MaybeInterceptResponse(
+ net::URLRequest* request,
+ net::NetworkDelegate* network_delegate) const {
+ return nullptr;
+}
+
+net::URLRequestJob* URLRequestInsecureInterceptor::MaybeInterceptRedirect(
+ net::URLRequest* request,
+ net::NetworkDelegate* network_delegate,
+ const GURL& location) const {
+ const content::ResourceRequestInfoImpl* info =
+ content::ResourceRequestInfoImpl::ForRequest(request);
+
+ if (!info ||
+ !(info->insecure_request_policy() & blink::kUpgradeInsecureRequests) ||
+ !location.SchemeIs("http"))
+ return nullptr;
+
+ // Upgrade insecure request.
+ GURL::Replacements replacement;
+ replacement.SetSchemeStr("https");
+ if (location.port() == "80")
+ replacement.SetPortStr("443");
+
+ return new net::URLRequestRedirectJob(
+ request, network_delegate, location.ReplaceComponents(replacement),
+ net::URLRequestRedirectJob::REDIRECT_307_TEMPORARY_REDIRECT,
+ "upgrade insecurely redirected request");
+}
+
+} // namespace content
« no previous file with comments | « content/browser/net/url_request_insecure_interceptor.h ('k') | content/browser/storage_partition_impl_map.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698