Skip to content

Commit

Permalink
Fix forwarding of request body during text streaming
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
  • Loading branch information
alexellis committed Jan 11, 2024
1 parent b4254fe commit 2d000d3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ func NewHandlerFunc(config types.FaaSConfig, resolver BaseURLResolver, verbose b
reverseProxy := httputil.ReverseProxy{}
reverseProxy.Director = func(req *http.Request) {
// At least an empty director is required to prevent runtime errors.
req.URL.Scheme = "http"
}
reverseProxy.ErrorHandler = func(w http.ResponseWriter, r *http.Request, err error) {
}

// Errors are common during disconnect of client, no need to log them.
Expand Down Expand Up @@ -187,7 +190,9 @@ func proxyRequest(w http.ResponseWriter, originalReq *http.Request, proxyClient
}

if v := originalReq.Header.Get("Accept"); v == "text/event-stream" {
reverseProxy.ServeHTTP(w, proxyReq)
originalReq.URL = proxyReq.URL

reverseProxy.ServeHTTP(w, originalReq)
return
}

Expand Down

0 comments on commit 2d000d3

Please sign in to comment.