diff --git a/rest/handler/cryptionhandler.go b/rest/handler/cryptionhandler.go index 93bbd889..e83132c1 100644 --- a/rest/handler/cryptionhandler.go +++ b/rest/handler/cryptionhandler.go @@ -42,7 +42,14 @@ func decryptBody(key []byte, r *http.Request) error { return errContentLengthExceeded } - content, err := ioutil.ReadAll(io.LimitReader(r.Body, maxBytes)) + var content []byte + var err error + if r.ContentLength > 0 { + content = make([]byte, r.ContentLength, r.ContentLength) + _, err = io.ReadFull(r.Body, content) + } else { + content, err = ioutil.ReadAll(io.LimitReader(r.Body, maxBytes)) + } if err != nil { return err }