SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
http exhaust and close response body
Chris Lue85048bcdc7a
diff --git a/weed/operation/chunked_file.go b/weed/operation/chunked_file.goindex f3f6e7b00b..995f06b53d 100644--- a/weed/operation/chunked_file.go+++ b/weed/operation/chunked_file.go@@ -6,6 +6,7 @@ import ("fmt""google.golang.org/grpc""io"+ "io/ioutil""net/http""sort"@@ -103,7 +104,10 @@ func readChunkNeedle(fileUrl string, w io.Writer, offset int64) (written int64,if err != nil {return written, err}- defer resp.Body.Close()+ defer func() {+ io.Copy(ioutil.Discard, resp.Body)+ resp.Body.Close()+ }()switch resp.StatusCode {case http.StatusRequestedRangeNotSatisfiable:diff --git a/weed/server/filer_server_handlers_read.go b/weed/server/filer_server_handlers_read.goindex 63fd2cc39a..9ddf4dae59 100644--- a/weed/server/filer_server_handlers_read.go+++ b/weed/server/filer_server_handlers_read.go@@ -3,6 +3,7 @@ package weed_serverimport ("context""io"+ "io/ioutil""mime""mime/multipart""net/http"@@ -107,7 +108,10 @@ func (fs *FilerServer) handleSingleChunk(w http.ResponseWriter, r *http.Request,writeJsonError(w, r, http.StatusInternalServerError, do_err)return}- defer resp.Body.Close()+ defer func() {+ io.Copy(ioutil.Discard, resp.Body)+ resp.Body.Close()+ }()for k, v := range resp.Header {w.Header()[k] = v}diff --git a/weed/server/filer_server_handlers_write.go b/weed/server/filer_server_handlers_write.goindex cb30ff4c07..92f5f19b69 100644--- a/weed/server/filer_server_handlers_write.go+++ b/weed/server/filer_server_handlers_write.go@@ -4,6 +4,7 @@ import ("context""encoding/json""errors"+ "io""io/ioutil""mime""net/http"@@ -131,7 +132,10 @@ func (fs *FilerServer) PostHandler(w http.ResponseWriter, r *http.Request) {writeJsonError(w, r, http.StatusInternalServerError, do_err)return}- defer resp.Body.Close()+ defer func() {+ io.Copy(ioutil.Discard, resp.Body)+ resp.Body.Close()+ }()etag := resp.Header.Get("ETag")resp_body, ra_err := ioutil.ReadAll(resp.Body)if ra_err != nil {