MCPcopy Create free account
hub / github.com/gofiber/fiber / sendFileContentLength

Function sendFileContentLength

res.go:936–955  ·  view source on GitHub ↗
(path string, cfg SendFile)

Source from the content-addressed store, hash-verified

934}
935
936func sendFileContentLength(path string, cfg SendFile) (int64, error) {
937 if cfg.FS != nil {
938 cleanPath := pathpkg.Clean(utils.TrimLeft(path, '/'))
939 if cleanPath == "." {
940 cleanPath = ""
941 }
942 info, err := fs.Stat(cfg.FS, cleanPath)
943 if err != nil {
944 return 0, fmt.Errorf("stat %q: %w", cleanPath, err)
945 }
946 return info.Size(), nil
947 }
948
949 info, err := os.Stat(filepath.FromSlash(path))
950 if err != nil {
951 return 0, fmt.Errorf("stat %q: %w", path, err)
952 }
953
954 return info.Size(), nil
955}
956
957// SendStatus sets the HTTP status code and if the response body is empty,
958// it sets the correct status message in the body.

Callers 1

SendFileMethod · 0.85

Calls 1

ErrorfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…