Skip to content

Commit

Permalink
fix upgrade requests by placing query string in request body (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmorganca committed Aug 6, 2021
1 parent e2823be commit 9c833a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/cmd/client.go
Expand Up @@ -113,6 +113,10 @@ func RunLocalClient() error {

timer.Reset(ClientTimeoutDuration)

if r.Header.Get("Upgrade") != "" {
r.Header.Add("X-Infra-Query", r.URL.RawQuery)
}

r.Header.Add("X-Infra-Authorization", r.Header.Get("Authorization"))
r.Header.Set("Authorization", "Bearer "+saToken)

Expand Down
6 changes: 6 additions & 0 deletions internal/engine/engine.go
Expand Up @@ -176,6 +176,12 @@ func proxyHandler(ca []byte, bearerToken string, remote *url.URL) (http.HandlerF
}

return func(w http.ResponseWriter, r *http.Request) {
// Sometimes the kubernetes proxy strips query string for Upgrade requests
// so we need to put that in the request body
if r.Header.Get("X-Infra-Query") != "" {
r.URL.RawQuery = r.Header.Get("X-Infra-Query")
}

email, ok := r.Context().Value(HttpContextKeyEmail{}).(string)
if !ok {
logging.L.Debug("Proxy handler unable to retrieve email from context")
Expand Down

0 comments on commit 9c833a7

Please sign in to comment.