void HttpServer::destroy(ConnectionPtr connection, bool release) { connection->markToBeDeleted(); { std::lock_guard<std::mutex> lock(connections_mutex_); auto it = std::find_if(std::begin(connections_), std::end(connections_), [&](ConnectionPtr conn) { return connection == conn; }); if (it == std::end(connections_)) { return; } else { --connection_count_; connections_.erase(it); } } if (release) { connection->disown(); HTTP::Connection::release(connection); } }
void HttpServer::connection_notify_request(ConnectionPtr connection, HTTP::Request&& request) { if (sink_) { connection->disown(); sink_(connection, std::forward<HTTP::Request>(request)); } else { connection->response().setCode(HTTP::HttpCode::NoContent).setBody(""); HTTP::setShouldConnectionBeClosed(request, connection->response()); connection->sendResponse(); } }