<%perl> use Digest::MD5 qw(md5_hex); my $url=$r->uri(); my $sid=$ARGS{sid}; print STDERR "Lab: Got $url ($sid)\n"; my $res=""; my $ended=0; if ($sid) { my $rs=$m->cache->get($sid); if ($rs) { ($ended,$res)=@{$rs}; unless ($ended) { $res.=< EOF } } else { $res="INVALID SESSION"; } } else { $sid=md5_hex(time().{}.rand().$$); $m->cache->set($sid,[(0,"")],'5 min'); if (my $pid=fork()) { $url=$r->uri(); $url.="?sid=$sid"; print STDERR "Going to $url\n"; $r->header_out('location',$url); $r->status(302); return; } elsif(defined($pid)) { close STDOUT; close STDIN; my $rnd; for my $i (1..25) { $rnd.=md5_hex(rand()); $rnd.="
"; $m->cache->set($sid,[(0,"$i: $rnd")],'5 min'); sleep 1; } $m->cache->set($sid,[(1,"done: $rnd")],'5 min'); $res="I was expecting this to go anywhere!!!
".$rnd; } else { } } <%$res%>