-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A safe and reliable check for whether a file descriptor supports mmap is to directly check if it is seekable. However, some seekable file descriptors may also report a zero size when calling fstat. If there is no content length specified for the response and it cannot be determined from the file descriptor then it is not possible to know what chunk size to send to the client. In this case, is it necessary to fall back to unwinding the body by iteration. The above conditions together reveal a straightforward and reliable way to check for sendfile support. This patch modifies the Response class to assert these conditions using a try/catch block as part of a new, simplified sendfile method. This method returns False if it is not possible to serve the response using sendfile. Otherwise, it serves the response and returns True. By returning False when SSL is in use, the code is made even simpler by removing the special support for SSL, which is served well enough by the iteration protocol. Fix #1038
- Loading branch information
Showing
2 changed files
with
36 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters