mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-16 05:16:35 +08:00
Check reader if it's nil before reading
This commit is contained in:
parent
80cd679c43
commit
a0ea2880e6
@ -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)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user