mirror of
https://github.com/filebrowser/filebrowser.git
synced 2026-07-17 16:36:49 +00:00
fix: force octet-stream for attachment downloads (#5942)
This commit is contained in:
parent
f5e0c4e2e1
commit
103acd15fe
2 changed files with 9 additions and 0 deletions
|
|
@ -77,6 +77,7 @@ func setContentDisposition(w http.ResponseWriter, r *http.Request, file *files.F
|
|||
} else {
|
||||
// As per RFC6266 section 4.3
|
||||
w.Header().Set("Content-Disposition", "attachment; filename*=utf-8''"+url.PathEscape(file.Name))
|
||||
w.Header().Set("Content-Type", "application/octet-stream")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -70,6 +70,14 @@ func TestSetContentDisposition(t *testing.T) {
|
|||
if got != tc.expected {
|
||||
t.Errorf("Content-Disposition = %q, want %q", got, tc.expected)
|
||||
}
|
||||
|
||||
contentType := recorder.Header().Get("Content-Type")
|
||||
if tc.inline && contentType != "" {
|
||||
t.Errorf("Content-Type = %q, want empty", contentType)
|
||||
}
|
||||
if !tc.inline && contentType != "application/octet-stream" {
|
||||
t.Errorf("Content-Type = %q, want application/octet-stream", contentType)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue