chore(request): check reader if it's nil before reading (#3419)

This commit is contained in:
Noah Yao 2024-03-11 22:44:28 +08:00 committed by GitHub
parent 1b3c085969
commit ab8042e9e5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 0 deletions

View File

@ -880,6 +880,9 @@ func (c *Context) GetHeader(key string) string {
// GetRawData returns stream data. // GetRawData returns stream data.
func (c *Context) GetRawData() ([]byte, error) { 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) return io.ReadAll(c.Request.Body)
} }