# HG changeset patch # User Heiko Schlittermann # Date 1233120231 -3600 # Node ID 83dad3fbc95e96a1f7d94abad1827ba0e5ec4f1e # Parent d63acb8bbdbdf5ed10a1ef61d0d8b76ceafb7824 Started Multipart-Support. diff -r d63acb8bbdbd -r 83dad3fbc95e hlog --- a/hlog Tue Jan 27 23:47:51 2009 +0100 +++ b/hlog Wed Jan 28 06:23:51 2009 +0100 @@ -33,6 +33,8 @@ sub handle_request($); sub date1123(;$); sub http($@); +sub multipart_start($); +sub multipart_part(@); sub bad_request(); MAIN: { @@ -113,12 +115,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]} @@ -156,18 +162,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] =~ /^