config: add proxy_timeout_sec
This commit is contained in:
@@ -12,5 +12,8 @@
|
|||||||
"forward_address": "127.0.0.1:3000",
|
"forward_address": "127.0.0.1:3000",
|
||||||
|
|
||||||
// max request size of 10MB
|
// 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
|
||||||
}
|
}
|
||||||
@@ -8,12 +8,13 @@ class CConfig {
|
|||||||
CConfig();
|
CConfig();
|
||||||
|
|
||||||
struct SConfig {
|
struct SConfig {
|
||||||
int port = 3001;
|
int port = 3001;
|
||||||
std::string forward_address = "127.0.0.1:3000";
|
std::string forward_address = "127.0.0.1:3000";
|
||||||
std::string data_dir = "";
|
std::string data_dir = "";
|
||||||
std::string html_dir = "";
|
std::string html_dir = "";
|
||||||
unsigned long int max_request_size = 10000000; // 10MB
|
unsigned long int max_request_size = 10000000; // 10MB
|
||||||
bool git_host = false;
|
bool git_host = false;
|
||||||
|
unsigned long int proxy_timeout_sec = 120; // 2 minutes
|
||||||
} m_config;
|
} m_config;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -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());
|
Debug::log(LOG, "Header in: {}: {}", h->name(), req.headers().getRaw(h->name()).value());
|
||||||
builder.header(h);
|
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?
|
// 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");
|
response.send(Pistache::Http::Code::Internal_Server_Error, "Internal Proxy Error");
|
||||||
});
|
});
|
||||||
Pistache::Async::Barrier<Pistache::Http::Response> b(resp);
|
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();
|
client.shutdown();
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user