From fad25f3e11b05fadd36c8a0a7d961197d3421c43 Mon Sep 17 00:00:00 2001 From: Benson Wong Date: Fri, 31 Jan 2025 10:21:49 -0800 Subject: [PATCH] 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. --- proxy/process.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proxy/process.go b/proxy/process.go index 6ac381c..1d185bb 100644 --- a/proxy/process.go +++ b/proxy/process.go @@ -326,7 +326,7 @@ func (p *Process) ProxyRequest(w http.ResponseWriter, r *http.Request) { proxyTo := p.config.Proxy 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 { http.Error(w, err.Error(), http.StatusInternalServerError) return