perf(proxy): optimize HTML response handling by streaming body

Replace io.ReadAll with io.Copy to stream response body directly to writer, avoiding memory allocation for large HTML content and improving performance.

lemon-mint committed Oct 31, 2025 at 13:46 UTC 66bf8b40fd9be7b7d18c4eb2280165f0ea2c7244
1 file changed +1 -7
cmd/webclient/main_js.go
+1 -7
@@ -93,14 +93,8 @@ func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
93 IsHTMLContentType(resp.Header.Get("Content-Type")) {
94 log.Debug().Msgf("HTML content received")
95
96 - body, err := io.ReadAll(resp.Body)
97 - if err != nil {
98 - w.WriteHeader(http.StatusBadGateway)
99 - w.Write([]byte("502: Failed to read response body"))
100 - return
101 - }
96 w.WriteHeader(resp.StatusCode)
103 - w.Write(body)
97 + io.Copy(w, resp.Body)
98 } else {
99 log.Debug().Msgf("Non-HTML content received")
100