[mod_python] req.sendfile() questions

Wouter van Marle wouter at squirrel-systems.com
Tue Jun 21 00:44:31 EDT 2005

On Mon, 2005-06-20 at 11:43 -0400, Jim Gallacher wrote:

> >>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.
> > That's less important to me; complete or not is the main issue here.
> > By the way, does the req.sendfile() function support resuming a
> > download?
> Ah, so it *is* important to you. :) 

Well maybe in a way it is :) I hoped a resume option would be built in
already. That would save me some headaches. I guess most modern browsers
support resume of downloads (they should, imho). I know http is not the
best option for downloading files (ftp is designed for that of course)
but well it seems to be the easiest now. I didn't intend to store
progress information except for complete or not complete.

> ap_send_fd() sets the number of 
> bytes sent to 0 on failure - ie the client disconnects. There is no way 
> for req.sendfile to know the number of bytes sent, so there is no way 
> for it to resume a download, since it would not know where in the file 
> to start sending.
> You may be able to manipulate the http headers to get what you want. 
> Take a look at headers such as Accept-Ranges, Content-Length, Range, 
> etc. This will depend on the client also being able to resume downloads 
> and sending the appropriate request. You will need to examine the 
> request header to determine what part of the file to send in response.

I see. So client requests resuming from a certain off-set. That
shouldn't be too hard to implement (in a future version). Thanks.

Any thoughts on using ftp downloads instead? Could allow for faster
downloads. Though then it seems I'll have to set up an ftp server. I
know again most web browsers do support ftp.

> See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

I will.


> Regards,
> Jim

More information about the Mod_python mailing list