diff --git a/src/uri.cpp b/src/uri.cpp index 493b2bafb3..5c884be58b 100644 --- a/src/uri.cpp +++ b/src/uri.cpp @@ -74,7 +74,7 @@ uri::uri(bool secure, const std::string& host, uint16_t port, const std::string& uri::uri(bool secure, const std::string& host, const std::string& resource) : m_secure(secure), m_host(host), - m_port(m_secure ? DEFAULT_SECURE_PORT : DEFAULT_PORT), + m_port(m_secure ? URI_DEFAULT_SECURE_PORT : URI_DEFAULT_PORT), m_resource(resource == "" ? "/" : resource) {} uri::uri(bool secure, @@ -119,7 +119,7 @@ std::string uri::get_host() const { } std::string uri::get_host_port() const { - if (m_port == (m_secure ? DEFAULT_SECURE_PORT : DEFAULT_PORT)) { + if (m_port == (m_secure ? URI_DEFAULT_SECURE_PORT : URI_DEFAULT_PORT)) { return m_host; } else { std::stringstream p; @@ -148,7 +148,7 @@ std::string uri::str() const { s << "ws" << (m_secure ? "s" : "") << "://" << m_host; - if (m_port != (m_secure ? DEFAULT_SECURE_PORT : DEFAULT_PORT)) { + if (m_port != (m_secure ? URI_DEFAULT_SECURE_PORT : URI_DEFAULT_PORT)) { s << ":" << m_port; } @@ -158,7 +158,7 @@ std::string uri::str() const { uint16_t uri::get_port_from_string(const std::string& port) const { if (port == "") { - return (m_secure ? DEFAULT_SECURE_PORT : DEFAULT_PORT); + return (m_secure ? URI_DEFAULT_SECURE_PORT : URI_DEFAULT_PORT); } unsigned int t_port = atoi(port.c_str()); diff --git a/src/uri.hpp b/src/uri.hpp index d68916ee5f..b2d270c617 100644 --- a/src/uri.hpp +++ b/src/uri.hpp @@ -50,12 +50,13 @@ private: std::string m_msg; }; - +// TODO: figure out why this fixes horrible linking errors. +static const uint16_t URI_DEFAULT_PORT = 80; +static const uint16_t URI_DEFAULT_SECURE_PORT = 443; class uri { public: - static const uint16_t DEFAULT_PORT = 80; - static const uint16_t DEFAULT_SECURE_PORT = 443; + explicit uri(const std::string& uri); uri(bool secure, const std::string& host, uint16_t port, const std::string& resource);