mirror of
https://github.com/woodchen-ink/proxy-go.git
synced 2025-07-18 00:21:56 +08:00
添加安全头部过滤功能,优化请求头复制逻辑,确保跳过不必要的 hop-by-hop 头部和安全头部,提高安全性和性能。
This commit is contained in:
parent
775814eb24
commit
8e484f29e9
@ -497,9 +497,17 @@ func copyHeader(dst, src http.Header) {
|
||||
}
|
||||
}
|
||||
|
||||
// 使用局部 map 快速查找,跳过 hop-by-hop 头部
|
||||
// 添加需要过滤的安全头部
|
||||
securityHeaders := map[string]bool{
|
||||
"Content-Security-Policy": true,
|
||||
"Content-Security-Policy-Report-Only": true,
|
||||
"X-Content-Security-Policy": true,
|
||||
"X-WebKit-CSP": true,
|
||||
}
|
||||
|
||||
// 使用局部 map 快速查找,跳过 hop-by-hop 头部和安全头部
|
||||
for k, vv := range src {
|
||||
if !hopHeaders[k] {
|
||||
if !hopHeaders[k] && !securityHeaders[k] {
|
||||
for _, v := range vv {
|
||||
dst.Add(k, v)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user