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

Unified Diff: net/base/host_resolver_impl.cc

Issue 3023048: Don't resolve IP literals. (Closed)
Patch Set: Rebase again 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 | « net/base/address_list_unittest.cc ('k') | net/base/host_resolver_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/host_resolver_impl.cc
diff --git a/net/base/host_resolver_impl.cc b/net/base/host_resolver_impl.cc
index aa1ed9cce981d5e1122019ff33078eef9ce2fa06..11d93067b904bef5a2cfc3f18b6d3f35cd672346 100644
--- a/net/base/host_resolver_impl.cc
+++ b/net/base/host_resolver_impl.cc
@@ -754,8 +754,6 @@ HostResolverImpl::~HostResolverImpl() {
delete job_pools_[i];
}
-// TODO(eroman): Don't create cache entries for hostnames which are simply IP
-// address literals.
int HostResolverImpl::Resolve(const RequestInfo& info,
AddressList* addresses,
CompletionCallback* callback,
@@ -772,6 +770,23 @@ int HostResolverImpl::Resolve(const RequestInfo& info,
// Update the net log and notify registered observers.
OnStartRequest(net_log, request_id, info);
+ // Check for IP literal.
+ IPAddressNumber ip_number;
+ if (ParseIPLiteralToNumber(info.hostname(), &ip_number)) {
+ DCHECK_EQ((info.host_resolver_flags() &
+ ~(HOST_RESOLVER_CANONNAME | HOST_RESOLVER_LOOPBACK_ONLY)), 0)
+ << " Unhandled flag";
+ AddressList result(ip_number, info.port(),
+ (info.host_resolver_flags() & HOST_RESOLVER_CANONNAME));
+
+ *addresses = result;
+ // Update the net log and notify registered observers.
+ OnFinishRequest(net_log, request_id, info, OK,
+ 0, /* os_error (unknown since from cache) */
+ false /* was_from_cache */);
+ return OK;
+ }
+
// Build a key that identifies the request in the cache and in the
// outstanding jobs map.
Key key = GetEffectiveKeyForRequest(info);
« no previous file with comments | « net/base/address_list_unittest.cc ('k') | net/base/host_resolver_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698