Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

Added the io package to reuse http clients for http pooling

Akshay Dashrath5eaf5d42831a
diff --git a/internal/orchestrator/proxy.go b/internal/orchestrator/proxy.go
index 8cab0311..8f73b664 100644
--- a/internal/orchestrator/proxy.go
+++ b/internal/orchestrator/proxy.go
@@ -2,6 +2,7 @@ package orchestrator
import (
"fmt"
+ "io"
"net"
"net/http"
"net/url"
@@ -130,7 +131,7 @@ func (o *Orchestrator) proxyToURL(w http.ResponseWriter, r *http.Request, target
}
w.WriteHeader(resp.StatusCode)
- _, _ = w.Write(readResponseBody(resp))
+ _, _ = io.Copy(w, resp.Body)
}
// findRunningInstanceByTabID finds the instance that owns the given tab.
@@ -181,24 +182,6 @@ func (o *Orchestrator) handleProxyScreencast(w http.ResponseWriter, r *http.Requ
handlers.ProxyWebSocket(w, r, targetURL)
}
-func readResponseBody(resp *http.Response) []byte {
- if resp.Body == nil {
- return []byte{}
- }
- body := make([]byte, 0)
- buf := make([]byte, 4096)
- for {
- n, err := resp.Body.Read(buf)
- if n > 0 {
- body = append(body, buf[:n]...)
- }
- if err != nil {
- break
- }
- }
- return body
-}
-
// classifyLaunchError returns appropriate HTTP status code for launch errors.
func classifyLaunchError(err error) int {
msg := err.Error()