diff --git a/http_examples.cpp b/http_examples.cpp index 12ab507..297aeb6 100644 --- a/http_examples.cpp +++ b/http_examples.cpp @@ -89,7 +89,7 @@ int main() { // Responds with request-information server.resource["^/info$"]["GET"] = [](shared_ptr response, shared_ptr request) { stringstream stream; - stream << "

Request from " << request->remote_endpoint_address() << ":" << request->remote_endpoint_port() << "

"; + stream << "

Request from " << request->remote_endpoint().address().to_string() << ":" << request->remote_endpoint().port() << "

"; stream << request->method << " " << request->path << " HTTP/" << request->http_version; diff --git a/https_examples.cpp b/https_examples.cpp index fab8849..a091bcb 100644 --- a/https_examples.cpp +++ b/https_examples.cpp @@ -87,7 +87,7 @@ int main() { // Responds with request-information server.resource["^/info$"]["GET"] = [](shared_ptr response, shared_ptr request) { stringstream stream; - stream << "

Request from " << request->remote_endpoint_address() << ":" << request->remote_endpoint_port() << "

"; + stream << "

Request from " << request->remote_endpoint().address().to_string() << ":" << request->remote_endpoint().port() << "

"; stream << request->method << " " << request->path << " HTTP/" << request->http_version; diff --git a/server_http.hpp b/server_http.hpp index 8152383..c4ec1d1 100644 --- a/server_http.hpp +++ b/server_http.hpp @@ -254,7 +254,8 @@ namespace SimpleWeb { return asio::ip::tcp::endpoint(); } - std::string remote_endpoint_address() const noexcept { + /// Deprecated, please use remote_endpoint().address().to_string() instead. + DEPRECATED std::string remote_endpoint_address() const noexcept { try { if(auto connection = this->connection.lock()) return connection->socket->lowest_layer().remote_endpoint().address().to_string(); @@ -264,7 +265,8 @@ namespace SimpleWeb { return std::string(); } - unsigned short remote_endpoint_port() const noexcept { + /// Deprecated, please use remote_endpoint().port() instead. + DEPRECATED unsigned short remote_endpoint_port() const noexcept { try { if(auto connection = this->connection.lock()) return connection->socket->lowest_layer().remote_endpoint().port(); diff --git a/tests/io_test.cpp b/tests/io_test.cpp index 8a139b7..afa0f2d 100644 --- a/tests/io_test.cpp +++ b/tests/io_test.cpp @@ -61,8 +61,8 @@ int main() { *response << "HTTP/1.1 200 OK\r\nContent-Length: " << content.length() << "\r\n\r\n" << content; - ASSERT(!request->remote_endpoint_address().empty()); - ASSERT(request->remote_endpoint_port() != 0); + ASSERT(!request->remote_endpoint().address().to_string().empty()); + ASSERT(request->remote_endpoint().port() != 0); }; server.resource["^/string/dup$"]["POST"] = [](shared_ptr response, shared_ptr request) { @@ -75,8 +75,8 @@ int main() { *response << content; response->send(); - ASSERT(!request->remote_endpoint_address().empty()); - ASSERT(request->remote_endpoint_port() != 0); + ASSERT(!request->remote_endpoint().address().to_string().empty()); + ASSERT(request->remote_endpoint().port() != 0); }; server.resource["^/string2$"]["POST"] = [](shared_ptr response, shared_ptr request) { diff --git a/utility.hpp b/utility.hpp index 0c9ee9c..2e20f93 100644 --- a/utility.hpp +++ b/utility.hpp @@ -12,6 +12,16 @@ #include #include +#ifndef DEPRECATED +#if defined(__GNUC__) || defined(__clang__) +#define DEPRECATED __attribute__((deprecated)) +#elif defined(_MSC_VER) +#define DEPRECATED __declspec(deprecated) +#else +#define DEPRECATED +#endif +#endif + #if __cplusplus > 201402L || _MSVC_LANG > 201402L #include namespace SimpleWeb {