[mod_python] req.sendfile and the Content-length header

Roger Binns rogerb at rogerbinns.com
Sat Jun 9 20:41:26 EDT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Graham Dumpleton wrote:
> What you are doing isn't actually guaranteed to yield the correct
> result as the file might be changed between the close() and the call
> to sendfile() and thus you could end up sending a different amount of
> data.

The modpython code has a similar problem except that it doesn't set the
content length so the protocol won't be bad.  It does do a stat first to
get the size then does an open and then a send of that size and so also
has the race condition.

In theory an alternative is to open the file and use apr_file_seek to
find the end although even then the file contents could change while
sending.

Roger
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFGa0i2mOOfHg372QQRAiK6AKDemPtKaXiKG0ey7LhzunR6DvlyNwCglnxo
G8QCn0Up/k1XykoDPizTbQk=
=zMcD
-----END PGP SIGNATURE-----


More information about the Mod_python mailing list