mirror of
https://github.com/openfaas/faas.git
synced 2025-06-29 18:23:26 +00:00
Fix issue in passing-through of proxy body
Proxy body was being passed correctly due to placement of defer statement. This has been moved into outer scope to resolve issue. Tested with new e2e tests in certifier component. Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
This commit is contained in:
@ -58,15 +58,18 @@ func buildUpstreamRequest(r *http.Request, url string) *http.Request {
|
|||||||
upstreamReq.Header["X-Forwarded-For"] = []string{r.RemoteAddr}
|
upstreamReq.Header["X-Forwarded-For"] = []string{r.RemoteAddr}
|
||||||
|
|
||||||
if r.Body != nil {
|
if r.Body != nil {
|
||||||
defer r.Body.Close()
|
|
||||||
upstreamReq.Body = r.Body
|
upstreamReq.Body = r.Body
|
||||||
}
|
}
|
||||||
|
|
||||||
return upstreamReq
|
return upstreamReq
|
||||||
}
|
}
|
||||||
|
|
||||||
func forwardRequest(w http.ResponseWriter, r *http.Request, proxyClient *http.Client, baseURL string, requestURL string, timeout time.Duration) (int, error) {
|
func forwardRequest(w http.ResponseWriter, r *http.Request, proxyClient *http.Client, baseURL string, requestURL string, timeout time.Duration) (int, error) {
|
||||||
|
|
||||||
upstreamReq := buildUpstreamRequest(r, baseURL+requestURL)
|
upstreamReq := buildUpstreamRequest(r, baseURL+requestURL)
|
||||||
|
if upstreamReq.Body != nil {
|
||||||
|
defer upstreamReq.Body.Close()
|
||||||
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
Reference in New Issue
Block a user