# HG changeset patch # User Heiko Schlittermann # Date 1233165476 -3600 # Node ID 9166982f8b19b2b57f58dc0b55956ec05384758e # Parent 83dad3fbc95e96a1f7d94abad1827ba0e5ec4f1e# Parent b3cf6e84d2c6151e7e777d1aced93c0572ff04f3 [merged] (zombie killer) diff -r b3cf6e84d2c6 -r 9166982f8b19 hlog --- a/hlog Wed Jan 28 18:57:03 2009 +0100 +++ b/hlog Wed Jan 28 18:57:56 2009 +0100 @@ -34,6 +34,8 @@ sub handle_request($); sub date1123(;$); sub http($@); +sub multipart_start($); +sub multipart_part(@); sub bad_request(); MAIN: { @@ -124,12 +126,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]} @@ -167,18 +173,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] =~ /^