Deprecated Request::remote_endpoint_address() and Request::remote_endpoint_port()
This commit is contained in:
parent
da7eee64a8
commit
a1d8282918
5 changed files with 20 additions and 8 deletions
|
|
@ -89,7 +89,7 @@ int main() {
|
|||
// Responds with request-information
|
||||
server.resource["^/info$"]["GET"] = [](shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request) {
|
||||
stringstream stream;
|
||||
stream << "<h1>Request from " << request->remote_endpoint_address() << ":" << request->remote_endpoint_port() << "</h1>";
|
||||
stream << "<h1>Request from " << request->remote_endpoint().address().to_string() << ":" << request->remote_endpoint().port() << "</h1>";
|
||||
|
||||
stream << request->method << " " << request->path << " HTTP/" << request->http_version;
|
||||
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ int main() {
|
|||
// Responds with request-information
|
||||
server.resource["^/info$"]["GET"] = [](shared_ptr<HttpsServer::Response> response, shared_ptr<HttpsServer::Request> request) {
|
||||
stringstream stream;
|
||||
stream << "<h1>Request from " << request->remote_endpoint_address() << ":" << request->remote_endpoint_port() << "</h1>";
|
||||
stream << "<h1>Request from " << request->remote_endpoint().address().to_string() << ":" << request->remote_endpoint().port() << "</h1>";
|
||||
|
||||
stream << request->method << " " << request->path << " HTTP/" << request->http_version;
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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<HttpServer::Response> response, shared_ptr<HttpServer::Request> 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<HttpServer::Response> response, shared_ptr<HttpServer::Request> request) {
|
||||
|
|
|
|||
10
utility.hpp
10
utility.hpp
|
|
@ -12,6 +12,16 @@
|
|||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#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 <string_view>
|
||||
namespace SimpleWeb {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue