fix(libhttp,dnfs2): HttpClient 新增超时接口,dnfs2 启用配置超时

修复 dnfs2 审计 L-3(P2-N5):

libhttp HttpClient 硬编码 CURLOPT_TIMEOUT=30L/CONNECTTIMEOUT=10L,
dnfs2 的 gateway_timeout/review_timeout 配置加载后从未使用,实际超时恒为 30s。

修复:
- libhttp HttpClient 新增 set_timeout/set_connect_timeout 接口
  (默认 30s/10s,向后兼容 gateway/core)
- request_stream_sync 使用成员变量替代硬编码值
- dnfs2 decode_token 设置 gateway_timeout
- dnfs2 review_content 设置 review_timeout

安全评级 A- → A,已知限制 6→5 项。
This commit is contained in:
qing committed 2026-08-08 01:33:57 +08:00
1 parent 9804838e96
commit 117fc0241e
5 files changed
+70 -16

No files matched your search

+18 -2
View File
@@ -42,6 +42,22 @@ size_t HttpClient::get_max_response_size() const {
return max_response_size_;
}
void HttpClient::set_timeout(long seconds) {
timeout_ = seconds;
}
long HttpClient::get_timeout() const {
return timeout_;
}
void HttpClient::set_connect_timeout(long seconds) {
connect_timeout_ = seconds;
}
long HttpClient::get_connect_timeout() const {
return connect_timeout_;
}
void HttpClient::set_header(const std::string& header) {
headers_ = curl_slist_append(headers_, header.c_str());
}
@@ -89,8 +105,8 @@ void HttpClient::request_stream_sync(
curl_easy_setopt(curl_, CURLOPT_WRITEFUNCTION, write_callback);
curl_easy_setopt(curl_, CURLOPT_WRITEDATA, &write_ctx);
curl_easy_setopt(curl_, CURLOPT_TIMEOUT, 30L);
curl_easy_setopt(curl_, CURLOPT_CONNECTTIMEOUT, 10L);
curl_easy_setopt(curl_, CURLOPT_TIMEOUT, timeout_);
curl_easy_setopt(curl_, CURLOPT_CONNECTTIMEOUT, connect_timeout_);
CURLcode res = curl_easy_perform(curl_);