I need to disable progressive buffering of an HTTP response.
This works for me in Perl, using the file descriptor class:
$|=1; $TIE = tie(*STDOUT,__PACKAGE__);
Print statements are stored in an array and retrieved using the following:
$buffer = tied *STDOUT; $buffer = join('', @$buffer); undef $TIE; untie(*STDOUT);
If the HTTP response is text/html
, it displays correctly in the browser.
However, for binary streams, I cannot set binmode
to STDOUT
after it is untied, and the contents are corrupted.
If I save the HTTP response for the file, or if I do not use the file descriptor class, the binary data is saved.
Any suggestions on how to force raw encoding? Thanks.
source share