Browse Source

...

pull/1/head
Volker Birk 2 years ago
parent
commit
cb57ceae2e
1 changed files with 15 additions and 4 deletions
  1. +15
    -4
      webserver.cc

+ 15
- 4
webserver.cc View File

@ -93,20 +93,31 @@ void Webserver::do_session(tcp::socket *socket)
http::read(*socket, buffer, req, ec);
if (ec == http::error::end_of_stream)
break;
if (ec)
if (ec) {
delete socket;
return fail(ec, "reading from stream");
}
boost::cmatch m;
Webserver::response *resp = nullptr;
Webserver::response *res = nullptr;
Webserver::handler_t handler = find_handler(req, m);
if (handler) {
resp = handler(m, req);
res = handler(m, req);
}
else {
deliver_file(req.target());
}
delete resp;
if (res) {
res->prepare_payload();
http::write(*socket, *res, ec);
delete res;
if (ec) {
delete socket;
return fail(ec, "writing to stream");
}
}
}
socket->shutdown(tcp::socket::shutdown_send, ec);


Loading…
Cancel
Save