From fed6b92227f5d8e2adfd51283adbd129b6f8aa1b Mon Sep 17 00:00:00 2001 From: Yifu Yu Date: Sat, 2 Mar 2024 01:25:15 +0800 Subject: [PATCH] Fix: save an allocation when a stream ends. --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 0a13ed4..3f80852 100644 --- a/main.go +++ b/main.go @@ -143,11 +143,11 @@ func upstreamFiber(name string) { })() body := r.Body for { - buff := make([]byte, 65536) if ctx.viewer == 0 { fmt.Printf("No active viewers for %s, stopping reading from upstream.\n", name) break } + buff := make([]byte, 65536) n, err := body.Read(buff) if err != nil { fmt.Fprintf(os.Stderr, "Upstream for stream %s request reached EOF\n", name)