summaryrefslogtreecommitdiffstats
path: root/net/proxy/proxy_server.cc
diff options
context:
space:
mode:
authorwtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-14 23:17:14 +0000
committerwtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-14 23:17:14 +0000
commite57ec6f78194e1cd7bb74b47cda1eab065e2d39a (patch)
treedc4d7f9e8b82e6c38bd37b7d2bd6d8e8cd879e2e /net/proxy/proxy_server.cc
parente5a99ff3bd91f5493e7916b9dca6b29429ce0f43 (diff)
downloadchromium_src-e57ec6f78194e1cd7bb74b47cda1eab065e2d39a.zip
chromium_src-e57ec6f78194e1cd7bb74b47cda1eab065e2d39a.tar.gz
chromium_src-e57ec6f78194e1cd7bb74b47cda1eab065e2d39a.tar.bz2
Change the host() method of ProxyServer to strip the
square brackets around an IPv6 literal address. Rename the method HostNoBrackets() to be consistent with GURL's new HostNoBrackets() method. When resolving an address, use the new HostNoBrackets() method instead of host(). Part of this changelist was contributed by Paul Marks of Google. Original review: http://codereview.chromium.org/115342 R=eroman http://crbug.com/12005 TEST=covered by new test cases in unit test Review URL: http://codereview.chromium.org/114029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16123 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/proxy/proxy_server.cc')
-rw-r--r--net/proxy/proxy_server.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/net/proxy/proxy_server.cc b/net/proxy/proxy_server.cc
index 8cb1c17..0209a83 100644
--- a/net/proxy/proxy_server.cc
+++ b/net/proxy/proxy_server.cc
@@ -56,10 +56,15 @@ ProxyServer::Scheme GetSchemeFromURI(std::string::const_iterator begin,
} // namespace
-const std::string& ProxyServer::host() const {
+std::string ProxyServer::HostNoBrackets() const {
// Doesn't make sense to call this if the URI scheme doesn't
// have concept of a host.
DCHECK(is_valid() && !is_direct());
+
+ // Remove brackets from an RFC 2732-style IPv6 literal address.
+ const std::string::size_type len = host_.size();
+ if (len != 0 && host_[0] == '[' && host_[len - 1] == ']')
+ return host_.substr(1, len - 2);
return host_;
}