From 163faf569a1c2e945e41044b3053bd0d12eddf82 Mon Sep 17 00:00:00 2001 From: Andrea Spacca Date: Sat, 7 Jul 2018 09:55:46 +0200 Subject: [PATCH] Handle empty upload --- server/handlers.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/handlers.go b/server/handlers.go index 6415edd..2d06eed 100644 --- a/server/handlers.go +++ b/server/handlers.go @@ -397,6 +397,12 @@ func (s *Server) putHandler(w http.ResponseWriter, r *http.Request) { contentLength = n } + if contentLength == 0 { + log.Print("Empty content-length") + http.Error(w, errors.New("Could not uplpoad empty file").Error(), 400) + return + } + contentType := r.Header.Get("Content-Type") if contentType == "" {