Use client request context in proxy request (#43)

Canceled or closed HTTP requests from clients will also stop the proxied
HTTP requests to upstreamed servers.
This commit is contained in:
Benson Wong
2025-01-31 10:21:49 -08:00
parent 2c3e3e27f7
commit fad25f3e11

View File

@@ -326,7 +326,7 @@ func (p *Process) ProxyRequest(w http.ResponseWriter, r *http.Request) {
proxyTo := p.config.Proxy proxyTo := p.config.Proxy
client := &http.Client{} client := &http.Client{}
req, err := http.NewRequest(r.Method, proxyTo+r.URL.String(), r.Body) req, err := http.NewRequestWithContext(r.Context(), r.Method, proxyTo+r.URL.String(), r.Body)
if err != nil { if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
return return