/[pub]/test/html-whatpm/parser.cgi
Suika

Contents of /test/html-whatpm/parser.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (show annotations) (download)
Mon May 28 14:04:57 2007 UTC (19 years, 6 months ago) by wakaba
Branch: MAIN
Changes since 1.6: +7 -1 lines
++ ChangeLog	28 May 2007 14:04:52 -0000
2007-05-28  Wakaba  <wakaba@suika.fam.cx>

	* parser.cgi: Log elapsed time to external files.

	* time.plt: New file.

1 #!/usr/bin/perl
2 use strict;
3
4 use lib qw[/home/httpd/html/www/markup/html/whatpm
5 /home/wakaba/public_html/-temp/wiki/lib];
6 use CGI::Carp qw[fatalsToBrowser];
7 use Time::HiRes qw/time/;
8
9 use SuikaWiki::Input::HTTP; ## TODO: Use some better CGI module
10
11 my $http = SuikaWiki::Input::HTTP->new;
12
13 ## TODO: _charset_
14
15 my $mode = $http->meta_variable ('PATH_INFO');
16 ## TODO: decode unreserved characters
17
18 if ($mode eq '/html' or $mode eq '/test') {
19 require Encode;
20 require Whatpm::HTML;
21 require Whatpm::NanoDOM;
22
23 my $s = $http->parameter ('s');
24 if (length $s > 1000_000) {
25 print STDOUT "Status: 400 Document Too Long\nContent-Type: text/plain; charset=us-ascii\n\nToo long";
26 exit;
27 }
28
29 my $time1 = time;
30 $s = Encode::decode ('utf-8', $s);
31 my $time2 = time;
32 my %time = (decode => $time2 - $time1);
33 my $char_length = length $s;
34
35 print STDOUT "Content-Type: text/plain; charset=utf-8\n\n";
36
37 print STDOUT "#errors\n";
38
39 my $onerror = sub {
40