Fixed a bug where gzip spits out garbage bytes when it's disabled.
Disabled Gzip on the Control Panel Backup Page.
This commit is contained in:
parent
0d96f4efac
commit
146aa3aaad
|
@ -892,7 +892,11 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
w.Header().Set("Content-Encoding", "gzip")
|
w.Header().Set("Content-Encoding", "gzip")
|
||||||
w.Header().Set("Content-Type", "text/html")
|
w.Header().Set("Content-Type", "text/html")
|
||||||
gz := gzip.NewWriter(w)
|
gz := gzip.NewWriter(w)
|
||||||
defer gz.Close()
|
defer func() {
|
||||||
|
if w.Header().Get("Content-Encoding") == "gzip" {
|
||||||
|
gz.Close()
|
||||||
|
}
|
||||||
|
}()
|
||||||
w = gzipResponseWriter{Writer: gz, ResponseWriter: w}
|
w = gzipResponseWriter{Writer: gz, ResponseWriter: w}
|
||||||
}
|
}
|
||||||
router.routeSwitch(w, req, user, prefix, extraData)
|
router.routeSwitch(w, req, user, prefix, extraData)
|
||||||
|
@ -1421,6 +1425,12 @@ func (router *GenRouter) routeSwitch(w http.ResponseWriter, req *http.Request, u
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gzw, ok := w.(gzipResponseWriter)
|
||||||
|
if ok {
|
||||||
|
w = gzw.ResponseWriter
|
||||||
|
w.Header().Del("Content-Type")
|
||||||
|
w.Header().Del("Content-Encoding")
|
||||||
|
}
|
||||||
counters.RouteViewCounter.Bump(73)
|
counters.RouteViewCounter.Bump(73)
|
||||||
err = panel.Backups(w,req,user,extraData)
|
err = panel.Backups(w,req,user,extraData)
|
||||||
case "/panel/logs/regs/":
|
case "/panel/logs/regs/":
|
||||||
|
|
|
@ -663,7 +663,11 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
w.Header().Set("Content-Encoding", "gzip")
|
w.Header().Set("Content-Encoding", "gzip")
|
||||||
w.Header().Set("Content-Type", "text/html")
|
w.Header().Set("Content-Type", "text/html")
|
||||||
gz := gzip.NewWriter(w)
|
gz := gzip.NewWriter(w)
|
||||||
defer gz.Close()
|
defer func() {
|
||||||
|
if w.Header().Get("Content-Encoding") == "gzip" {
|
||||||
|
gz.Close()
|
||||||
|
}
|
||||||
|
}()
|
||||||
w = gzipResponseWriter{Writer: gz, ResponseWriter: w}
|
w = gzipResponseWriter{Writer: gz, ResponseWriter: w}
|
||||||
}
|
}
|
||||||
router.routeSwitch(w, req, user, prefix, extraData)
|
router.routeSwitch(w, req, user, prefix, extraData)
|
||||||
|
|
|
@ -210,7 +210,7 @@ func buildPanelRoutes() {
|
||||||
Action("routePanelGroupsEditPermsSubmit", "/panel/groups/edit/perms/submit/", "extraData"),
|
Action("routePanelGroupsEditPermsSubmit", "/panel/groups/edit/perms/submit/", "extraData"),
|
||||||
Action("routePanelGroupsCreateSubmit", "/panel/groups/create/"),
|
Action("routePanelGroupsCreateSubmit", "/panel/groups/create/"),
|
||||||
|
|
||||||
View("panel.Backups", "/panel/backups/", "extraData").Before("SuperAdminOnly"), // TODO: Tests for this
|
View("panel.Backups", "/panel/backups/", "extraData").Before("SuperAdminOnly").NoGzip(), // TODO: Tests for this
|
||||||
View("panel.LogsRegs", "/panel/logs/regs/"),
|
View("panel.LogsRegs", "/panel/logs/regs/"),
|
||||||
View("panel.LogsMod", "/panel/logs/mod/"),
|
View("panel.LogsMod", "/panel/logs/mod/"),
|
||||||
View("panel.Debug", "/panel/debug/").Before("AdminOnly"),
|
View("panel.Debug", "/panel/debug/").Before("AdminOnly"),
|
||||||
|
|
Loading…
Reference in New Issue