Add Content-Length and Last-Modified headers to downloads

- Closes: #47
This commit is contained in:
Las Zenow 2019-06-05 11:12:23 +00:00
parent a8ac449458
commit e94938eba1

View file

@ -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)