mirror of
https://gitcode.com/gitea/gitea.git
synced 2025-06-03 18:57:37 +08:00
Add direct serving of package content (#25543)
Fixes #24723 Direct serving of content aka HTTP redirect is not mentioned in any of the package registry specs but lots of official registries do that so it should be supported by the usual clients.
This commit is contained in:
@ -397,18 +397,17 @@ func DownloadPackageFile(ctx *context.Context) {
|
||||
|
||||
pf := pd.Files[0].File
|
||||
|
||||
s, _, err := packages_service.GetPackageFileStream(ctx, pf)
|
||||
s, u, _, err := packages_service.GetPackageFileStream(ctx, pf)
|
||||
if err != nil {
|
||||
apiError(ctx, http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
defer s.Close()
|
||||
|
||||
setResponseHeaders(ctx.Resp, &headers{
|
||||
Digest: pd.Files[0].Blob.HashSHA256,
|
||||
})
|
||||
|
||||
ctx.ServeContent(s, &context.ServeHeaderOptions{
|
||||
helper.ServePackageFile(ctx, s, u, pf, &context.ServeHeaderOptions{
|
||||
Filename: pf.Name,
|
||||
ContentType: "application/zip",
|
||||
LastModified: pf.CreatedUnix.AsLocalTime(),
|
||||
|
Reference in New Issue
Block a user