Browse Source

make create_status_response() available for Webserver users.

pull/1/head
roker 2 years ago
parent
commit
6e748754e5
2 changed files with 12 additions and 1 deletions
  1. +9
    -1
      webserver.cc
  2. +3
    -0
      webserver.hh

+ 9
- 1
webserver.cc View File

@ -78,7 +78,7 @@ void Webserver::remove_generic_url_handler()
}
void Webserver::deliver_status(tcp::socket *socket, const request& req, http::status status)
Webserver::response Webserver::create_status_response(const request& req, http::status status)
{
http::response< http::string_body > res{status, req.version()};
res.set(http::field::content_type, "text/html; charset=utf-8");
@ -89,6 +89,14 @@ void Webserver::deliver_status(tcp::socket *socket, const request& req, http::st
res.prepare_payload();
if (status != http::status::internal_server_error)
res.keep_alive(req.keep_alive());
return res;
}
void Webserver::deliver_status(tcp::socket *socket, const request& req, http::status status)
{
const response res { create_status_response(req, status) };
beast::error_code ec;
http::write(*socket, res, ec);
}


+ 3
- 0
webserver.hh View File

@ -67,6 +67,9 @@ namespace pEp {
static beast::string_view mime_type(beast::string_view path);
static
response create_status_response(const request& req, http::status status);
protected:
void deliver_status(tcp::socket *socket, const request& req, http::status status);
void deliver_file (tcp::socket *socket, const request& req);


Loading…
Cancel
Save