-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
Description
A go TCP server can efficiently server files to clients using the ReadFrom method, but if the protocol allows partial files, e.g. HTTP Range requests, we have to fallback to copying all the data again for each connection. Currently sendfile is only accessible by calling *TCPConn.ReadFrom(r io.Reader), with no way to set the offset and count. Internally, sendfile uses to the netFD writelock and file descriptor. Doing this outside of the net package is awkward and requires putting the connection into blocking mode. One option is to special case an io.SectionReader in the sendfile implementation, though this requires modifying SectionReader in a way to expose the underlying io.Reader, offset, and count fields.