diff options
author | HampusM <hampus@hampusmat.com> | 2022-05-13 22:33:12 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-05-13 22:33:12 +0200 |
commit | cd00813c0740930d389f935f0c2d7d8a11eef02d (patch) | |
tree | ad1d20704e6707b5fcb734876c4a0cbed860c297 /minion/src/http/request.cpp | |
parent | fc1a41c627f25c1fa52c87d002d08870fa8876ac (diff) |
refactor(minion): wifi module create http request object in stack
Diffstat (limited to 'minion/src/http/request.cpp')
-rw-r--r-- | minion/src/http/request.cpp | 42 |
1 files changed, 40 insertions, 2 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) +{ +} |