diff --git a/http/raw.go b/http/raw.go index 35e474ae..b057e95e 100644 --- a/http/raw.go +++ b/http/raw.go @@ -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") } } diff --git a/http/raw_test.go b/http/raw_test.go index ec53a173..c35334f6 100644 --- a/http/raw_test.go +++ b/http/raw_test.go @@ -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) + } }) } }