From e94938eba1ec0ccbf5bc2161db207a6845b5c3e3 Mon Sep 17 00:00:00 2001 From: Las Zenow Date: Wed, 5 Jun 2019 11:12:23 +0000 Subject: [PATCH] Add Content-Length and Last-Modified headers to downloads - Closes: #47 --- lib/trantor.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/trantor.go b/lib/trantor.go index bcefd00..dc378cb 100644 --- a/lib/trantor.go +++ b/lib/trantor.go @@ -1,6 +1,8 @@ package trantor import ( + "time" + log "github.com/cihub/seelog" "fmt" @@ -116,6 +118,8 @@ func downloadHandler(h handler) { headers := h.w.Header() headers["Content-Type"] = []string{"application/epub+zip"} headers["Content-Disposition"] = []string{"attachment; filename=\"" + book.Title + ".epub\""} + headers["Content-Length"] = []string{fmt.Sprint(book.FileSize)} + headers["Last-Modified"] = []string{fmt.Sprint(book.UploadDate.Format(time.RFC1123))} addCacheControlHeader(h.w, false) io.Copy(h.w, f)