[mod_python] req.sendfile() questions

Jim Gallacher jg.lists at sympatico.ca
Mon Jun 20 08:37:43 EDT 2005


Wouter van Marle wrote:
> Hi all,
> 
> I'm looking into a way of sending out specific files, and detect whether
> or not the download was successful.
> For sending the file I think I can best use req.sendfile(path,[offset,
> len]). That seems easy enough to implement.
> 
> But how to detect whether the download was aborted (if so: at what
> stage), or whether it has finished successful, etc. What I understand
> after searching the web, is that req.sendfile does come back: just no
> documentation on what it comes back with!

It will raise an IOError exception if the client disconnects. Otherwise 
it will return the number of bytes sent.

req.sendfile is a wrapper around the apache function ap_send_fd(). A 
quick look at this tells me that nbytes is set to 0 on failure, so there 
is no way for mod_python to determine the progress if the client 
disconnects.

I'll add this to the documentation.

Jim


More information about the Mod_python mailing list