aboutsummaryrefslogtreecommitdiff
path: root/http.go
diff options
context:
space:
mode:
authorGravatar Erik Dubbelboer <erik@dubbelboer.com> 2021-10-01 13:37:28 +0200
committerGravatar Erik Dubbelboer <erik@dubbelboer.com> 2021-10-01 13:38:31 +0200
commitffab77a59d9ca1fe3add2f6501efd44a6669291b (patch)
treeaaf7a9f715cd1f5f813f2efbae1479628a18e7bc /http.go
parentProperly parse URI (diff)
downloadfasthttp-ffab77a59d9ca1fe3add2f6501efd44a6669291b.tar.gz
fasthttp-ffab77a59d9ca1fe3add2f6501efd44a6669291b.tar.bz2
fasthttp-ffab77a59d9ca1fe3add2f6501efd44a6669291b.zip
Improve return value reusability documentation
Diffstat (limited to 'http.go')
-rw-r--r--http.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/http.go b/http.go
index dd1418a..18e5f81 100644
--- a/http.go
+++ b/http.go
@@ -320,7 +320,9 @@ func (resp *Response) LocalAddr() net.Addr {
// Body returns response body.
//
-// The returned body is valid until the response modification.
+// The returned value is valid until the response is released,
+// either though ReleaseResponse or your request handler returning.
+// Do not store references to returned value. Make copies instead.
func (resp *Response) Body() []byte {
if resp.bodyStream != nil {
bodyBuf := resp.bodyBuffer()
@@ -638,7 +640,9 @@ func (req *Request) SwapBody(body []byte) []byte {
// Body returns request body.
//
-// The returned body is valid until the request modification.
+// The returned value is valid until the request is released,
+// either though ReleaseRequest or your request handler returning.
+// Do not store references to returned value. Make copies instead.
func (req *Request) Body() []byte {
if req.bodyRaw != nil {
return req.bodyRaw