fix: prevent double-recording when HTTP response cache is enabled

The cache-hit path (serveCachedResponse) recorded on the same HandlerRecorderObject
as the calling handler's deferred Record(), producing two records per request.
Copy ro at HandleHTTP entry so the sniffer's internal recording stays isolated
from the caller's defer. Also zero ro.Time when the sniffer takes over, so the
handler's defer Record() skips the now-redundant connection-level record.

Fixes 10 files across sniffer and all 8 handlers that support sniffed HTTP forwarding.
This commit is contained in:
ginuerzh
2026-07-26 20:11:36 +08:00
parent db3c7a375c
commit 486a77665d
10 changed files with 25 additions and 0 deletions
+1
View File
@@ -227,6 +227,7 @@ func (h *redirectHandler) Handle(ctx context.Context, conn net.Conn, opts ...han
conn = xnet.NewReadWriteConn(br, conn, conn)
switch proto {
case sniffing.ProtoHTTP:
ro.Time = time.Time{}
return sniffer.HandleHTTP(ctx, "tcp", conn,
sniffing.WithService(h.options.Service),
sniffing.WithDial(dial),