-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnot_found_handler.cpp
More file actions
33 lines (26 loc) · 1021 Bytes
/
not_found_handler.cpp
File metadata and controls
33 lines (26 loc) · 1021 Bytes
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
// Based Off http://www.boost.org/doc/libs/1_55_0/doc/html/boost_asio/example/cpp11/http/server/request_handler.cpp
#include "not_found_handler.hpp"
#include <fstream>
#include <sstream>
namespace http {
namespace server {
RequestHandler::Status NotFoundHandler::HandleRequest(const Request &request, Response* response) {
//Uses the stock response function to create and set a 404 not found response
const char text[] =
"<html>"
"<head><title>Not Found</title></head>"
"<body><h1>404 Not Found</h1></body>"
"</html>";
std::string body = text;
response->SetStatus(Response::not_found);
response->SetBody(body); //.append(req.content, req.content+ req.bytes);
response->AddHeader("Content-Length", std::to_string(body.size()));
response->AddHeader("Content-Type", "text/html");
return RequestHandler::not_found;
}
RequestHandler::Status NotFoundHandler::Init(const std::string& uri_prefix, const NginxConfig& config)
{
return RequestHandler::OK;
}
}
}