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

Side by Side 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, 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/browser/loader/resource_request_info_impl.h"
6 #include "content/browser/net/url_request_insecure_interceptor.h"
7 #include "net/url_request/url_request_redirect_job.h"
8
9 namespace content {
10
11 URLRequestInsecureInterceptor::URLRequestInsecureInterceptor() {}
12 URLRequestInsecureInterceptor::~URLRequestInsecureInterceptor() {}
13
14 net::URLRequestJob* URLRequestInsecureInterceptor::MaybeInterceptRequest(
15 net::URLRequest* request,
16 net::NetworkDelegate* network_delegate) const {
17 return nullptr;
18 }
19
20 net::URLRequestJob* URLRequestInsecureInterceptor::MaybeInterceptResponse(
21 net::URLRequest* request,
22 net::NetworkDelegate* network_delegate) const {
23 return nullptr;
24 }
25
26 net::URLRequestJob* URLRequestInsecureInterceptor::MaybeInterceptRedirect(
27 net::URLRequest* request,
28 net::NetworkDelegate* network_delegate,
29 const GURL& location) const {
30 const content::ResourceRequestInfoImpl* info =
31 content::ResourceRequestInfoImpl::ForRequest(request);
32
33 if (!info ||
34 !(info->insecure_request_policy() & blink::kUpgradeInsecureRequests) ||
35 !location.SchemeIs("http"))
36 return nullptr;
37
38 // Upgrade insecure request.
39 GURL::Replacements replacement;
40 replacement.SetSchemeStr("https");
41 if (location.port() == "80")
42 replacement.SetPortStr("443");
43
44 return new net::URLRequestRedirectJob(
45 request, network_delegate, location.ReplaceComponents(replacement),
46 net::URLRequestRedirectJob::REDIRECT_307_TEMPORARY_REDIRECT,
47 "upgrade insecurely redirected request");
48 }
49
50 } // namespace content
OLDNEW
« 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