[mod_python] How check permissions to GET JPG image

Graham Dumpleton grahamd at dscpl.com.au
Tue Dec 6 16:49:11 EST 2005

Enot wrote ..
> ML> The range header normally specifies what the client wants, so you can
> ML> set up a correct response (read the RFC!) open the file, seek to the
> ML> requested position (using file.seek(..)) and start sending from there.
> The problem is in mod_python. When i use "req.sendfile()"
> my "req.headers_out" probably are rewrited by Apache.
> Is any way to use "req.sendfile()" with resume? Where i must search?
> Using "req.write()" for lage files is very bad.
> Can i use successive "req.write(); req.flush()" with small pieces of
> lage file?

You shouldn't need to use file.seek() or req.write() as req.sendfile() allows
an offset to be specified.

  sendfile(path[, offset, len])

    Sends len bytes of file path directly to the client, starting at offset
    offset using the server's internal API. offset defaults to 0, and len
    defaults to -1 (send the entire file).

    This function provides the most efficient way to send a file to the client.

Thus calculate from the headers where you need to start and tell
req.sendfile() to start there instead.


More information about the Mod_python mailing list