def sendfile(self, data, zlib_compress=None, compress_level=<NUM_LIT:6>):
if hasattr(data, '<STR_LIT>'):<EOL><INDENT>data.seek(<NUM_LIT:0>)<EOL><DEDENT>chunk_size = CHUNK_SIZE<EOL>if zlib_compress:<EOL><INDENT>chunk_size = BLOCK_SIZE<EOL>compressor = compressobj(compress_level)<EOL><DEDENT>while <NUM_LIT:1>:<EOL><INDENT>binarydata = data.read(chunk_size)<EOL>if binarydata == '<STR_LIT>':<EOL><INDENT>break<EOL><DEDENT>if zlib_compress:<EOL><INDENT>binarydata = compressor.compress(binarydata)<EOL>if not binarydata:<EOL><INDENT>continue<EOL><DEDENT><DEDENT>self.send(binarydata)<EOL><DEDENT>if zlib_compress:<EOL><INDENT>remaining = compressor.flush()<EOL>while remaining:<EOL><INDENT>binarydata = remaining[:BLOCK_SIZE]<EOL>remaining = remaining[BLOCK_SIZE:]<EOL>self.send(binarydata)<EOL><DEDENT><DEDENT>
Send data from a file object