Make sure to always provide a MIME type.

This commit is contained in:
Solderpunk 2020-06-04 23:12:09 +02:00
parent a16a5fac12
commit 532dd83414
1 changed files with 5 additions and 0 deletions

View File

@ -190,6 +190,11 @@ func serveFile(path string, log LogEntry, conn net.Conn) {
} else {
mimeType = mime.TypeByExtension(ext)
}
// Set a generic MIME type if the extension wasn't recognised
if mimeType == "" {
mimeType = "application/octet-stream"
}
contents, err := ioutil.ReadFile(path)
if err != nil {
conn.Write([]byte("50 Error!\r\n"))