mirror of
https://github.com/woodchen-ink/proxy-go.git
synced 2025-07-18 00:21:56 +08:00
优化代理响应头设置,将"Proxy-Go-Cache"和"Proxy-Go-AltTarget"的值调整为更具语义的格式,以提高可读性和一致性。
This commit is contained in:
parent
18a22e2792
commit
6bdcaf6f83
@ -125,7 +125,7 @@ func (h *MirrorProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
if item.ContentEncoding != "" {
|
||||
w.Header().Set("Content-Encoding", item.ContentEncoding)
|
||||
}
|
||||
w.Header().Set("Proxy-Go-Cache", "HIT")
|
||||
w.Header().Set("Proxy-Go-Cache-HIT", "1")
|
||||
if notModified {
|
||||
w.WriteHeader(http.StatusNotModified)
|
||||
return
|
||||
@ -149,7 +149,7 @@ func (h *MirrorProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// 复制响应头
|
||||
copyHeader(w.Header(), resp.Header)
|
||||
w.Header().Set("Proxy-Go-Cache", "MISS")
|
||||
w.Header().Set("Proxy-Go-Cache-HIT", "0")
|
||||
|
||||
// 设置状态码
|
||||
w.WriteHeader(resp.StatusCode)
|
||||
|
@ -350,12 +350,13 @@ func (h *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
if item.ContentEncoding != "" {
|
||||
w.Header().Set("Content-Encoding", item.ContentEncoding)
|
||||
}
|
||||
w.Header().Set("Proxy-Go-Cache", "HIT")
|
||||
w.Header().Set("Proxy-Go-Cache-HIT", "1")
|
||||
|
||||
// 如果使用了扩展名映射的备用目标,添加标记响应头
|
||||
if usedAltTarget {
|
||||
w.Header().Set("Proxy-Go-AltTarget", "true")
|
||||
w.Header().Set("Proxy-Go-AltTarget", "1")
|
||||
}
|
||||
w.Header().Set("Proxy-Go-AltTarget", "0")
|
||||
|
||||
if notModified {
|
||||
w.WriteHeader(http.StatusNotModified)
|
||||
@ -383,12 +384,13 @@ func (h *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// 复制响应头
|
||||
copyHeader(w.Header(), resp.Header)
|
||||
w.Header().Set("Proxy-Go-Cache", "MISS")
|
||||
w.Header().Set("Proxy-Go-Cache-HIT", "0")
|
||||
|
||||
// 如果使用了扩展名映射的备用目标,添加标记响应头
|
||||
if usedAltTarget {
|
||||
w.Header().Set("Proxy-Go-AltTarget", "true")
|
||||
w.Header().Set("Proxy-Go-AltTarget", "1")
|
||||
}
|
||||
w.Header().Set("Proxy-Go-AltTarget", "0")
|
||||
|
||||
// 设置响应状态码
|
||||
w.WriteHeader(resp.StatusCode)
|
||||
|
Loading…
x
Reference in New Issue
Block a user