2
0
mirror of https://github.com/boostorg/url.git synced 2026-02-21 15:32:13 +00:00

default port

fix #290
This commit is contained in:
alandefreitas
2022-08-16 02:32:08 -03:00
parent 55ec8d4905
commit ffdc0b257d
3 changed files with 52 additions and 0 deletions

View File

@@ -107,6 +107,25 @@ to_string(scheme s) noexcept
return "<unknown>";
}
std::uint16_t
default_port(scheme s) noexcept
{
switch(s)
{
case scheme::ftp:
return 21;
case scheme::http:
case scheme::ws:
return 80;
case scheme::https:
case scheme::wss:
return 443;
default:
break;
}
return 0;
}
} // urls
} // boost

View File

@@ -12,6 +12,7 @@
#include <boost/url/detail/config.hpp>
#include <boost/url/string_view.hpp>
#include <cinttypes>
namespace boost {
namespace urls {
@@ -150,6 +151,29 @@ BOOST_URL_DECL
string_view
to_string(scheme s) noexcept;
/** Return the default port for a known scheme
This function returns the default port
for the known schemes. If the value does
not represent a known scheme or the scheme
does not represent a protocol, the function
returns zero.
The following ports are returned by the
function:
@li @ref scheme::ftp = 21
@li @ref scheme::http, @ref scheme::ws = 80
@li @ref scheme::https, @ref scheme::wss = 443
@return An integer with the default port number
@param s The known scheme constant
*/
BOOST_URL_DECL
std::uint16_t
default_port(scheme s) noexcept;
} // urls
} // boost