Skip to content

Commit b5a6d87

Browse files
committed
Use int64 for SendFile byte range size
1 parent 413bad5 commit b5a6d87

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

res.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ func (r *DefaultRes) SendFile(file string, config ...SendFile) error {
822822
request.SetRequestURI(file)
823823

824824
var (
825-
sendFileSize int
825+
sendFileSize int64
826826
hasSendFileSize bool
827827
)
828828

@@ -866,7 +866,7 @@ func (r *DefaultRes) SendFile(file string, config ...SendFile) error {
866866
// Apply cache control header
867867
if status != StatusNotFound && status != StatusForbidden {
868868
if cfg.ByteRange && hasSendFileSize && response.StatusCode() == StatusRequestedRangeNotSatisfiable && len(response.Header.Peek(HeaderContentRange)) == 0 {
869-
response.Header.Set(HeaderContentRange, "bytes */"+strconv.Itoa(sendFileSize))
869+
response.Header.Set(HeaderContentRange, "bytes */"+strconv.FormatInt(sendFileSize, 10))
870870
}
871871

872872
if cacheControlValue != "" {
@@ -879,7 +879,7 @@ func (r *DefaultRes) SendFile(file string, config ...SendFile) error {
879879
return nil
880880
}
881881

882-
func sendFileContentLength(path string, cfg SendFile) (int, error) {
882+
func sendFileContentLength(path string, cfg SendFile) (int64, error) {
883883
if cfg.FS != nil {
884884
cleanPath := pathpkg.Clean(utils.TrimLeft(path, '/'))
885885
if cleanPath == "." {
@@ -889,15 +889,15 @@ func sendFileContentLength(path string, cfg SendFile) (int, error) {
889889
if err != nil {
890890
return 0, fmt.Errorf("stat %q: %w", cleanPath, err)
891891
}
892-
return int(info.Size()), nil
892+
return info.Size(), nil
893893
}
894894

895895
info, err := os.Stat(filepath.FromSlash(path))
896896
if err != nil {
897897
return 0, fmt.Errorf("stat %q: %w", path, err)
898898
}
899899

900-
return int(info.Size()), nil
900+
return info.Size(), nil
901901
}
902902

903903
// SendStatus sets the HTTP status code and if the response body is empty,

0 commit comments

Comments
 (0)