From f24ab372e7f2ace6a67e0d1d3fc02e793202d8e9 Mon Sep 17 00:00:00 2001 From: "maruel@google.com" Date: Wed, 8 Oct 2008 19:06:43 +0000 Subject: Revert 3024, broke mac build. Review URL: http://codereview.chromium.org/6351 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3027 0039d316-1c4b-4281-b951-d872f2087c98 --- net/base/net_util.cc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'net/base/net_util.cc') diff --git a/net/base/net_util.cc b/net/base/net_util.cc index 305cbcc..57448af 100644 --- a/net/base/net_util.cc +++ b/net/base/net_util.cc @@ -913,4 +913,26 @@ bool IsPortAllowedByFtp(int port) { return IsPortAllowedByDefault(port); } +std::string GetImplicitPort(const GURL& url) { + if (url.has_port()) + return url.port(); + + // TODO(eroman): unify with DefaultPortForScheme() + // [url_canon_stdurl.cc] + + static const struct { + const char* scheme; + const char* port; + } scheme_map[] = { + { "http", "80" }, + { "https", "443" }, + { "ftp", "21" } + }; + for (int i = 0; i < static_cast(ARRAYSIZE_UNSAFE(scheme_map)); ++i) { + if (url.SchemeIs(scheme_map[i].scheme)) + return scheme_map[i].port; + } + return std::string(""); +} + } // namespace net -- cgit v1.1