From f898cd2b25c21f4877c78865bebfdb124495a7ec Mon Sep 17 00:00:00 2001 From: Marius Date: Fri, 9 Sep 2022 18:21:09 +0200 Subject: [PATCH] Revert "handler: Avoid calling WriteChunk if no data is available (#746)" This reverts commit b5cbafdbd5017d59f959f49db9b6cf92f70ac50d. See https://github.com/tus/tusd/issues/798 --- pkg/handler/unrouted_handler.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/handler/unrouted_handler.go b/pkg/handler/unrouted_handler.go index 34d3669..9103069 100644 --- a/pkg/handler/unrouted_handler.go +++ b/pkg/handler/unrouted_handler.go @@ -576,7 +576,6 @@ func (handler *UnroutedHandler) PatchFile(w http.ResponseWriter, r *http.Request info.Size = uploadLength info.SizeIsDeferred = false - } if err := handler.writeChunk(ctx, upload, info, w, r); err != nil { @@ -624,7 +623,7 @@ func (handler *UnroutedHandler) writeChunk(ctx context.Context, upload Upload, i var err error // Prevent a nil pointer dereference when accessing the body which may not be // available in the case of a malicious request. - if r.Body != nil && maxSize > 0 { + if r.Body != nil { // Limit the data read from the request's body to the allowed maximum reader := newBodyReader(io.LimitReader(r.Body, maxSize))