Source file
src/net/sendfile_windows.go
1
2
3
4
5 package net
6
7 import (
8 "internal/poll"
9 "io"
10 "os"
11 "syscall"
12 )
13
14
15
16
17
18
19
20
21 func sendFile(fd *netFD, r io.Reader) (written int64, err error, handled bool) {
22 var n int64 = 0
23
24 lr, ok := r.(*io.LimitedReader)
25 if ok {
26 n, r = lr.N, lr.R
27 if n <= 0 {
28 return 0, nil, true
29 }
30 }
31
32 f, ok := r.(*os.File)
33 if !ok {
34 return 0, nil, false
35 }
36
37 written, err = poll.SendFile(&fd.pfd, syscall.Handle(f.Fd()), n)
38 if err != nil {
39 err = wrapSyscallError("transmitfile", err)
40 }
41
42
43
44 handled = written > 0
45
46 return
47 }
48
View as plain text