Skip to content
Snippets Groups Projects
Commit cb2c5221 authored by ave's avatar ave
Browse files

Implement Content-Length

parent 21419e02
No related branches found
No related tags found
No related merge requests found
...@@ -16,6 +16,7 @@ import ( ...@@ -16,6 +16,7 @@ import (
"path" "path"
"regexp" "regexp"
"strings" "strings"
"strconv"
"time" "time"
"github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5"
...@@ -705,6 +706,7 @@ func (s *server) handleAppTargz(w http.ResponseWriter, r *http.Request) { ...@@ -705,6 +706,7 @@ func (s *server) handleAppTargz(w http.ResponseWriter, r *http.Request) {
for _, app := range apps { for _, app := range apps {
if app.repository == fmt.Sprintf("%s/%s", orga, repo) { if app.repository == fmt.Sprintf("%s/%s", orga, repo) {
w.Header().Add("Content-Type", "application/x-gzip") w.Header().Add("Content-Type", "application/x-gzip")
w.Header().Add("Content-Length", strconv.Itoa(len(app.appInfo.targz)))
w.Write(app.appInfo.targz) w.Write(app.appInfo.targz)
return return
} }
......
...@@ -10,6 +10,7 @@ import ( ...@@ -10,6 +10,7 @@ import (
"net/http" "net/http"
"regexp" "regexp"
"strings" "strings"
"strconv"
) )
func (s *server) cacheTarball(rel *GLRelease, data io.Reader) error { 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 * ...@@ -49,6 +50,7 @@ func (s *server) serveMirroredFile(w http.ResponseWriter, r *http.Request, rel *
b := s.cache[rel.TagName][artifact] b := s.cache[rel.TagName][artifact]
s.cacheMu.RUnlock() s.cacheMu.RUnlock()
w.Header().Add("Content-Type", "application/octet-stream") w.Header().Add("Content-Type", "application/octet-stream")
w.Header().Add("Content-Length", strconv.Itoa(len(b)))
w.Write(b) w.Write(b)
return return
} }
...@@ -103,6 +105,7 @@ func (s *server) serveMirroredFile(w http.ResponseWriter, r *http.Request, rel * ...@@ -103,6 +105,7 @@ func (s *server) serveMirroredFile(w http.ResponseWriter, r *http.Request, rel *
b := s.cache[rel.TagName][artifact] b := s.cache[rel.TagName][artifact]
s.cacheMu.RUnlock() s.cacheMu.RUnlock()
w.Header().Add("Content-Type", "application/octet-stream") w.Header().Add("Content-Type", "application/octet-stream")
w.Header().Add("Content-Length", strconv.Itoa(len(b)))
w.Write(b) w.Write(b)
return return
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment