1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-23 07:09:43 +02:00

Write HTTP headers before body write

This commit is contained in:
sauls8t 2019-11-08 10:40:10 +00:00
parent 7954f4b976
commit ad361c22ba
2 changed files with 2 additions and 3 deletions

View file

@ -180,6 +180,7 @@ func (h *Handler) Download(w http.ResponseWriter, r *http.Request) {
dataSize := len(a.Data)
w.WriteHeader(http.StatusOK)
w.Header().Set("Content-Type", typ)
w.Header().Set("Content-Disposition", `Attachment; filename="`+a.Filename+`" ; `+`filename*="`+a.Filename+`"`)
if dataSize != 0 {
@ -191,7 +192,6 @@ func (h *Handler) Download(w http.ResponseWriter, r *http.Request) {
h.Runtime.Log.Error("write attachment", err)
return
}
w.WriteHeader(http.StatusOK)
h.Store.Audit.Record(ctx, audit.EventTypeAttachmentDownload)
}

View file

@ -124,6 +124,7 @@ func (h *Handler) Backup(w http.ResponseWriter, r *http.Request) {
// instead of parsing 'Content-Disposition' header.
// This HTTP header is CORS white-listed.
w.Header().Set("x-documize-filename", filename)
w.WriteHeader(http.StatusOK)
// Write backup to response stream.
x, err := w.Write(bk)
@ -140,8 +141,6 @@ func (h *Handler) Backup(w http.ResponseWriter, r *http.Request) {
if !spec.Retain {
os.Remove(filename)
}
w.WriteHeader(http.StatusOK)
}
// Restore receives ZIP file for restore operation.