[issue13559] Use sendfile where possible in httplib

Benjamin Peterson report at bugs.python.org
Fri Dec 9 07:08:50 CET 2011


Benjamin Peterson <benjamin at python.org> added the comment:

2011/12/8 Giampaolo Rodola' <report at bugs.python.org>:
>
> Giampaolo Rodola' <g.rodola at gmail.com> added the comment:
>
> This is not possible for two reasons:
>
> - on most POSIX systems, sendfile() works with mmap-like ("regular") files only, while HTTPConnection.send() accepts any file-like object as long as it provides a read() method
>
> - after read()ing a chunk of data from the file and before send()ing it over the socket, the data can be subject to an intermediate conversion (datablock.encode("iso-8859-1")):
> http://hg.python.org/cpython/file/87c6be1e393a/Lib/http/client.py#l839
> ...whereas sendfile() can only be used to send a binary file "as-is"

I presume you could check for a binary mode, though? Also, you can
catch EINVAl on invalid fds.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13559>
_______________________________________


More information about the Python-bugs-list mailing list