diff --git a/example/config.jsonc b/example/config.jsonc index e8d17d5..fbc8d21 100644 --- a/example/config.jsonc +++ b/example/config.jsonc @@ -12,5 +12,8 @@ "forward_address": "127.0.0.1:3000", // max request size of 10MB - "max_request_size": 10000000 + "max_request_size": 10000000, + + // Timeout of 2 minutes for the proxy requests + "proxy_timeout_sec": 120 } \ No newline at end of file diff --git a/src/config/Config.hpp b/src/config/Config.hpp index 9a8b4b2..736e403 100644 --- a/src/config/Config.hpp +++ b/src/config/Config.hpp @@ -8,12 +8,13 @@ class CConfig { CConfig(); struct SConfig { - int port = 3001; - std::string forward_address = "127.0.0.1:3000"; - std::string data_dir = ""; - std::string html_dir = ""; - unsigned long int max_request_size = 10000000; // 10MB - bool git_host = false; + int port = 3001; + std::string forward_address = "127.0.0.1:3000"; + std::string data_dir = ""; + std::string html_dir = ""; + unsigned long int max_request_size = 10000000; // 10MB + bool git_host = false; + unsigned long int proxy_timeout_sec = 120; // 2 minutes } m_config; }; diff --git a/src/core/Handler.cpp b/src/core/Handler.cpp index 039227c..c870e21 100644 --- a/src/core/Handler.cpp +++ b/src/core/Handler.cpp @@ -296,7 +296,7 @@ void CServerHandler::proxyPass(const Pistache::Http::Request& req, Pistache::Htt Debug::log(LOG, "Header in: {}: {}", h->name(), req.headers().getRaw(h->name()).value()); builder.header(h); } - builder.timeout(std::chrono::milliseconds(10000)); + builder.timeout(std::chrono::seconds(g_pConfig->m_config.proxy_timeout_sec)); // TODO: implement streaming for git's large objects? @@ -329,7 +329,7 @@ void CServerHandler::proxyPass(const Pistache::Http::Request& req, Pistache::Htt response.send(Pistache::Http::Code::Internal_Server_Error, "Internal Proxy Error"); }); Pistache::Async::Barrier b(resp); - b.wait_for(std::chrono::seconds(10)); + b.wait_for(std::chrono::seconds(g_pConfig->m_config.proxy_timeout_sec)); client.shutdown(); } \ No newline at end of file