Fix setting HTTP headers after write (#21833)

The headers can't be modified after it was send to the client.
This commit is contained in:
KN4CK3R 2022-11-17 18:55:15 +01:00 committed by GitHub
parent c144942b23
commit 43ab9324c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 72 additions and 58 deletions

View file

@ -604,7 +604,10 @@ func RegisterRoutes(m *web.Route) {
m.Group("", func() {
m.Get("/favicon.ico", func(ctx *context.Context) {
ctx.ServeFile(path.Join(setting.StaticRootPath, "public/img/favicon.png"))
ctx.SetServeHeaders(&context.ServeHeaderOptions{
Filename: "favicon.png",
})
http.ServeFile(ctx.Resp, ctx.Req, path.Join(setting.StaticRootPath, "public/img/favicon.png"))
})
m.Group("/{username}", func() {
m.Get(".png", func(ctx *context.Context) { ctx.Error(http.StatusNotFound) })