Skip to content

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.

skip body if not allowed by http status

Chris Lu570d2eccec32
diff --git a/weed/server/common.go b/weed/server/common.go
index 13d20d8798..ad3842190c 100644
--- a/weed/server/common.go
+++ b/weed/server/common.go
@@ -33,8 +33,21 @@ func init() {
go serverStats.Start()
}
+// bodyAllowedForStatus is a copy of http.bodyAllowedForStatus non-exported function.
+func bodyAllowedForStatus(status int) bool {
+ switch {
+ case status >= 100 && status <= 199:
+ return false
+ case status == http.StatusNoContent:
+ return false
+ case status == http.StatusNotModified:
+ return false
+ }
+ return true
+}
+
func writeJson(w http.ResponseWriter, r *http.Request, httpStatus int, obj interface{}) (err error) {
- if httpStatus == http.StatusNoContent {
+ if !bodyAllowedForStatus(httpStatus) {
return
}