--- test/html-webhacc/cc.cgi 2007/07/21 04:58:17 1.15
+++ test/html-webhacc/cc.cgi 2007/08/11 13:54:55 1.16
@@ -2,12 +2,10 @@
use strict;
use lib qw[/home/httpd/html/www/markup/html/whatpm
- /home/wakaba/work/manakai/lib
- /home/wakaba/public_html/-temp/wiki/lib];
+ /home/wakaba/work/manakai2/lib];
use CGI::Carp qw[fatalsToBrowser];
use Scalar::Util qw[refaddr];
-
-use SuikaWiki::Input::HTTP; ## TODO: Use some better CGI module
+use Time::HiRes qw/time/;
sub htescape ($) {
my $s = $_[0];
@@ -21,11 +19,10 @@
return $s;
} # htescape
-my $http = SuikaWiki::Input::HTTP->new;
-
-## TODO: _charset_
+ use Message::CGI::HTTP;
+ my $http = Message::CGI::HTTP->new;
- if ($http->meta_variable ('PATH_INFO') ne '/') {
+ if ($http->get_meta_variable ('PATH_INFO') ne '/') {
print STDOUT "Status: 404 Not Found\nContent-Type: text/plain; charset=us-ascii\n\n400";
exit;
}
@@ -54,7 +51,11 @@
$| = 0;
my $input = get_input_document ($http, $dom);
- my $inner_html_element = $http->parameter ('e');
+ my $inner_html_element = $http->get_parameter ('e');
+ my $char_length = 0;
+ my %time;
+ my $time1;
+ my $time2;
print qq[
@@ -67,6 +68,7 @@
push @nav, ['#document-info' => 'Information'];
if (defined $input->{s}) {
+ $char_length = length $input->{s};
print STDOUT qq[
Base URI
@@ -77,6 +79,8 @@
Character Encoding
@{[defined $input->{charset} ? ''.htescape ($input->{charset}).'
' : '(none)']}
@{[$input->{charset_overridden} ? '(overridden)' : '']}
+Length
+ $char_length byte@{[$char_length == 1 ? '' : 's']}
];
@@ -91,8 +95,11 @@
require Whatpm::HTML;
$input->{charset} ||= 'ISO-8859-1'; ## TODO: for now.
-
+
+ $time1 = time;
my $t = Encode::decode ($input->{charset}, $input->{s});
+ $time2 = time;
+ $time{decode} = $time2 - $time1;
print STDOUT qq[
@@ -117,6 +124,7 @@
};
$doc = $dom->create_document;
+ $time1 = time;
if (defined $inner_html_element and length $inner_html_element) {
$el = $doc->create_element_ns
('http://www.w3.org/1999/xhtml', [undef, $inner_html_element]);
@@ -124,6 +132,8 @@
} else {
Whatpm::HTML->parse_string ($t => $doc, $onerror);
}
+ $time2 = time;
+ $time{parse} = $time2 - $time1;
print STDOUT qq[
@@ -132,6 +142,9 @@
print_source_string_section (\($input->{s}), $input->{charset});
} elsif ({
'text/xml' => 1,
+ 'application/atom+xml' => 1,
+ 'application/rss+xml' => 1,
+ 'application/svg+xml' => 1,
'application/xhtml+xml' => 1,
'application/xml' => 1,
}->{$input->{media_type}}) {
@@ -153,9 +166,12 @@
return 1;
};
+ $time1 = time;
open my $fh, '<', \($input->{s});
$doc = Message::DOM::XMLParserTemp->parse_byte_stream
($fh => $dom, $onerror, charset => $input->{charset});
+ $time2 = time;
+ $time{parse_xml} = $time2 - $time1;
print STDOUT qq[
@@ -202,12 +218,15 @@
qq[\n], $msg, "\n";
};
+ $time1 = time;
my $elements;
if ($el) {
$elements = Whatpm::ContentChecker->check_element ($el, $onerror);
} else {
$elements = Whatpm::ContentChecker->check_document ($doc, $onerror);
}
+ $time2 = time;
+ $time{check} = $time2 - $time1;
print STDOUT qq[
@@ -348,6 +367,12 @@