aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/packages/generic
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2023-07-03 15:33:28 +0200
committerGitHub <noreply@github.com>2023-07-03 15:33:28 +0200
commitc890454769562e0ec2978e123aaf3d9a43e5ef4f (patch)
treea152b5a0356a3da4f83083c5e7fc87214f8bd251 /routers/api/packages/generic
parentf1cb461c1fb23b68ae34ada2de6bad3bfa6ceeca (diff)
downloadgitea-c890454769562e0ec2978e123aaf3d9a43e5ef4f.tar.gz
gitea-c890454769562e0ec2978e123aaf3d9a43e5ef4f.zip
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.
Diffstat (limited to 'routers/api/packages/generic')
-rw-r--r--routers/api/packages/generic/generic.go8
1 files changed, 2 insertions, 6 deletions
diff --git a/routers/api/packages/generic/generic.go b/routers/api/packages/generic/generic.go
index 0c873119ef..7cd1d1a5be 100644
--- a/routers/api/packages/generic/generic.go
+++ b/routers/api/packages/generic/generic.go
@@ -30,7 +30,7 @@ func apiError(ctx *context.Context, status int, obj interface{}) {
// DownloadPackageFile serves the specific generic package.
func DownloadPackageFile(ctx *context.Context) {
- s, pf, err := packages_service.GetFileStreamByPackageNameAndVersion(
+ s, u, pf, err := packages_service.GetFileStreamByPackageNameAndVersion(
ctx,
&packages_service.PackageInfo{
Owner: ctx.Package.Owner,
@@ -50,12 +50,8 @@ func DownloadPackageFile(ctx *context.Context) {
apiError(ctx, http.StatusInternalServerError, err)
return
}
- defer s.Close()
- ctx.ServeContent(s, &context.ServeHeaderOptions{
- Filename: pf.Name,
- LastModified: pf.CreatedUnix.AsLocalTime(),
- })
+ helper.ServePackageFile(ctx, s, u, pf)
}
// UploadPackage uploads the specific generic package.