Check reader if it's nil before reading

This commit is contained in:
Noah Yao 2022-11-30 12:06:20 +08:00 committed by GitHub
parent 80cd679c43
commit a0ea2880e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -871,6 +871,9 @@ func (c *Context) GetHeader(key string) string {
// GetRawData returns stream data.
func (c *Context) GetRawData() ([]byte, error) {
if c.Request.Body == nil {
return nil, errors.New("cannot read nil body")
}
return io.ReadAll(c.Request.Body)
}