Skip to content

Commit

Permalink
Redirect proxy requests for only GET & HEAD methods
Browse files Browse the repository at this point in the history
  • Loading branch information
heyste committed Aug 19, 2021
1 parent 7413f44 commit 5787c1e
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ func (h *UpgradeAwareHandler) ServeHTTP(w http.ResponseWriter, req *http.Request

loc := *h.Location
loc.RawQuery = req.URL.RawQuery
method := req.Method

// If original request URL ended in '/', append a '/' at the end of the
// of the proxy URL
Expand All @@ -213,7 +214,7 @@ func (h *UpgradeAwareHandler) ServeHTTP(w http.ResponseWriter, req *http.Request
// Redirect requests with an empty path to a location that ends with a '/'
// This is essentially a hack for http://issue.k8s.io/4958.
// Note: Keep this code after tryUpgrade to not break that flow.
if len(loc.Path) == 0 {
if len(loc.Path) == 0 && (method == http.MethodGet || method == http.MethodHead) {
var queryPart string
if len(req.URL.RawQuery) > 0 {
queryPart = "?" + req.URL.RawQuery
Expand Down

0 comments on commit 5787c1e

Please sign in to comment.