fix: update toBytes method in HttpResponse to accept offset parameter

This commit is contained in:
Quinten 2025-11-11 16:29:39 +01:00
parent f8a73fde2b
commit a11e1ec42d
2 changed files with 3 additions and 3 deletions

View File

@ -89,7 +89,7 @@ std::string HttpResponse::getDateHeader() const
return "Date: " + std::string(buffer) + "\r\n";
}
std::vector<uint8_t> HttpResponse::toBytes() const
std::vector<uint8_t> HttpResponse::toBytes(long offset) const
{
std::string headerStr;
std::string reason;
@ -107,5 +107,5 @@ std::vector<uint8_t> HttpResponse::toBytes() const
std::vector<uint8_t> responseData(headerStr.begin(), headerStr.end());
responseData.insert(responseData.end(), body_.begin(), body_.end());
return responseData;
return {responseData.begin() + offset, responseData.end()};
}

View File

@ -39,7 +39,7 @@ class HttpResponse
[[nodiscard]] const HttpHeaders &getHeaders() const noexcept;
[[nodiscard]] std::vector<uint8_t> toBytes() const;
[[nodiscard]] std::vector<uint8_t> toBytes(long offset = 0) const;
private:
[[nodiscard]] std::string getStatusLine() const;