[lectures] Fix content type detection.

This commit is contained in:
Arseny Balobanov 2022-04-21 21:38:22 +03:00
parent 9944c84b9d
commit 49be410e05

View file

@ -39,8 +39,7 @@ func copyHandler(w http.ResponseWriter, r *http.Request) {
defer func() { _ = f.Close() }()
// Infer the Content-Type of the file.
filePrefix := make([]byte, 1024)
_, _ = io.ReadAtLeast(f, filePrefix, 512)
filePrefix, _ := io.ReadAll(io.LimitReader(f, 512))
contentType := http.DetectContentType(filePrefix)
// Get the file size.