diff options
Diffstat (limited to 'minion/src/http')
-rw-r--r-- | minion/src/http/request.cpp | 42 | ||||
-rw-r--r-- | minion/src/http/request.hpp | 14 |
2 files changed, 49 insertions, 7 deletions
diff --git a/minion/src/http/request.cpp b/minion/src/http/request.cpp index 9a35d37..9baf7cc 100644 --- a/minion/src/http/request.cpp +++ b/minion/src/http/request.cpp @@ -55,7 +55,7 @@ auto str_to_http_request_method(const char *http_request_method_str) -> HTTPRequ } HTTPRequest::HTTPRequest( - size_t connection_id, + int connection_id, HTTPRequestMethod method, char *http_version, // NOLINT(bugprone-easily-swappable-parameters) char *path, @@ -71,12 +71,23 @@ HTTPRequest::HTTPRequest( { } +HTTPRequest::HTTPRequest(HTTPRequest &&other) noexcept + : _connection_id(other._connection_id), + _method(other._method), + _http_version(other._http_version), + _path(other._path), + _data_length(other._data_length), + _data(other._data) +{ + other._data = nullptr; +} + HTTPRequest::~HTTPRequest() noexcept { free(_data); } -auto HTTPRequest::connection_id() const noexcept -> size_t +auto HTTPRequest::connection_id() const noexcept -> int { return _connection_id; } @@ -105,3 +116,30 @@ auto HTTPRequest::data() const noexcept -> const char * { return _data; } + +auto HTTPRequest::operator=(HTTPRequest &&other) noexcept -> HTTPRequest & +{ + if (this != &other) + { + free(_data); + _data = other._data; + other._data = nullptr; + } + + return *this; +} + +HTTPRequest HTTPRequest::create_invalid() noexcept +{ + return HTTPRequest(); +} + +HTTPRequest::HTTPRequest() noexcept + : _connection_id(-1), + _method(HTTPRequestMethod(-1)), + _http_version(""), + _path(""), + _data_length(0), + _data(nullptr) +{ +} diff --git a/minion/src/http/request.hpp b/minion/src/http/request.hpp index 85af722..8524dc6 100644 --- a/minion/src/http/request.hpp +++ b/minion/src/http/request.hpp @@ -25,7 +25,7 @@ class HTTPRequest { public: explicit HTTPRequest( - size_t connection_id, + int connection_id, HTTPRequestMethod method, char *http_version, char *path, @@ -35,11 +35,11 @@ public: HTTPRequest(const HTTPRequest &other) noexcept = delete; - HTTPRequest(HTTPRequest &&other) noexcept = delete; + HTTPRequest(HTTPRequest &&other) noexcept; ~HTTPRequest() noexcept; - auto connection_id() const noexcept -> size_t; + auto connection_id() const noexcept -> int; auto method() const noexcept -> HTTPRequestMethod; @@ -53,13 +53,17 @@ public: auto operator=(const HTTPRequest &other) noexcept -> HTTPRequest & = delete; - auto operator=(HTTPRequest &&other) noexcept -> HTTPRequest & = delete; + auto operator=(HTTPRequest &&other) noexcept -> HTTPRequest &; + + static HTTPRequest create_invalid() noexcept; private: - const size_t _connection_id; + const int _connection_id; const HTTPRequestMethod _method; char *_http_version; char *_path; const int _data_length; char *_data; + + HTTPRequest() noexcept; }; |