From 5072bbb2cbf5b29d041629faa8367f15e4d145a2 Mon Sep 17 00:00:00 2001 From: Oleg Lobanov Date: Sat, 24 Jul 2021 15:33:54 +0200 Subject: [PATCH] fix: break resource create/update handlers on error (closes #1464) --- http/resource.go | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/http/resource.go b/http/resource.go index 8c2125ee..b4ca81cf 100644 --- a/http/resource.go +++ b/http/resource.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "io" - "io/ioutil" "net/http" "net/url" "os" @@ -96,10 +95,6 @@ func resourcePostHandler(fileCache FileCache) handleFunc { return http.StatusForbidden, nil } - defer func() { - _, _ = io.Copy(ioutil.Discard, r.Body) - }() - // Directories creation on POST. if strings.HasSuffix(r.URL.Path, "/") { err := d.user.Fs.MkdirAll(r.URL.Path, 0775) @@ -154,11 +149,6 @@ var resourcePutHandler = withUser(func(w http.ResponseWriter, r *http.Request, d return http.StatusForbidden, nil } - defer func() { - _, _ = io.Copy(ioutil.Discard, r.Body) - }() - - // Only allow PUT for files. if strings.HasSuffix(r.URL.Path, "/") { return http.StatusMethodNotAllowed, nil