First really working router Version
This commit is contained in:
@@ -7,13 +7,15 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
Response::Response(std::vector<std::byte> data) {
|
||||
Response::Response(http::statusCode statusCode) { m_statusCode = statusCode; }
|
||||
|
||||
void Response::SetPayload(std::vector<std::byte> data) {
|
||||
m_headers.insert(std::pair<std::string, std::string>(
|
||||
"content-length", std::to_string(data.size())));
|
||||
m_payload = data;
|
||||
}
|
||||
|
||||
Response::Response(std::string data) {
|
||||
void Response::SetPayload(std::string data) {
|
||||
m_headers.insert(std::pair<std::string, std::string>(
|
||||
"content-length", std::to_string(std::strlen(data.data()))));
|
||||
|
||||
@@ -28,7 +30,8 @@ void Response::SetContentType(const std::string type) {
|
||||
|
||||
void Response::Send(int clientSocket) {
|
||||
std::stringstream ss;
|
||||
ss << "HTTP/1.1 200 OK\n";
|
||||
ss << "HTTP/1.1 " << m_statusCode << " "
|
||||
<< http::StatusCodeString(m_statusCode) << "\n";
|
||||
for (const auto &[key, value] : m_headers) {
|
||||
ss << key << ": " << value << "\n";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user