From df9c7594c79ca657edff8af604805190cf797eb0 Mon Sep 17 00:00:00 2001 From: WithoutPants <53250216+WithoutPants@users.noreply.github.com> Date: Wed, 14 Sep 2022 14:20:53 +1000 Subject: [PATCH] Disable http2 and fix https detection (#2900) --- internal/api/server.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/internal/api/server.go b/internal/api/server.go index 646f647d6..1029fb8a7 100644 --- a/internal/api/server.go +++ b/internal/api/server.go @@ -278,6 +278,11 @@ func Start() error { Addr: address, Handler: r, TLSConfig: tlsConfig, + // disable http/2 support by default + // when http/2 is enabled, we are unable to hijack and close + // the connection/request. This is necessary to stop running + // streams when deleting a scene file. + TLSNextProto: make(map[string]func(*http.Server, *tls.Conn, http.Handler)), } printVersion() @@ -401,11 +406,9 @@ func BaseURLMiddleware(next http.Handler) http.Handler { fn := func(w http.ResponseWriter, r *http.Request) { ctx := r.Context() - var scheme string - if strings.Compare("https", r.URL.Scheme) == 0 || r.Proto == "HTTP/2.0" || r.Header.Get("X-Forwarded-Proto") == "https" { + scheme := "http" + if r.TLS != nil { scheme = "https" - } else { - scheme = "http" } prefix := getProxyPrefix(r.Header)