2 |
use strict; |
use strict; |
3 |
|
|
4 |
use lib qw[/home/httpd/html/www/markup/html/whatpm |
use lib qw[/home/httpd/html/www/markup/html/whatpm |
5 |
/home/wakaba/public_html/-temp/wiki/lib]; |
/home/wakaba/work/manakai2/lib]; |
6 |
use CGI::Carp qw[fatalsToBrowser]; |
use CGI::Carp qw[fatalsToBrowser]; |
7 |
use Time::HiRes qw/time/; |
use Time::HiRes qw/time/; |
8 |
|
|
9 |
use SuikaWiki::Input::HTTP; ## TODO: Use some better CGI module |
use Message::CGI::HTTP; |
10 |
|
my $http = Message::CGI::HTTP->new; |
|
my $http = SuikaWiki::Input::HTTP->new; |
|
11 |
|
|
12 |
## TODO: _charset_ |
## TODO: _charset_ |
13 |
|
|
14 |
my $mode = $http->meta_variable ('PATH_INFO'); |
my $mode = $http->get_meta_variable ('PATH_INFO'); |
15 |
## TODO: decode unreserved characters |
## TODO: decode unreserved characters |
16 |
|
|
17 |
if ($mode eq '/html' or $mode eq '/test') { |
if ($mode eq '/html' or $mode eq '/test') { |
19 |
require Whatpm::HTML; |
require Whatpm::HTML; |
20 |
require Whatpm::NanoDOM; |
require Whatpm::NanoDOM; |
21 |
|
|
22 |
my $s = $http->parameter ('s'); |
my $s = $http->get_parameter ('s'); |
23 |
if (length $s > 1000_000) { |
if (length $s > 1000_000) { |
24 |
print STDOUT "Status: 400 Document Too Long\nContent-Type: text/plain; charset=us-ascii\n\nToo long"; |
print STDOUT "Status: 400 Document Too Long\nContent-Type: text/plain; charset=us-ascii\n\nToo long"; |
25 |
exit; |
exit; |
29 |
$s = Encode::decode ('utf-8', $s); |
$s = Encode::decode ('utf-8', $s); |
30 |
my $time2 = time; |
my $time2 = time; |
31 |
my %time = (decode => $time2 - $time1); |
my %time = (decode => $time2 - $time1); |
32 |
|
my $char_length = length $s; |
33 |
|
|
34 |
print STDOUT "Content-Type: text/plain; charset=utf-8\n\n"; |
print STDOUT "Content-Type: text/plain; charset=utf-8\n\n"; |
35 |
|
|
51 |
my $out; |
my $out; |
52 |
$time1 = time; |
$time1 = time; |
53 |
if ($mode eq '/html') { |
if ($mode eq '/html') { |
54 |
$out = Whatpm::HTML->get_inner_html ($doc); |
require Whatpm::HTML::Serializer; |
55 |
|
$out = Whatpm::HTML::Serializer->get_inner_html ($doc); |
56 |
} else { # test |
} else { # test |
57 |
$out = test_serialize ($doc); |
$out = test_serialize ($doc); |
58 |
} |
} |
61 |
print STDOUT Encode::encode ('utf-8', $$out); |
print STDOUT Encode::encode ('utf-8', $$out); |
62 |
print STDOUT "\n"; |
print STDOUT "\n"; |
63 |
|
|
64 |
if ($http->parameter ('dom5')) { |
if ($http->get_parameter ('dom5')) { |
65 |
require Whatpm::ContentChecker; |
require Whatpm::ContentChecker; |
66 |
print STDOUT "#domerrors\n"; |
print STDOUT "#domerrors\n"; |
67 |
$time1 = time; |
$time1 = time; |
78 |
print STDOUT "html5->dom5\t", $time{parse}, "s\n"; |
print STDOUT "html5->dom5\t", $time{parse}, "s\n"; |
79 |
print STDOUT "dom5->serialize\t", $time{serialize}, "s\n"; |
print STDOUT "dom5->serialize\t", $time{serialize}, "s\n"; |
80 |
print STDOUT "dom5 check\t", $time{check}, "s\n" if defined $time{check}; |
print STDOUT "dom5 check\t", $time{check}, "s\n" if defined $time{check}; |
81 |
|
for (qw/decode parse serialize check/) { |
82 |
|
next unless defined $time{$_}; |
83 |
|
open my $file, '>>', ".$_.txt" or die ".$_.txt: $!"; |
84 |
|
print $file $char_length, "\t", $time{$_}, "\n"; |
85 |
|
} |
86 |
} else { |
} else { |
87 |
print STDOUT "Status: 404 Not Found\nContent-Type: text/plain; charset=us-ascii\n\n404"; |
print STDOUT "Status: 404 Not Found\nContent-Type: text/plain; charset=us-ascii\n\n404"; |
88 |
} |
} |