Ville Silventoinen
vsi at ebi.ac.uk
Fri Mar 24 07:29:26 EST 2006
Hi, is there a way to send a file using a file handle? I've got a file archive, which stores files in gzip format. When a client downloads the file, I'd like to send the file uncompressed, without creating a temporary file. I'm sending the file like this (bit simplified): req.filename = fname req.content_type = ctype req.set_content_length = flen fh = gzip.GzipFile(fpath, 'rb', 9) block_size = 1024 while 1: data = fh.read(block_size) if not data: break req.write(data) fh.close() return apache.OK I've tested this with different files, it seems to work ok. I was looking at the requestobject.c. Would it be easy to implement something like req_sendfh in addition to req_sendfile? Thanks, Ville
|