mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
skip body if not allowed by http status
This commit is contained in:
parent
605c39ced7
commit
570d2eccec
|
@ -33,8 +33,21 @@ func init() {
|
||||||
go serverStats.Start()
|
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) {
|
func writeJson(w http.ResponseWriter, r *http.Request, httpStatus int, obj interface{}) (err error) {
|
||||||
if httpStatus == http.StatusNoContent {
|
if !bodyAllowedForStatus(httpStatus) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue