MCPcopy
hub / github.com/valyala/fasthttp / Body

Method Body

http.go:427–438  ·  view source on GitHub ↗

Body returns response body. 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.

()

Source from the content-addressed store, hash-verified

425// either though ReleaseResponse or your request handler returning.
426// Do not store references to returned value. Make copies instead.
427func (resp *Response) Body() []byte {
428 if resp.bodyStream != nil {
429 bodyBuf := resp.bodyBuffer()
430 bodyBuf.Reset()
431 _, err := copyZeroAlloc(bodyBuf, resp.bodyStream)
432 resp.closeBodyStream(err) //nolint:errcheck
433 if err != nil {
434 bodyBuf.SetString(err.Error())
435 }
436 }
437 return resp.bodyBytes()
438}
439
440func (resp *Response) bodyBytes() []byte {
441 if resp.bodyRaw != nil {

Callers 15

TestFSServeFileHeadFunction · 0.95
testFSFSCompressFunction · 0.95
TestDirFSServeFileHeadFunction · 0.95
BodyGunzipWithLimitMethod · 0.95
BodyUnbrotliWithLimitMethod · 0.95
BodyInflateWithLimitMethod · 0.95
BodyUnzstdWithLimitMethod · 0.95
ExampleLBClientFunction · 0.95

Calls 6

bodyBufferMethod · 0.95
closeBodyStreamMethod · 0.95
bodyBytesMethod · 0.95
copyZeroAllocFunction · 0.85
ResetMethod · 0.65
ErrorMethod · 0.45

Tested by 15

TestFSServeFileHeadFunction · 0.76
testFSFSCompressFunction · 0.76
TestDirFSServeFileHeadFunction · 0.76
ExampleLBClientFunction · 0.76
TestServerWriteFastErrorFunction · 0.76
TestServerServeTLSEmbedFunction · 0.76