| OLD | NEW |
| 1 #!/usr/bin/perl -wT | 1 #!/usr/bin/perl -wT |
| 2 | 2 |
| 3 my $pre_chunked = ($ENV{"SERVER_SOFTWARE"} && index($ENV{"SERVER_SOFTWARE"}, "Li
ghtTPD") != -1); | 3 my $pre_chunked = ($ENV{"SERVER_SOFTWARE"} && index($ENV{"SERVER_SOFTWARE"}, "Li
ghtTPD") != -1); |
| 4 | 4 |
| 5 sub print_maybe_chunked | 5 sub print_maybe_chunked |
| 6 { | 6 { |
| 7 my $string = shift; | 7 my $string = shift; |
| 8 if ($pre_chunked) { | 8 if ($pre_chunked) { |
| 9 print $string; | 9 print $string; |
| 10 return; | 10 return; |
| 11 } | 11 } |
| 12 printf "%lx\r\n", length($string); | 12 printf "%lx\r\n", length($string); |
| 13 print "$string\r\n"; | 13 print "$string\r\n"; |
| 14 } | 14 } |
| 15 | 15 |
| 16 print "Content-type: text/html\r\n"; | 16 print "Content-type: text/html\r\n"; |
| 17 if (!$pre_chunked) { | 17 if (!$pre_chunked) { |
| 18 print "Transfer-encoding: chunked\r\n"; | 18 print "Transfer-encoding: chunked\r\n"; |
| 19 } | 19 } |
| 20 | 20 |
| 21 select (STDOUT); | 21 select (STDOUT); |
| 22 $| = 1; | 22 $| = 1; |
| 23 | 23 |
| 24 print "\r\n"; | 24 print "\r\n"; |
| 25 print_maybe_chunked "<!DOCTYPE html><style>h2 { background-color: green; }</styl
e>"; | 25 print_maybe_chunked "<!DOCTYPE html><style>h2 { background-color: green; }</styl
e>"; |
| 26 print_maybe_chunked "<link rel='stylesheet' onload='start()'>"; | 26 print_maybe_chunked "<link rel='stylesheet' onload='start()'>"; |
| 27 print_maybe_chunked "<body><script>document.getElementsByTagName('link')[0].href
='resources/slow-loading-sheet.php?color=green&sleep=500000'; document.body.offs
etTop; requestAnimationFrame(function() { console.log('requestAnimationFrame ran
'); });"; | 27 print_maybe_chunked "<body><script>document.getElementsByTagName('link')[0].href
='resources/slow-loading-sheet.php?color=green&sleep=500000'; document.body.offs
etTop; requestAnimationFrame(function() { console.log('requestAnimationFrame ran
'); });"; |
| 28 print_maybe_chunked "function start() { console.log('Stylesheet loaded'); } cons
ole.log('Inline script done');</script>"; | 28 print_maybe_chunked "function start() { console.log('Stylesheet loaded'); } cons
ole.log('Inline script done');</script>"; |
| 29 print_maybe_chunked "<h1>Styled by external stylesheet</h1><div style='height: 2
00px'></div><h2>Noncomposited</h2><h2 style='-webkit-transform:translateZ(0)'>Co
mposited</h2>"; | 29 print_maybe_chunked "<h1>Styled by external stylesheet</h1><div style='height: 2
00px'></div><h2>Noncomposited</h2><h2 style='transform:translateZ(0)'>Composited
</h2>"; |
| 30 sleep(1); | 30 sleep(1); |
| 31 print_maybe_chunked ""; | 31 print_maybe_chunked ""; |
| OLD | NEW |