From cb2c52216dc28db745d9bd0028267611aa9cfabe Mon Sep 17 00:00:00 2001
From: ave <ave@ave.zone>
Date: Thu, 21 Sep 2023 12:24:27 +0200
Subject: [PATCH] Implement Content-Length

---
 server_apps.go   | 2 ++
 server_mirror.go | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/server_apps.go b/server_apps.go
index b8359c2..a9d76f0 100644
--- a/server_apps.go
+++ b/server_apps.go
@@ -16,6 +16,7 @@ import (
 	"path"
 	"regexp"
 	"strings"
+	"strconv"
 	"time"
 
 	"github.com/go-git/go-git/v5"
@@ -705,6 +706,7 @@ func (s *server) handleAppTargz(w http.ResponseWriter, r *http.Request) {
 	for _, app := range apps {
 		if app.repository == fmt.Sprintf("%s/%s", orga, repo) {
 			w.Header().Add("Content-Type", "application/x-gzip")
+			w.Header().Add("Content-Length", strconv.Itoa(len(app.appInfo.targz)))
 			w.Write(app.appInfo.targz)
 			return
 		}
diff --git a/server_mirror.go b/server_mirror.go
index 2f514e2..a37ff1f 100644
--- a/server_mirror.go
+++ b/server_mirror.go
@@ -10,6 +10,7 @@ import (
 	"net/http"
 	"regexp"
 	"strings"
+	"strconv"
 )
 
 func (s *server) cacheTarball(rel *GLRelease, data io.Reader) error {
@@ -49,6 +50,7 @@ func (s *server) serveMirroredFile(w http.ResponseWriter, r *http.Request, rel *
 		b := s.cache[rel.TagName][artifact]
 		s.cacheMu.RUnlock()
 		w.Header().Add("Content-Type", "application/octet-stream")
+		w.Header().Add("Content-Length", strconv.Itoa(len(b)))
 		w.Write(b)
 		return
 	}
@@ -103,6 +105,7 @@ func (s *server) serveMirroredFile(w http.ResponseWriter, r *http.Request, rel *
 		b := s.cache[rel.TagName][artifact]
 		s.cacheMu.RUnlock()
 		w.Header().Add("Content-Type", "application/octet-stream")
+		w.Header().Add("Content-Length", strconv.Itoa(len(b)))
 		w.Write(b)
 		return
 	}
-- 
GitLab