From aa216d549846fe075d7f0c3ef09513d5159bbe1a Mon Sep 17 00:00:00 2001 From: evilenzo Date: Mon, 13 Dec 2021 19:55:31 +0300 Subject: [PATCH 1/2] Missing operators and ctors for http_request and http_response --- Release/include/cpprest/http_msg.h | 117 ++++++++++++++++++++++++++++- 1 file changed, 115 insertions(+), 2 deletions(-) diff --git a/Release/include/cpprest/http_msg.h b/Release/include/cpprest/http_msg.h index 55c0433c94..10d3e5f018 100644 --- a/Release/include/cpprest/http_msg.h +++ b/Release/include/cpprest/http_msg.h @@ -503,6 +503,8 @@ class _http_response final : public http::details::http_msg_base _http_response(http::status_code code) : m_status_code(code) {} + virtual _http_response() = default; + http::status_code status_code() const { return m_status_code; } void set_status_code(http::status_code code) { m_status_code = code; } @@ -548,6 +550,60 @@ class http_response /// A new HTTP response. http_response(http::status_code code) : _m_impl(std::make_shared(code)) {} + /// + /// Constructs a response object + /// + /// A new HTTP response. + http_response(const http_response& _Other) : _m_impl(_Other._m_impl) {} + + /// + /// Constructs a response object + /// + /// A new HTTP response. + http_response(http_response&& _Other) : _m_impl(std::move(_Other._m_impl)) {} + + /// Replaces the contents of one http_request object with another. + /// The source http_request object. + /// + /// As http_request behaves like a smart pointer, after a copy assignment, this http_request + /// objects represents the same actual http_request as does. + /// + /// A new HTTP response. + http_response& operator=(const http_response& _Other) + { + if (this != &_Other) + { + _m_impl = _Other._m_impl; + } + return *this; + } + + /// + /// Destructor frees any held resources. + /// + ~http_response() = default; + + /// Replaces the contents of one http_request object with another. + /// The source http_request object. + /// + /// As http_request behaves like a smart pointer, after a copy assignment, this http_request + /// objects represents the same actual http_request as does. + /// + /// A new HTTP response. + http_response& operator=(http_response&& _Other) + { + if (this != &_Other) + { + _m_impl = std::move(_Other._m_impl); + } + return *this; + } + + /// + /// Destructor frees any held resources. + /// + ~http_response() = default; + /// /// Gets the status code of the response message. /// @@ -853,7 +909,7 @@ class _http_request final : public http::details::http_msg_base, public std::ena _ASYNCRTIMP _http_request(std::unique_ptr server_context); - virtual ~_http_request() {} + virtual ~_http_request() = default; http::method& method() { return m_method; } @@ -951,10 +1007,67 @@ class http_request /// Request method. http_request(http::method mtd) : _m_impl(std::make_shared(std::move(mtd))) {} + /// + /// Constructs a http_request object. + /// + /// + /// The source http_request object. + /// + http_request(const http_request& _Other) : _m_impl(_Other._m_impl) {} + + /// + /// Constructs a http_request object. + /// + /// + /// The source http_request object. + /// + http_request(http_request&& _Other) : _m_impl(_Other._m_impl) {} + + + /// + /// Replaces the contents of one http_request object with another. + /// + /// + /// The source http_request object. + /// + /// + /// As http_request behaves like a smart pointer, after a copy assignment, this http_request + /// objects represents the same actual http_request as does. + /// + /**/ + http_request& operator=(const http_request& _Other) + { + if (this != &_Other) + { + _m_impl = _Other._m_impl; + } + return *this; + } + + /// + /// Replaces the contents of one http_request object with another. + /// + /// + /// The source http_request object. + /// + /// + /// As http_request behaves like a smart pointer, after a copy assignment, this http_request + /// objects represents the same actual http_request as does. + /// + /**/ + http_request& operator=(http_request&& _Other) + { + if (this != &_Other) + { + _m_impl = std::move(_Other._m_impl); + } + return *this; + } + /// /// Destructor frees any held resources. /// - ~http_request() {} + ~http_request() = default; /// /// Get the method (GET/PUT/POST/DELETE) of the request message. From a8dccb3293ee61e83773d3bbc7a56f6391410e13 Mon Sep 17 00:00:00 2001 From: evilenzo Date: Sun, 26 Dec 2021 01:50:42 +0300 Subject: [PATCH 2/2] Remove all redundant code and make compiler generate copy and move functions --- Release/include/cpprest/http_msg.h | 116 ----------------------------- 1 file changed, 116 deletions(-) diff --git a/Release/include/cpprest/http_msg.h b/Release/include/cpprest/http_msg.h index 10d3e5f018..353281ffbc 100644 --- a/Release/include/cpprest/http_msg.h +++ b/Release/include/cpprest/http_msg.h @@ -550,60 +550,6 @@ class http_response /// A new HTTP response. http_response(http::status_code code) : _m_impl(std::make_shared(code)) {} - /// - /// Constructs a response object - /// - /// A new HTTP response. - http_response(const http_response& _Other) : _m_impl(_Other._m_impl) {} - - /// - /// Constructs a response object - /// - /// A new HTTP response. - http_response(http_response&& _Other) : _m_impl(std::move(_Other._m_impl)) {} - - /// Replaces the contents of one http_request object with another. - /// The source http_request object. - /// - /// As http_request behaves like a smart pointer, after a copy assignment, this http_request - /// objects represents the same actual http_request as does. - /// - /// A new HTTP response. - http_response& operator=(const http_response& _Other) - { - if (this != &_Other) - { - _m_impl = _Other._m_impl; - } - return *this; - } - - /// - /// Destructor frees any held resources. - /// - ~http_response() = default; - - /// Replaces the contents of one http_request object with another. - /// The source http_request object. - /// - /// As http_request behaves like a smart pointer, after a copy assignment, this http_request - /// objects represents the same actual http_request as does. - /// - /// A new HTTP response. - http_response& operator=(http_response&& _Other) - { - if (this != &_Other) - { - _m_impl = std::move(_Other._m_impl); - } - return *this; - } - - /// - /// Destructor frees any held resources. - /// - ~http_response() = default; - /// /// Gets the status code of the response message. /// @@ -1007,68 +953,6 @@ class http_request /// Request method. http_request(http::method mtd) : _m_impl(std::make_shared(std::move(mtd))) {} - /// - /// Constructs a http_request object. - /// - /// - /// The source http_request object. - /// - http_request(const http_request& _Other) : _m_impl(_Other._m_impl) {} - - /// - /// Constructs a http_request object. - /// - /// - /// The source http_request object. - /// - http_request(http_request&& _Other) : _m_impl(_Other._m_impl) {} - - - /// - /// Replaces the contents of one http_request object with another. - /// - /// - /// The source http_request object. - /// - /// - /// As http_request behaves like a smart pointer, after a copy assignment, this http_request - /// objects represents the same actual http_request as does. - /// - /**/ - http_request& operator=(const http_request& _Other) - { - if (this != &_Other) - { - _m_impl = _Other._m_impl; - } - return *this; - } - - /// - /// Replaces the contents of one http_request object with another. - /// - /// - /// The source http_request object. - /// - /// - /// As http_request behaves like a smart pointer, after a copy assignment, this http_request - /// objects represents the same actual http_request as does. - /// - /**/ - http_request& operator=(http_request&& _Other) - { - if (this != &_Other) - { - _m_impl = std::move(_Other._m_impl); - } - return *this; - } - - /// - /// Destructor frees any held resources. - /// - ~http_request() = default; - /// /// Get the method (GET/PUT/POST/DELETE) of the request message. ///