--- test/html-webhacc/cc.cgi 2007/11/11 06:57:16 1.24 +++ test/html-webhacc/cc.cgi 2007/11/18 05:30:03 1.25 @@ -62,7 +62,12 @@
Request URI
<@{[htescape $input->{request_uri}]}>
Document URI
-
<@{[htescape $input->{uri}]}>
+
<@{[htescape $input->{uri}]}> +
]; # no yet push @nav, ['#document-info' => 'Information']; @@ -74,7 +79,7 @@
<@{[htescape $input->{base_uri}]}>
Internet Media Type
@{[htescape $input->{media_type}]} - @{[$input->{media_type_overridden} ? '(overridden)' : '']}
+ @{[$input->{media_type_overridden} ? '(overridden)' : defined $input->{official_type} ? $input->{media_type} eq $input->{official_type} ? '' : '(sniffed; official type is: '.htescape ($input->{official_type}).')' : '(sniffed)']}
Character Encoding
@{[defined $input->{charset} ? ''.htescape ($input->{charset}).'' : '(none)']} @{[$input->{charset_overridden} ? '(overridden)' : '']}
@@ -93,7 +98,8 @@ if ($input->{media_type} eq 'text/html') { ($doc, $el) = print_syntax_error_html_section ($input, $result); - print_source_string_section (\($input->{s}), $input->{charset}); + print_source_string_section + (\($input->{s}), $input->{charset} || $doc->input_encoding); } elsif ({ 'text/xml' => 1, 'application/atom+xml' => 1, @@ -997,9 +1003,6 @@ ## TODO: More strict parsing... my $ct = $res->header ('Content-Type'); - if (defined $ct and $ct =~ m#^([0-9A-Za-z._+-]+/[0-9A-Za-z._+-]+)#) { - $r->{media_type} = lc $1; - } if (defined $ct and $ct =~ /;\s*charset\s*=\s*"?([^\s;"]+)"?/i) { $r->{charset} = lc $1; $r->{charset} =~ tr/\\//d; @@ -1010,9 +1013,22 @@ $r->{charset_overridden} = (not defined $r->{charset} or $r->{charset} ne $input_charset); $r->{charset} = $input_charset; - } + } + + ## TODO: Support for HTTP Content-Encoding $r->{s} = ''.$res->content; + + require Whatpm::ContentType; + ($r->{official_type}, $r->{media_type}) + = Whatpm::ContentType->get_sniffed_type + (get_file_head => sub { + return substr $r->{s}, 0, shift; + }, + http_content_type_byte => $ct, + has_http_content_encoding => + defined $res->header ('Content-Encoding'), + supported_image_types => {}); } else { $r->{uri} = $res->request->uri; $r->{request_uri} = $request_uri; @@ -1034,6 +1050,16 @@ $r->{charset} =~ s/\s+//g; $r->{charset} = 'utf-8' if $r->{charset} eq ''; $r->{header_field} = []; + + require Whatpm::ContentType; + ($r->{official_type}, $r->{media_type}) + = Whatpm::ContentType->get_sniffed_type + (get_file_head => sub { + return substr $r->{s}, 0, shift; + }, + http_content_type_byte => undef, + has_http_content_encoding => 0, + supported_image_types => {}); } my $input_format = $http->get_parameter ('i'); @@ -1100,4 +1126,4 @@ =cut -## $Date: 2007/11/11 06:57:16 $ +## $Date: 2007/11/18 05:30:03 $