--- test/html-webhacc/cc.cgi 2007/07/17 14:28:20 1.14
+++ test/html-webhacc/cc.cgi 2007/09/02 07:59:01 1.17
@@ -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[
@@ -194,7 +210,7 @@
require Whatpm::ContentChecker;
my $onerror = sub {
my %opt = @_;
- my ($type, $cls, $msg) = get_text ($opt{type}, $opt{level});
+ my ($type, $cls, $msg) = get_text ($opt{type}, $opt{level}, $opt{node});
$type =~ tr/ /-/;
$type =~ s/\|/%7C/g;
$msg .= qq[ [Description]];
@@ -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[
@@ -279,7 +298,7 @@
];
for my $id (sort {$a cmp $b} keys %{$elements->{id}}) {
- print STDOUT qq[- @{[htescape $id]}
];
+ print STDOUT qq[@{[htescape $id]}
];
for (@{$elements->{id}->{$id}}) {
print STDOUT qq[- ].get_node_link ($_).qq[
];
}
@@ -313,7 +332,7 @@
];
for my $class (sort {$a cmp $b} keys %{$elements->{class}}) {
- print STDOUT qq[- @{[htescape $class]}
];
+ print STDOUT qq[@{[htescape $class]}
];
for (@{$elements->{class}->{$class}}) {
print STDOUT qq[- ].get_node_link ($_).qq[
];
}
@@ -348,6 +367,12 @@