fix(admin): add User-Agent for Done-hub provider ops

- Done-hub Cookie 请求增加浏览器 User-Agent
- 覆盖认证验证和余额查询的共享请求头
- 补充请求头测试,确认 Cookie 与 User-Agent 同时发送
This commit is contained in:
AAEE86
2026-05-26 16:07:02 +08:00
parent 7e76c9763d
commit 1793443b09
+21 -1
View File
@@ -440,7 +440,21 @@ pub fn admin_provider_ops_verify_headers(
)?;
}
}
"nekocode" | "done_hub" => {
"nekocode" => {
if let Some(session_cookie) = credentials
.get("session_cookie")
.and_then(Value::as_str)
.filter(|value| !value.trim().is_empty())
{
insert_header(
&mut headers,
"Cookie",
&admin_provider_ops_session_cookie_header(session_cookie),
)?;
}
}
"done_hub" => {
insert_header(&mut headers, "User-Agent", ADMIN_PROVIDER_OPS_USER_AGENT)?;
if let Some(session_cookie) = credentials
.get("session_cookie")
.and_then(Value::as_str)
@@ -1005,6 +1019,12 @@ mod tests {
headers.get(COOKIE).and_then(|value| value.to_str().ok()),
Some("session=abc")
);
assert_eq!(
headers
.get(USER_AGENT)
.and_then(|value| value.to_str().ok()),
Some(ADMIN_PROVIDER_OPS_USER_AGENT)
);
}
#[test]