Fedora Core 4 httpd-2.0.54-10 mod_perl-2.0.0-0.rc5.3 I have an nph mod_perl script which will send a JPEG to a client either inline or as an attachment (if a param is passed). If it is an attachment, I set the Content-Disposition to: "Content-Disposition: attachment; filename=\"$snapshot_filename\"\r\n" otherwise, I do not include this tag in the header.
I am creating the buffer as I go (appending header tags). I append the separator and the JPEG: $write_buffer .= "\r\n" . $jpeg . "\r\n\r\n"; And then send the buffer to the client: $r->print($write_buffer); If the Content-Disposition line is not present, $r->print returns the number of bytes sent to the client which equals length($write_buffer). 7628/7628 (bytes_sent/buffer_length) If the Content-Disposition line is present, $r->print returns the number of bytes sent to the client which is larger than length($write_buffer). 10882/7647 (bytes_sent/buffer_length) (the buffer length is different because the image sent was different) In addition to this, the JPEG is valid in the first case but is "corrupt" in the second. Saving the attachment through Firefox or using curl results in a file which is not a valid JPEG. If I break the attachment send into 3 sends: $r->print($write_buffer); $r->print($jpeg); $r->print("\r\n\r\n"); Each returns bytes sent equal to the length of the buffer and everything is valid on the client's end. "print $write_buffer" works in both the inline and append cases without needing to separate the transfer into parts. Is this a bug in mod_perl or am I missing something?? thanks, Christopher