config: add proxy_timeout_sec

This commit is contained in:
Vaxry
2025-04-12 23:13:11 +01:00
parent 7bfb4cdb84
commit 7e348baf8c
3 changed files with 13 additions and 9 deletions

View File

@@ -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
}

View File

@@ -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;
};

View File

@@ -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<Pistache::Http::Response> b(resp);
b.wait_for(std::chrono::seconds(10));
b.wait_for(std::chrono::seconds(g_pConfig->m_config.proxy_timeout_sec));
client.shutdown();
}