Absorbtion of generate response
This commit is contained in:
@@ -20,7 +20,13 @@ void HTTPrequest::processRequest() {
|
||||
void HTTPrequest::sendResponse(std::string status, std::string mime,
|
||||
std::string data) {
|
||||
// Logging here perhaps
|
||||
asio::write(sock, asio::buffer(data));
|
||||
std::stringstream output;
|
||||
output << "HTTP/1.1 " << status << "\n"
|
||||
<< "Content-Type: " << mime << "\nContent-Length: " << data.size()
|
||||
<< "\nConnection: close\n\n"
|
||||
<< data;
|
||||
|
||||
asio::write(sock, asio::buffer(output.str()));
|
||||
}
|
||||
|
||||
// ================= CLASS HANDLING SPECIFIC =================
|
||||
|
@@ -22,13 +22,3 @@ void Helpers::getlineAndCount(std::basic_istream<char> &stream, uint64_t &count,
|
||||
count += string.size() + 1; // Delimiter
|
||||
return;
|
||||
}
|
||||
std::string Helpers::GenerateResponse(std::string statusCode,
|
||||
std::string contentType,
|
||||
std::string content) {
|
||||
std::stringstream output;
|
||||
output << "HTTP/1.1 " << statusCode << "\n"
|
||||
<< "Content-Type: " << contentType
|
||||
<< "\nContent-Length: " << content.size() << "\nConnection: close\n\n"
|
||||
<< content;
|
||||
return output.str();
|
||||
}
|
||||
|
@@ -5,6 +5,4 @@ namespace Helpers {
|
||||
std::string ReadFile(std::string Path);
|
||||
void getlineAndCount(std::basic_istream<char> &stream, uint64_t &count,
|
||||
std::string &string, char delimit = '\0');
|
||||
std::string GenerateResponse(std::string statusCode, std::string contentType,
|
||||
std::string content);
|
||||
} // namespace Helpers
|
||||
|
Reference in New Issue
Block a user