fix: resolve undefined variable 'svr' compilation error (#17348)

This commit is contained in:
o7si
2025-11-18 16:10:47 +08:00
committed by GitHub
parent ffa277a54c
commit 97cb3fd5ae

View File

@@ -46,25 +46,26 @@ bool server_http_context::init(const common_params & params) {
port = params.port; port = params.port;
hostname = params.hostname; hostname = params.hostname;
auto & srv = pimpl->srv;
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT #ifdef CPPHTTPLIB_OPENSSL_SUPPORT
if (params.ssl_file_key != "" && params.ssl_file_cert != "") { if (params.ssl_file_key != "" && params.ssl_file_cert != "") {
LOG_INF("Running with SSL: key = %s, cert = %s\n", params.ssl_file_key.c_str(), params.ssl_file_cert.c_str()); LOG_INF("Running with SSL: key = %s, cert = %s\n", params.ssl_file_key.c_str(), params.ssl_file_cert.c_str());
svr.reset( srv.reset(
new httplib::SSLServer(params.ssl_file_cert.c_str(), params.ssl_file_key.c_str()) new httplib::SSLServer(params.ssl_file_cert.c_str(), params.ssl_file_key.c_str())
); );
} else { } else {
LOG_INF("Running without SSL\n"); LOG_INF("Running without SSL\n");
svr.reset(new httplib::Server()); srv.reset(new httplib::Server());
} }
#else #else
if (params.ssl_file_key != "" && params.ssl_file_cert != "") { if (params.ssl_file_key != "" && params.ssl_file_cert != "") {
LOG_ERR("Server is built without SSL support\n"); LOG_ERR("Server is built without SSL support\n");
return false; return false;
} }
pimpl->srv.reset(new httplib::Server()); srv.reset(new httplib::Server());
#endif #endif
auto & srv = pimpl->srv;
srv->set_default_headers({{"Server", "llama.cpp"}}); srv->set_default_headers({{"Server", "llama.cpp"}});
srv->set_logger(log_server_request); srv->set_logger(log_server_request);
srv->set_exception_handler([](const httplib::Request &, httplib::Response & res, const std::exception_ptr & ep) { srv->set_exception_handler([](const httplib::Request &, httplib::Response & res, const std::exception_ptr & ep) {