diff --git a/src/httpserver/basic_auth_fail_response.hpp b/src/httpserver/basic_auth_fail_response.hpp index a7c7b418..c9182dce 100644 --- a/src/httpserver/basic_auth_fail_response.hpp +++ b/src/httpserver/basic_auth_fail_response.hpp @@ -56,6 +56,12 @@ class basic_auth_fail_response : public string_response { } + basic_auth_fail_response(basic_auth_fail_response&& other) noexcept: + string_response(std::move(other)), + realm(std::move(other.realm)) + { + } + basic_auth_fail_response& operator=(const basic_auth_fail_response& b) { if (this == &b) return *this; @@ -66,6 +72,16 @@ class basic_auth_fail_response : public string_response return *this; } + basic_auth_fail_response& operator=(basic_auth_fail_response&& b) + { + if (this == &b) return *this; + + (string_response&) (*this) = std::move(b); + this->realm = std::move(b.realm); + + return *this; + } + ~basic_auth_fail_response() { } diff --git a/src/httpserver/create_webserver.hpp b/src/httpserver/create_webserver.hpp index c0ecb189..43a59f9d 100644 --- a/src/httpserver/create_webserver.hpp +++ b/src/httpserver/create_webserver.hpp @@ -87,6 +87,178 @@ class create_webserver { } + create_webserver(const create_webserver& b): + _port(b._port), + _start_method(b._start_method), + _max_threads(b._max_threads), + _max_connections(b._max_connections), + _memory_limit(b._memory_limit), + _content_size_limit(b._content_size_limit), + _connection_timeout(b._connection_timeout), + _per_IP_connection_limit(b._per_IP_connection_limit), + _log_access(b._log_access), + _log_error(b._log_error), + _validator(b._validator), + _unescaper(b._unescaper), + _bind_address(b._bind_address), + _bind_socket(b._bind_socket), + _max_thread_stack_size(b._max_thread_stack_size), + _use_ssl(b._use_ssl), + _use_ipv6(b._use_ipv6), + _debug(b._debug), + _pedantic(b._pedantic), + _https_mem_key(b._https_mem_key), + _https_mem_cert(b._https_mem_cert), + _https_mem_trust(b._https_mem_trust), + _https_priorities(b._https_priorities), + _cred_type(b._cred_type), + _digest_auth_random(b._digest_auth_random), + _nonce_nc_size(b._nonce_nc_size), + _default_policy(b._default_policy), + _basic_auth_enabled(b._basic_auth_enabled), + _digest_auth_enabled(b._digest_auth_enabled), + _regex_checking(b._regex_checking), + _ban_system_enabled(b._ban_system_enabled), + _post_process_enabled(b._post_process_enabled), + _deferred_enabled(b._deferred_enabled), + _single_resource(b._single_resource), + _not_found_resource(b._not_found_resource), + _method_not_allowed_resource(b._method_not_allowed_resource), + _internal_error_resource(b._internal_error_resource) + { + } + + create_webserver(create_webserver&& b): + _port(b._port), + _start_method(b._start_method), + _max_threads(b._max_threads), + _max_connections(b._max_connections), + _memory_limit(b._memory_limit), + _content_size_limit(b._content_size_limit), + _connection_timeout(b._connection_timeout), + _per_IP_connection_limit(b._per_IP_connection_limit), + _log_access(std::move(b._log_access)), + _log_error(std::move(b._log_error)), + _validator(std::move(b._validator)), + _unescaper(std::move(b._unescaper)), + _bind_address(std::move(b._bind_address)), + _bind_socket(b._bind_socket), + _max_thread_stack_size(b._max_thread_stack_size), + _use_ssl(b._use_ssl), + _use_ipv6(b._use_ipv6), + _debug(b._debug), + _pedantic(b._pedantic), + _https_mem_key(std::move(b._https_mem_key)), + _https_mem_cert(std::move(b._https_mem_cert)), + _https_mem_trust(std::move(b._https_mem_trust)), + _https_priorities(std::move(b._https_priorities)), + _cred_type(b._cred_type), + _digest_auth_random(std::move(b._digest_auth_random)), + _nonce_nc_size(b._nonce_nc_size), + _default_policy(b._default_policy), + _basic_auth_enabled(b._basic_auth_enabled), + _digest_auth_enabled(b._digest_auth_enabled), + _regex_checking(b._regex_checking), + _ban_system_enabled(b._ban_system_enabled), + _post_process_enabled(b._post_process_enabled), + _deferred_enabled(b._deferred_enabled), + _single_resource(b._single_resource), + _not_found_resource(std::move(b._not_found_resource)), + _method_not_allowed_resource(std::move(b._method_not_allowed_resource)), + _internal_error_resource(std::move(b._internal_error_resource)) + { + } + + create_webserver& operator=(const create_webserver& b) + { + if (this == &b) return *this; + + this->_port = b._port; + this->_start_method = b._start_method; + this->_max_threads = b._max_threads; + this->_max_connections = b._max_connections; + this->_memory_limit = b._memory_limit; + this->_content_size_limit = b._content_size_limit; + this->_connection_timeout = b._connection_timeout; + this->_per_IP_connection_limit = b._per_IP_connection_limit; + this->_log_access = b._log_access; + this->_log_error = b._log_error; + this->_validator = b._validator; + this->_unescaper = b._unescaper; + this->_bind_address = b._bind_address; + this->_bind_socket = b._bind_socket; + this->_max_thread_stack_size = b._max_thread_stack_size; + this->_use_ssl = b._use_ssl; + this->_use_ipv6 = b._use_ipv6; + this->_debug = b._debug; + this->_pedantic = b._pedantic; + this->_https_mem_key = b._https_mem_key; + this->_https_mem_cert = b._https_mem_cert; + this->_https_mem_trust = b._https_mem_trust; + this->_https_priorities = b._https_priorities; + this->_cred_type = b._cred_type; + this->_digest_auth_random = b._digest_auth_random; + this->_nonce_nc_size = b._nonce_nc_size; + this->_default_policy = b._default_policy; + this->_basic_auth_enabled = b._basic_auth_enabled; + this->_digest_auth_enabled = b._digest_auth_enabled; + this->_regex_checking = b._regex_checking; + this->_ban_system_enabled = b._ban_system_enabled; + this->_post_process_enabled = b._post_process_enabled; + this->_deferred_enabled = b._deferred_enabled; + this->_single_resource = b._single_resource; + this->_not_found_resource = b._not_found_resource; + this->_method_not_allowed_resource = b._method_not_allowed_resource; + this->_internal_error_resource = b._internal_error_resource; + + return *this; + } + + create_webserver& operator=(create_webserver&& b) + { + if (this == &b) return *this; + + this->_port = b._port; + this->_start_method = b._start_method; + this->_max_threads = b._max_threads; + this->_max_connections = b._max_connections; + this->_memory_limit = b._memory_limit; + this->_content_size_limit = b._content_size_limit; + this->_connection_timeout = b._connection_timeout; + this->_per_IP_connection_limit = b._per_IP_connection_limit; + this->_log_access = std::move(b._log_access); + this->_log_error = std::move(b._log_error); + this->_validator = std::move(b._validator); + this->_unescaper = std::move(b._unescaper); + this->_bind_address = std::move(b._bind_address); + this->_bind_socket = b._bind_socket; + this->_max_thread_stack_size = b._max_thread_stack_size; + this->_use_ssl = b._use_ssl; + this->_use_ipv6 = b._use_ipv6; + this->_debug = b._debug; + this->_pedantic = b._pedantic; + this->_https_mem_key = std::move(b._https_mem_key); + this->_https_mem_cert = std::move(b._https_mem_cert); + this->_https_mem_trust = std::move(b._https_mem_trust); + this->_https_priorities = std::move(b._https_priorities); + this->_cred_type = b._cred_type; + this->_digest_auth_random = std::move(b._digest_auth_random); + this->_nonce_nc_size = b._nonce_nc_size; + this->_default_policy = b._default_policy; + this->_basic_auth_enabled = b._basic_auth_enabled; + this->_digest_auth_enabled = b._digest_auth_enabled; + this->_regex_checking = b._regex_checking; + this->_ban_system_enabled = b._ban_system_enabled; + this->_post_process_enabled = b._post_process_enabled; + this->_deferred_enabled = b._deferred_enabled; + this->_single_resource = b._single_resource; + this->_not_found_resource = std::move(b._not_found_resource); + this->_method_not_allowed_resource = std::move(b._method_not_allowed_resource); + this->_internal_error_resource = std::move(b._internal_error_resource); + + return *this; + } + explicit create_webserver(uint16_t port): _port(port), _start_method(http::http_utils::INTERNAL_SELECT), diff --git a/src/httpserver/deferred_response.hpp b/src/httpserver/deferred_response.hpp index ab46a306..c5a9f1ff 100644 --- a/src/httpserver/deferred_response.hpp +++ b/src/httpserver/deferred_response.hpp @@ -59,12 +59,31 @@ class deferred_response : public string_response { } + deferred_response(deferred_response&& other) noexcept: + string_response(std::move(other)), + cycle_callback(std::move(other.cycle_callback)), + completed(other.completed) + { + } + deferred_response& operator=(const deferred_response& b) { if (this == &b) return *this; (string_response&) (*this) = b; this->cycle_callback = b.cycle_callback; + this->completed = b.completed; + + return *this; + } + + deferred_response& operator=(deferred_response&& b) + { + if (this == &b) return *this; + + (string_response&) (*this) = std::move(b); + this->cycle_callback = std::move(b.cycle_callback); + this->completed = b.completed; return *this; } diff --git a/src/httpserver/details/modded_request.hpp b/src/httpserver/details/modded_request.hpp index 74bb79df..5948e1bd 100644 --- a/src/httpserver/details/modded_request.hpp +++ b/src/httpserver/details/modded_request.hpp @@ -53,6 +53,55 @@ struct modded_request second(false) { } + + modded_request(const modded_request& b): + pp(b.pp), + complete_uri(b.complete_uri), + standardized_url(b.standardized_url), + ws(b.ws), + dhr(b.dhr), + second(b.second) + { + } + + modded_request(modded_request&& b): + pp(std::move(b.pp)), + complete_uri(std::move(b.complete_uri)), + standardized_url(std::move(b.standardized_url)), + ws(std::move(b.ws)), + dhr(std::move(b.dhr)), + second(b.second) + { + } + + modded_request& operator=(const modded_request& b) + { + if (this == &b) return *this; + + this->pp = b.pp; + this->complete_uri = b.complete_uri; + this->standardized_url = b.standardized_url; + this->ws = b.ws; + this->dhr = b.dhr; + this->second = b.second; + + return *this; + } + + modded_request& operator=(modded_request&& b) + { + if (this == &b) return *this; + + this->pp = std::move(b.pp); + this->complete_uri = std::move(b.complete_uri); + this->standardized_url = std::move(b.standardized_url); + this->ws = std::move(b.ws); + this->dhr = std::move(b.dhr); + this->second = b.second; + + return *this; + } + ~modded_request() { if (NULL != pp) diff --git a/src/httpserver/digest_auth_fail_response.hpp b/src/httpserver/digest_auth_fail_response.hpp index 2b67d268..63d02378 100644 --- a/src/httpserver/digest_auth_fail_response.hpp +++ b/src/httpserver/digest_auth_fail_response.hpp @@ -64,6 +64,14 @@ class digest_auth_fail_response : public string_response { } + digest_auth_fail_response(digest_auth_fail_response&& other) noexcept: + string_response(std::move(other)), + realm(std::move(other.realm)), + opaque(std::move(other.opaque)), + reload_nonce(other.reload_nonce) + { + } + digest_auth_fail_response& operator=(const digest_auth_fail_response& b) { if (this == &b) return *this; @@ -76,6 +84,18 @@ class digest_auth_fail_response : public string_response return *this; } + digest_auth_fail_response& operator=(digest_auth_fail_response&& b) + { + if (this == &b) return *this; + + (string_response&) (*this) = std::move(b); + this->realm = std::move(b.realm); + this->opaque = std::move(b.opaque); + this->reload_nonce = b.reload_nonce; + + return *this; + } + ~digest_auth_fail_response() { } diff --git a/src/httpserver/file_response.hpp b/src/httpserver/file_response.hpp index 9f7a3977..1192d91a 100644 --- a/src/httpserver/file_response.hpp +++ b/src/httpserver/file_response.hpp @@ -55,6 +55,12 @@ class file_response : public http_response { } + file_response(file_response&& other) noexcept: + http_response(std::move(other)), + filename(std::move(other.filename)) + { + } + file_response& operator=(const file_response& b) { if (this == &b) return *this; @@ -65,6 +71,16 @@ class file_response : public http_response return *this; } + file_response& operator=(file_response&& b) + { + if (this == &b) return *this; + + (http_response&) (*this) = std::move(b); + this->filename = std::move(b.filename); + + return *this; + } + ~file_response() { } diff --git a/src/httpserver/http_request.hpp b/src/httpserver/http_request.hpp index 93a23f7b..96b49833 100644 --- a/src/httpserver/http_request.hpp +++ b/src/httpserver/http_request.hpp @@ -78,7 +78,7 @@ class http_request { return this->pass; } - + /** * Method used to get the path requested * @return string representing the path requested. @@ -182,7 +182,7 @@ class http_request else return EMPTY; } - + /** * Method used to get a specific footer passed with the request. * @param key the specific footer to get the value from @@ -197,7 +197,7 @@ class http_request else return EMPTY; } - + /** * Method used to get a specific argument passed with the request. * @param ket the specific argument to get the value from @@ -212,7 +212,7 @@ class http_request else return EMPTY; } - + /** * Method used to get the content of the request. * @return the content in string representation @@ -221,7 +221,7 @@ class http_request { return this->content; } - + /** * Method to check whether the size of the content reached or exceeded content_size_limit. * @return boolean @@ -238,7 +238,7 @@ class http_request { return this->querystring; } - + /** * Method used to get the version of the request. * @return the version in string representation @@ -247,7 +247,7 @@ class http_request { return this->version; } - + /** * Method used to get the requestor. * @return the requestor @@ -256,7 +256,7 @@ class http_request { return this->requestor; } - + /** * Method used to get the requestor port used. * @return the requestor port @@ -304,6 +304,75 @@ class http_request underlying_connection(b.underlying_connection) { } + + http_request(http_request&& b) noexcept: + user(std::move(b.user)), + pass(std::move(b.pass)), + path(std::move(b.path)), + digested_user(std::move(b.digested_user)), + method(std::move(b.method)), + post_path(std::move(b.post_path)), + headers(std::move(b.headers)), + footers(std::move(b.footers)), + cookies(std::move(b.cookies)), + args(std::move(b.args)), + querystring(std::move(b.querystring)), + content(std::move(b.content)), + content_size_limit(b.content_size_limit), + version(std::move(b.version)), + requestor(std::move(b.requestor)), + underlying_connection(std::move(b.underlying_connection)) + { + } + + http_request& operator=(const http_request& b) + { + if (this == &b) return *this; + + this->user = b.user; + this->pass = b.pass; + this->path = b.path; + this->digested_user = b.digested_user; + this->method = b.method; + this->post_path = b.post_path; + this->headers = b.headers; + this->footers = b.footers; + this->cookies = b.cookies; + this->args = b.args; + this->querystring = b.querystring; + this->content = b.content; + this->content_size_limit = b.content_size_limit; + this->version = b.version; + this->requestor = b.requestor; + this->underlying_connection = b.underlying_connection; + + return *this; + } + + http_request& operator=(http_request&& b) + { + if (this == &b) return *this; + + this->user = std::move(b.user); + this->pass = std::move(b.pass); + this->path = std::move(b.path); + this->digested_user = std::move(b.digested_user); + this->method = std::move(b.method); + this->post_path = std::move(b.post_path); + this->headers = std::move(b.headers); + this->footers = std::move(b.footers); + this->cookies = std::move(b.cookies); + this->args = std::move(b.args); + this->querystring = std::move(b.querystring); + this->content = std::move(b.content); + this->content_size_limit = b.content_size_limit; + this->version = std::move(b.version); + this->requestor = std::move(b.requestor); + this->underlying_connection = std::move(b.underlying_connection); + + return *this; + } + std::string user; std::string pass; std::string path; diff --git a/src/httpserver/http_resource.hpp b/src/httpserver/http_resource.hpp index 0460f92b..faaa3463 100644 --- a/src/httpserver/http_resource.hpp +++ b/src/httpserver/http_resource.hpp @@ -212,12 +212,24 @@ class http_resource **/ http_resource(const http_resource& b) : allowed_methods(b.allowed_methods) { } + http_resource(http_resource&& b) noexcept: allowed_methods(std::move(b.allowed_methods)) { } + http_resource& operator=(const http_resource& b) { + if (this == &b) return *this; + allowed_methods = b.allowed_methods; return (*this); } + http_resource& operator=(http_resource&& b) + { + if (this == &b) return *this; + + allowed_methods = std::move(b.allowed_methods); + return (*this); + } + private: friend class webserver; friend void resource_init(std::map& res); diff --git a/src/httpserver/http_response.hpp b/src/httpserver/http_response.hpp index 0846878f..b7f9b9a9 100644 --- a/src/httpserver/http_response.hpp +++ b/src/httpserver/http_response.hpp @@ -68,6 +68,14 @@ class http_response { } + http_response(http_response&& other) noexcept: + response_code(other.response_code), + headers(std::move(other.headers)), + footers(std::move(other.footers)), + cookies(std::move(other.cookies)) + { + } + http_response& operator=(const http_response& b) { if (this == &b) return *this; @@ -80,6 +88,18 @@ class http_response return *this; } + http_response& operator=(http_response&& b) + { + if (this == &b) return *this; + + this->response_code = b.response_code; + this->headers = std::move(b.headers); + this->footers = std::move(b.footers); + this->cookies = std::move(b.cookies); + + return *this; + } + virtual ~http_response() { } diff --git a/src/httpserver/string_response.hpp b/src/httpserver/string_response.hpp index c0177a74..0397f38c 100644 --- a/src/httpserver/string_response.hpp +++ b/src/httpserver/string_response.hpp @@ -55,6 +55,12 @@ class string_response : public http_response { } + string_response(string_response&& other) noexcept: + http_response(std::move(other)), + content(std::move(other.content)) + { + } + string_response& operator=(const string_response& b) { if (this == &b) return *this; @@ -65,6 +71,16 @@ class string_response : public http_response return *this; } + string_response& operator=(string_response&& b) + { + if (this == &b) return *this; + + (http_response&) (*this) = std::move(b); + this->content = std::move(b.content); + + return *this; + } + ~string_response() { }