Add Content-Length and Last-Modified headers to downloads
- Closes: #47
This commit is contained in:
parent
a8ac449458
commit
e94938eba1
1 changed files with 4 additions and 0 deletions
|
@ -1,6 +1,8 @@
|
||||||
package trantor
|
package trantor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
log "github.com/cihub/seelog"
|
log "github.com/cihub/seelog"
|
||||||
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -116,6 +118,8 @@ func downloadHandler(h handler) {
|
||||||
headers := h.w.Header()
|
headers := h.w.Header()
|
||||||
headers["Content-Type"] = []string{"application/epub+zip"}
|
headers["Content-Type"] = []string{"application/epub+zip"}
|
||||||
headers["Content-Disposition"] = []string{"attachment; filename=\"" + book.Title + ".epub\""}
|
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)
|
addCacheControlHeader(h.w, false)
|
||||||
|
|
||||||
io.Copy(h.w, f)
|
io.Copy(h.w, f)
|
||||||
|
|
Reference in a new issue