Skip to content

Commit

Permalink
Add ErrorContent
Browse files Browse the repository at this point in the history
  • Loading branch information
gitover22 committed Apr 10, 2024
1 parent 262ce25 commit 89a99d6
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/http/http_response.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,24 @@ size_t HttpResponse::FileLen() const{
return mmFileStat.st_size;
}
void HttpResponse::ErrorContent(Buffer& buff,std::string message){
std::string body;
std::string status;
body += "<html><title>Error</title>";
body += "<body bgcolor=\"ffffff\">";
if(CODE_STATUS.count(code) == 1) {
status = CODE_STATUS.find(code)->second;
} else {
status = "Bad Request";
}
body += std::to_string(code) + " : " + status + "\n";
body += "<p>" + message + "</p>";
body += "<hr><em>SuperServer</em></body></html>";
buff.Append("Content-length: " + std::to_string(body.size()) + "\r\n\r\n");
buff.Append(body);

}
int HttpResponse::Code() const{

return code;
}
void HttpResponse::AddStateLine(Buffer &buff){
std::string status;
Expand Down

0 comments on commit 89a99d6

Please sign in to comment.