io-lecture: replace f.Read(...) with io.ReadAtLeast(f, ...) in http chunking solution
This commit is contained in:
parent
9f02fb6a2b
commit
ff46a72f53
1 changed files with 2 additions and 2 deletions
|
@ -40,8 +40,8 @@ func copyHandler(w http.ResponseWriter, r *http.Request) {
|
|||
defer func() { _ = f.Close() }()
|
||||
|
||||
// Infer the Content-Type of the file.
|
||||
filePrefix := make([]byte, 512)
|
||||
_, _ = f.Read(filePrefix)
|
||||
filePrefix := make([]byte, 1024)
|
||||
_, _ = io.ReadAtLeast(f, filePrefix, 512)
|
||||
contentType := http.DetectContentType(filePrefix)
|
||||
|
||||
// Get the file size.
|
||||
|
|
Loading…
Reference in a new issue