-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresponse.cpp
More file actions
34 lines (33 loc) · 1.15 KB
/
Copy pathresponse.cpp
File metadata and controls
34 lines (33 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "response.hpp"
OK::OK(std::string& t_content, std::map<std::string, std::string>& t_header){
content = t_content;
header = t_header;
header["Content-Length"] = std::to_string(content.length());
status = 200;
sheader = "HTTP/1.1 200 OK\r\n";
stringify_header();
}
void Response::stringify_header(){
for (auto it : header){
sheader += it.first;
sheader += ": ";
sheader += it.second;
sheader += "\r\n";
}
}
NotFound::NotFound() {
status = 404;
sheader = "HTTP/1.1 404 Not Found\r\n";
content = "<HTML><title>Not Found</title><body><h1>404 Requested Ressource could not be found</h1></body></HTML>";
header["Content-Type"] = "text/html";
header["Content-Length"] = std::to_string(content.length());
stringify_header();
}
BadRequest::BadRequest() {
status = 400;
sheader = "HTTP/1.1 400 Bad Request\r\n";
content = "<HTML><title>Bad Request</title><body><h1>The Request is ill formatted or unsuited in this case</h1></body></HTML>";
header["Content-Type"] = "text/html";
header["Content-Length"] = std::to_string(content.length());
stringify_header();
}