# HG changeset patch # User Heiko Schlittermann # Date 1233172851 -3600 # Node ID ce482bda336e0640dbe964f6d0376014c07208b3 # Parent 9166982f8b19b2b57f58dc0b55956ec05384758e# Parent f79215d95c42638c76f8d0aa1c52997c2c2c5bf1 [merged] tag feature diff -r f79215d95c42 -r ce482bda336e hlog --- a/hlog Wed Jan 28 20:58:55 2009 +0100 +++ b/hlog Wed Jan 28 21:00:51 2009 +0100 @@ -34,6 +34,8 @@ sub handle_request($); sub date1123(;$); sub http($@); +sub multipart_start($); +sub multipart_part(@); sub bad_request(); MAIN: { @@ -139,12 +141,16 @@ seek($file{fh}, -($lines + 1) * $file{avglen}, 2); $file{fh}->getline; - $client->print(http "200 OK" => join "", <<__EOF, $file{fh}->getlines); + $client->print( + http "200 OK", + multipart_start "abcde"); + + $client->print(multipart_part <<__EOF, $file{fh}->getlines); # Proof of concept ;-) # see https://keller.schlittermann.de/hg/hlog # # FILE: @{[sprintf "%s", $file{name}]} -# LENGTH: @{[sprintf "%5d", $file{size}]} +# SIZE : @{[sprintf "%5d", $file{size}]} # LINES: @{[sprintf "%5d approx", $file{lines}]} # LENGTH: @{[sprintf "%5d approx", $file{avglen}]} # DISPLAY: @{[sprintf "%5d approx", $lines]} @@ -182,18 +188,46 @@ return %r; } +{ + my $boundary; +sub multipart_start(@) { + $boundary = "--" . shift; + $boundary .= "\n" unless $boundary =~ /\n$/; + + $boundary =~ /^--(.*)\n$/; + + return "Content-Type: multipart/x-mixed-replace; boundary=\"$1\"\n", + "\n"; +} + +sub multipart_part(@) { + return $boundary, + $_[0] =~ /^