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

View File

@ -880,6 +880,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)
}