Catch sendfile failure from no file descriptor

If the filelike response object has no `fileno` attribute, then skip
trying to use sendfile rather than failing with an error.

Close #1160
This commit is contained in:
Randall Leeds 2015-12-28 14:50:46 -08:00
parent 960d5ef7cc
commit 98c9e3b375

View File

@ -355,6 +355,10 @@ class Response(object):
try:
fileno = respiter.filelike.fileno()
except AttributeError:
return False
try:
offset = os.lseek(fileno, 0, os.SEEK_CUR)
if self.response_length is None:
filesize = os.fstat(fileno).st_size