diff options
Diffstat (limited to 'src/net/sendfile_unix_alt.go')
-rw-r--r-- | src/net/sendfile_unix_alt.go | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/net/sendfile_unix_alt.go b/src/net/sendfile_unix_alt.go index 5cb65ee767..9e46c4e607 100644 --- a/src/net/sendfile_unix_alt.go +++ b/src/net/sendfile_unix_alt.go @@ -9,9 +9,12 @@ package net import ( "internal/poll" "io" - "os" + "io/fs" + "syscall" ) +const supportsSendfile = true + // sendFile copies the contents of r to c using the sendfile // system call to minimize copies. // @@ -34,7 +37,13 @@ func sendFile(c *netFD, r io.Reader) (written int64, err error, handled bool) { return 0, nil, true } } - f, ok := r.(*os.File) + // r might be an *os.File or an os.fileWithoutWriteTo. + // Type assert to an interface rather than *os.File directly to handle the latter case. + f, ok := r.(interface { + fs.File + io.Seeker + syscall.Conn + }) if !ok { return 0, nil, false } |