fup: fix minor issue with shorter-than-512 byte file uploads
Reader.Read is permitted to return EOF on short reads, which had not been anticipated by this code. There's probably more instances of this lurking...
This commit is contained in:
parent
a9a437cee4
commit
b4e785af8a
1 changed files with 1 additions and 1 deletions
|
@ -174,7 +174,7 @@ func (a *Application) upload(rw http.ResponseWriter, r *http.Request) {
|
|||
if mimeType == "" {
|
||||
// We'll need to sniff it...
|
||||
buf := make([]byte, 512)
|
||||
if _, err := r.Body.Read(buf); err != nil {
|
||||
if _, err := r.Body.Read(buf); err != nil && !errors.Is(err, io.EOF) {
|
||||
log.Printf("upload: Read for MIME sniffing: %v", err)
|
||||
a.internalError(rw, r)
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue