fix(http): set Proxy-Agent header after authenticate to avoid leak #42

This commit is contained in:
wzxjohn
2025-01-29 23:06:09 +08:00
committed by ginuerzh
parent e4b1c3c2b5
commit 11bca5bc3d
+8 -3
View File
@@ -254,9 +254,6 @@ func (h *httpHandler) handleRequest(ctx context.Context, conn net.Conn, req *htt
if resp.Header == nil {
resp.Header = http.Header{}
}
if resp.Header.Get("Proxy-Agent") == "" {
resp.Header.Set("Proxy-Agent", h.md.proxyAgent)
}
ro.HTTP = &xrecorder.HTTPRecorderObject{
Host: req.Host,
@@ -290,6 +287,14 @@ func (h *httpHandler) handleRequest(ctx context.Context, conn net.Conn, req *htt
if !ok {
return errors.New("authentication failed")
}
if resp.Header == nil {
resp.Header = http.Header{}
}
if resp.Header.Get("Proxy-Agent") == "" {
resp.Header.Set("Proxy-Agent", h.md.proxyAgent)
}
ctx = ctxvalue.ContextWithClientID(ctx, ctxvalue.ClientID(clientID))
if h.options.Bypass != nil &&