1
0
Fork 0
forked from forgejo/forgejo

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

@ -77,7 +77,9 @@ func enumeratePackages(ctx *context.Context, filename string, pvs []*packages_mo
})
}
ctx.SetServeHeaders(filename + ".gz")
ctx.SetServeHeaders(&context.ServeHeaderOptions{
Filename: filename + ".gz",
})
zw := gzip.NewWriter(ctx.Resp)
defer zw.Close()
@ -115,7 +117,9 @@ func ServePackageSpecification(ctx *context.Context) {
return
}
ctx.SetServeHeaders(filename)
ctx.SetServeHeaders(&context.ServeHeaderOptions{
Filename: filename,
})
zw := zlib.NewWriter(ctx.Resp)
defer zw.Close()