mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-02-03 00:38:40 +08:00
parse body only if content length > 0
This commit is contained in:
parent
05c8dd0b9c
commit
a26fc2b672
@ -34,9 +34,13 @@ func Parse(r *http.Request, v interface{}) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if r.ContentLength > 0 {
|
||||||
return ParseJsonBody(r, v)
|
return ParseJsonBody(r, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Parses the form request.
|
// Parses the form request.
|
||||||
func ParseForm(r *http.Request, v interface{}) error {
|
func ParseForm(r *http.Request, v interface{}) error {
|
||||||
if strings.Contains(r.Header.Get(ContentType), multipartFormData) {
|
if strings.Contains(r.Header.Get(ContentType), multipartFormData) {
|
||||||
|
@ -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")
|
||||||
|
Loading…
Reference in New Issue
Block a user