mirror of https://github.com/gin-gonic/gin.git
chore(request): check reader if it's nil before reading (#3419)
This commit is contained in:
parent
1b3c085969
commit
ab8042e9e5
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue