fix: update toBytes method in HttpResponse to accept offset parameter
This commit is contained in:
parent
f8a73fde2b
commit
a11e1ec42d
@ -89,7 +89,7 @@ std::string HttpResponse::getDateHeader() const
|
|||||||
return "Date: " + std::string(buffer) + "\r\n";
|
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 headerStr;
|
||||||
std::string reason;
|
std::string reason;
|
||||||
@ -107,5 +107,5 @@ std::vector<uint8_t> HttpResponse::toBytes() const
|
|||||||
std::vector<uint8_t> responseData(headerStr.begin(), headerStr.end());
|
std::vector<uint8_t> responseData(headerStr.begin(), headerStr.end());
|
||||||
responseData.insert(responseData.end(), body_.begin(), body_.end());
|
responseData.insert(responseData.end(), body_.begin(), body_.end());
|
||||||
|
|
||||||
return responseData;
|
return {responseData.begin() + offset, responseData.end()};
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ class HttpResponse
|
|||||||
|
|
||||||
[[nodiscard]] const HttpHeaders &getHeaders() const noexcept;
|
[[nodiscard]] const HttpHeaders &getHeaders() const noexcept;
|
||||||
|
|
||||||
[[nodiscard]] std::vector<uint8_t> toBytes() const;
|
[[nodiscard]] std::vector<uint8_t> toBytes(long offset = 0) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
[[nodiscard]] std::string getStatusLine() const;
|
[[nodiscard]] std::string getStatusLine() const;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user