# 1st demo progressive script execution. # Author: Kyle Scholz (http://www.kylescholz.com) use HTTP::Daemon; use HTTP::Status; use strict; my $CRLF = "\015\012"; $|=1; # Autoflush buffers start_server(10000); # Send a chunk of a response sub send_chunk { my ($conn, $content, $is_last) = @_; printf $conn "%x$CRLF%s$CRLF", length($content), $content; if ($is_last) { print $conn "0$CRLF$CRLF"; } } # Send a complete response sub send_response { my ($conn) = @_; my $i = 0; my $total = 0; # Send Headers my $response = HTTP::Response->new(200); $response->header("Transfer-Encoding" => "chunked"); $conn->send_response($response); # Start HTML Doc my $content = ""; $total += length($content); # Reported total length is at last chunk send_chunk($conn, $content); # Send chunks at interval while($i<50) { my $content = sprintf "