Skip to content

Commit

Permalink
fix: break resource create/update handlers on error (closes #1464)
Browse files Browse the repository at this point in the history
  • Loading branch information
o1egl committed Jul 24, 2021
1 parent 6b19ab6 commit 5072bbb
Showing 1 changed file with 0 additions and 10 deletions.
10 changes: 0 additions & 10 deletions http/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"os"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5072bbb

Please sign in to comment.