fix(server/files): fix Content-Disposition is not set (#46)

* fix(server/files): fix Content-Disposition is not set

* test(header): check content disposition header
This commit is contained in:
Hexxa 2021-04-21 11:38:59 +08:00 committed by GitHub
parent a9ccb4506c
commit 8b5a80f766
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 7 deletions

View file

@ -98,13 +98,21 @@ func TestFileHandlers(t *testing.T) {
})
}
fileName := path.Base(filePath)
contentDispositionHeader := res.Header.Get("Content-Disposition")
if len(errs) > 0 {
t.Error(errs)
return false
} else if res.StatusCode != 200 && res.StatusCode != 206 {
}
if res.StatusCode != 200 && res.StatusCode != 206 {
t.Error(res.StatusCode)
return false
}
if contentDispositionHeader != fmt.Sprintf(`attachment; filename="%s"`, fileName) {
t.Errorf("incorrect Content-Disposition header: %s", contentDispositionHeader)
return false
}
switch rd {
case 0:
if body != content {