From a0ea2880e65d604970f4e5576d1b07c234755230 Mon Sep 17 00:00:00 2001 From: Noah Yao Date: Wed, 30 Nov 2022 12:06:20 +0800 Subject: [PATCH] Check reader if it's nil before reading --- context.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/context.go b/context.go index c41c71ec..08f3a2df 100644 --- a/context.go +++ b/context.go @@ -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) }