From 141ce67c097565d085cf1ffaefd6aeb9e9e7db77 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 30 Nov 2020 02:45:00 -0800 Subject: [PATCH] close http request body --- weed/server/filer_server_handlers_write.go | 1 + weed/util/http_util.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/weed/server/filer_server_handlers_write.go b/weed/server/filer_server_handlers_write.go index 09a8e3626..c2d92f8ba 100644 --- a/weed/server/filer_server_handlers_write.go +++ b/weed/server/filer_server_handlers_write.go @@ -66,6 +66,7 @@ func (fs *FilerServer) PostHandler(w http.ResponseWriter, r *http.Request) { ) fs.autoChunk(ctx, w, r, so) + util.CloseRequest(r) } diff --git a/weed/util/http_util.go b/weed/util/http_util.go index 7851d8293..2cd69b01b 100644 --- a/weed/util/http_util.go +++ b/weed/util/http_util.go @@ -374,3 +374,8 @@ func CloseResponse(resp *http.Response) { io.Copy(ioutil.Discard, resp.Body) resp.Body.Close() } + +func CloseRequest(req *http.Request) { + io.Copy(ioutil.Discard, req.Body) + req.Body.Close() +}