live: fix writing headers in hijacked connection with gzip enabled (#32310)

This commit is contained in:
Alexander Emelin
2021-03-25 21:36:52 +03:00
committed by GitHub
parent 08dfdddefd
commit 07f7c60ae0
+11 -10
View File
@@ -10,23 +10,24 @@ import (
const resourcesPath = "/resources"
var gzipIgnoredPathPrefixes = []string{
"/api/datasources/proxy", // Ignore datasource proxy requests.
"/api/plugin-proxy/",
"/metrics",
"/live/ws", // WebSocket does not support gzip compression.
}
func Gziper() macaron.Handler {
gziperLogger := log.New("gziper")
gziper := gzip.Gziper()
return func(ctx *macaron.Context) {
requestPath := ctx.Req.URL.RequestURI()
// ignore datasource proxy requests
if strings.HasPrefix(requestPath, "/api/datasources/proxy") {
return
}
if strings.HasPrefix(requestPath, "/api/plugin-proxy/") {
return
}
if strings.HasPrefix(requestPath, "/metrics") {
return
for _, pathPrefix := range gzipIgnoredPathPrefixes {
if strings.HasPrefix(requestPath, pathPrefix) {
return
}
}
// ignore resources