Skip to content

Commit 79ea8a4

Browse files
committed
feat: optimize body copy when immutable
1 parent c0daafa commit 79ea8a4

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

req.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,7 @@ func (r *DefaultReq) Body() []byte {
178178
return []byte(err.Error())
179179
}
180180

181-
if r.c.app.config.Immutable {
182-
return utils.CopyBytes(body)
183-
}
184-
return body
181+
return r.c.app.ImmutableBytes(body)
185182
}
186183

187184
// RequestCtx returns *fasthttp.RequestCtx that carries a deadline
@@ -913,9 +910,5 @@ func (r *DefaultReq) release() {
913910
}
914911

915912
func (r *DefaultReq) getBody() []byte {
916-
if r.c.app.config.Immutable {
917-
return utils.CopyBytes(r.c.fasthttp.Request.Body())
918-
}
919-
920-
return r.c.fasthttp.Request.Body()
913+
return r.c.app.ImmutableBytes(r.c.fasthttp.Request.Body())
921914
}

0 commit comments

Comments
 (0)