Browse Source

const correctness. Avoid copying of the request object.

master
roker 2 years ago
parent
commit
3a45f4648d
2 changed files with 7 additions and 7 deletions
  1. +3
    -3
      webserver.cc
  2. +4
    -4
      webserver.hh

+ 3
- 3
webserver.cc View File

@ -78,7 +78,7 @@ void Webserver::remove_generic_url_handler()
}
void Webserver::deliver_status(tcp::socket *socket, Webserver::request req, http::status status)
void Webserver::deliver_status(tcp::socket *socket, 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");
@ -94,7 +94,7 @@ void Webserver::deliver_status(tcp::socket *socket, Webserver::request req, http
}
void Webserver::deliver_file(tcp::socket *socket, Webserver::request req)
void Webserver::deliver_file(tcp::socket *socket, const request& req)
{
static boost::regex file{"/([\\w\\d]{1,100}\\.[\\w\\d]{1,4})"};
boost::cmatch m;
@ -130,7 +130,7 @@ void Webserver::deliver_file(tcp::socket *socket, Webserver::request req)
}
Webserver::handler_t Webserver::find_handler(request& req, boost::cmatch& m)
Webserver::handler_t Webserver::find_handler(const request& req, boost::cmatch& m)
{
std::lock_guard< std::mutex > lock(_mtx);


+ 4
- 4
webserver.hh View File

@ -30,7 +30,7 @@ namespace pEp {
typedef boost::regex url_t;
typedef http::request< http::string_body > request;
typedef http::response< http::string_body > response;
typedef std::function< response*(boost::cmatch, request&) > handler_t;
typedef std::function< response*(boost::cmatch, const request&) > handler_t;
private:
struct Handling {
@ -68,9 +68,9 @@ namespace pEp {
static beast::string_view mime_type(beast::string_view path);
protected:
void deliver_status(tcp::socket *socket, request req, http::status status);
void deliver_file (tcp::socket *socket, request req);
handler_t find_handler(request& req, boost::cmatch& m);
void deliver_status(tcp::socket *socket, const request& req, http::status status);
void deliver_file (tcp::socket *socket, const request& req);
handler_t find_handler(const request& req, boost::cmatch& m);
// called at the beginning of a connection thread. Do nothing by default.
virtual void thread_init() {}


Loading…
Cancel
Save