55 lines
1.6 KiB
C++
55 lines
1.6 KiB
C++
|
|
#ifndef HTTP_STATUS_HPP
|
|
# define HTTP_STATUS_HPP
|
|
|
|
/*
|
|
https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
|
|
*/
|
|
|
|
/*
|
|
First version of macro HTML_ERROR(STATUS) dont work with call like this :
|
|
client->response.append( HTML_ERROR( _http_status[client->status].c_str() ) );
|
|
so I made the other version with dynamic replacement of STATUS .
|
|
*/
|
|
// # define HTML_ERROR(STATUS) "\r\n<!DOCTYPE html><html><head><title>"STATUS"</title></head><body><h1 style=\"text-align:center\">"STATUS"</h1><hr><p style=\"text-align:center\">Le Webserv/0.1</p></body></html>"
|
|
|
|
# define STATUS_PLACEHOLDER "$STATUS"
|
|
# define HTML_ERROR \
|
|
"<!DOCTYPE html>"\
|
|
"<html>"\
|
|
"<head>"\
|
|
"<title>" STATUS_PLACEHOLDER "</title>"\
|
|
"</head>"\
|
|
"<body>"\
|
|
"<h1 style=\"text-align:center\">" STATUS_PLACEHOLDER "</h1>"\
|
|
"<hr>"\
|
|
"<p style=\"text-align:center\">Le Webserv/0.1</p>"\
|
|
"</body>"\
|
|
"</html>"
|
|
|
|
// When new status added, need to update _init_http_status_map()
|
|
# define S200 "200 OK"
|
|
# define S201 "201 Created"
|
|
# define S204 "204 No Content"
|
|
|
|
# define S301 "301 Moved Permanently"
|
|
# define S302 "302 Found"
|
|
# define S303 "303 See Other"
|
|
# define S304 "304 Not Modified" // unused
|
|
# define S307 "307 Temporary Redirect"
|
|
# define S308 "308 Permanent Redirect"
|
|
|
|
# define S400 "400 Bad Request"
|
|
# define S403 "403 Forbidden"
|
|
# define S404 "404 Not Found"
|
|
# define S405 "405 Method Not Allowed"
|
|
# define S408 "408 Request Timeout"
|
|
# define S413 "413 Content Too Large"
|
|
# define S415 "415 Unsupported Media Type"
|
|
|
|
# define S500 "500 Internal Server Error"
|
|
# define S501 "501 Not Implemented"
|
|
# define S505 "505 HTTP Version Not Supported"
|
|
|
|
#endif
|