25 lines
913 B
Go
25 lines
913 B
Go
package http
|
|
|
|
// ForwardExcludedHeaders 是本服务转发请求到上游 serverAddr 时必须剔除的请求头集合。
|
|
// key 使用 net/http.Header 的规范形式 (textproto.CanonicalMIMEHeaderKey),
|
|
// 调用方可直接用 http.Header 的 key 做查找。
|
|
//
|
|
// 包含两类:
|
|
// 1. RFC 7230 §6.1 定义的 hop-by-hop 头,不允许跨代理转发。
|
|
// 2. 本进程内部注入的控制标志,只对本进程的中间件有意义,不能让上游看见。
|
|
var ForwardExcludedHeaders = map[string]bool{
|
|
// hop-by-hop
|
|
"Connection": true,
|
|
"Keep-Alive": true,
|
|
"Proxy-Authenticate": true,
|
|
"Proxy-Authorization": true,
|
|
"Te": true,
|
|
"Trailers": true,
|
|
"Transfer-Encoding": true,
|
|
"Upgrade": true,
|
|
|
|
// 内部 DoS 防护标志,由 server.headToGet 注入,
|
|
// 仅供 templatecache / filecache 判断是否回填缓存。
|
|
"X-Origin-Head": true,
|
|
}
|