aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2021-08-18 00:56:35 -0700
committerChris Lu <chris.lu@gmail.com>2021-08-18 00:56:35 -0700
commit570d2eccec32d3ec9dfc63ec1688bff27eb7d9e1 (patch)
treed1292cdd2107f4b08ffedf38ebb21d8f5594ff59
parent605c39ced7a99554693f53ba372ee53a313b99f2 (diff)
downloadseaweedfs-570d2eccec32d3ec9dfc63ec1688bff27eb7d9e1.tar.xz
seaweedfs-570d2eccec32d3ec9dfc63ec1688bff27eb7d9e1.zip
skip body if not allowed by http status
-rw-r--r--weed/server/common.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/weed/server/common.go b/weed/server/common.go
index 13d20d879..ad3842190 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
}