mirror of
https://github.com/go-gost/x.git
synced 2026-10-19 16:16:32 +00:00
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:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user