parse body only if content length > 0

This commit is contained in:
kevin 2020-08-12 14:37:34 +08:00 committed by kingxt
parent 05c8dd0b9c
commit a26fc2b672
2 changed files with 6 additions and 2 deletions

View File

@ -34,7 +34,11 @@ func Parse(r *http.Request, v interface{}) error {
return err return err
} }
return ParseJsonBody(r, v) if r.ContentLength > 0 {
return ParseJsonBody(r, v)
}
return nil
} }
// Parses the form request. // Parses the form request.

View File

@ -20,4 +20,4 @@ const (
CodeSignatureInvalidToken CodeSignatureInvalidToken
) )
var ErrBodylessRequest = errors.New("not a POST|PUT|PATCH request") var ErrBodylessRequest = errors.New("not a POST|PUT|PATCH|DELETE request")