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

Unified Diff: net/base/host_mapping_rules.cc

Issue 3177026: Add a feature to the HostResolverRules to be able to match rules only... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 4 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 | « no previous file | net/base/host_mapping_rules_unittest.cc » ('j') | net/base/host_mapping_rules_unittest.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/host_mapping_rules.cc
===================================================================
--- net/base/host_mapping_rules.cc (revision 56811)
+++ net/base/host_mapping_rules.cc (working copy)
@@ -28,8 +28,18 @@
it != map_rules_.end(); ++it) {
const MapRule& rule = *it;
- if (!MatchPatternASCII(host_port->host(), rule.hostname_pattern))
- continue; // This rule doesn't apply.
+ // The rule's hostname_pattern will be something like:
+ // www.foo.com
+ // *.foo.com
+ // www.foo.com:1234
+ // *.foo.com:1234
+ // First, we'll check for a match just on hostname.
+ // If that fails, we'll check for a match with both hostname and port.
+ if (!MatchPatternASCII(host_port->host(), rule.hostname_pattern)) {
+ std::string host_port_string = host_port->ToString();
+ if (!MatchPatternASCII(host_port_string, rule.hostname_pattern))
+ continue; // This rule doesn't apply.
+ }
host_port->set_host(rule.replacement_hostname);
if (rule.replacement_port != -1)
« no previous file with comments | « no previous file | net/base/host_mapping_rules_unittest.cc » ('j') | net/base/host_mapping_rules_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698