summaryrefslogtreecommitdiffstats
path: root/net/base/net_util.cc
diff options
context:
space:
mode:
Diffstat (limited to 'net/base/net_util.cc')
-rw-r--r--net/base/net_util.cc22
1 files changed, 22 insertions, 0 deletions
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<int>(ARRAYSIZE_UNSAFE(scheme_map)); ++i) {
+ if (url.SchemeIs(scheme_map[i].scheme))
+ return scheme_map[i].port;
+ }
+ return std::string("");
+}
+
} // namespace net