MCPcopy
hub / github.com/gofiber/fiber / GetBytes

Method GetBytes

app.go:813–821  ·  view source on GitHub ↗

GetBytes returns b unchanged when Immutable is off or b is read-only (rodata). Otherwise, it returns a detached copy.

(b []byte)

Source from the content-addressed store, hash-verified

811// GetBytes returns b unchanged when Immutable is off or b is read-only (rodata).
812// Otherwise, it returns a detached copy.
813func (app *App) GetBytes(b []byte) []byte {
814 if !app.config.Immutable || len(b) == 0 {
815 return b
816 }
817 if isReadOnly(unsafe.Pointer(unsafe.SliceData(b))) { //nolint:gosec // pointer check avoids unnecessary copy
818 return b // rodata → safe to return as-is
819 }
820 return utils.CopyBytes(b) // detach when backed by request/response memory
821}
822
823// Adds an ip address to TrustProxyConfig.ranges or TrustProxyConfig.ips based on whether it is an IP range or not
824func (app *App) handleTrustedProxy(ipAddress string) {

Callers 3

BodyMethod · 0.80
getBodyMethod · 0.80
Test_App_GetBytesFunction · 0.80

Calls 1

isReadOnlyFunction · 0.70

Tested by 1

Test_App_GetBytesFunction · 0.64