From 4d28489febce59b69649ee9ab5103864a0bfde8c Mon Sep 17 00:00:00 2001 From: short <> Date: Mon, 22 Aug 2005 01:57:35 +0000 Subject: [PATCH] Provide header only if XHTML got negotiated. $W->{"user_agent"} is now set to "" if not defined. Force XHTML for: http://validator.w3.org/ --- Web.pm | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Web.pm b/Web.pm index 8b1859c..88b0aff 100644 --- a/Web.pm +++ b/Web.pm @@ -202,8 +202,8 @@ my($class,%args)=@_; $W->{"args"}{$name}=[@vals]; } - do { $W->{$_}=$W->{"r"}->headers_in()->{"Accept"} if !defined $W->{$_}; } for ("accept"); - do { $W->{$_}=$W->{"r"}->headers_in()->{"User-Agent"} if !defined $W->{$_}; } for ("user_agent"); + do { $W->{$_}=$W->{"r"}->headers_in()->{"Accept"} if !defined $W->{$_}; } for ("accept"); + do { $W->{$_}=$W->{"r"}->headers_in()->{"User-Agent"}||"" if !defined $W->{$_}; } for ("user_agent"); $W->{"browser"}=HTTP::BrowserDetect->new($W->{"user_agent"}); @@ -788,7 +788,10 @@ my($class)=@_; # https://bugzilla.mozilla.org/show_bug.cgi?id=120556 # of at least # Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8b) Gecko/20050217 - my $mime=$class->Negotiate_choose([ + my $mime; + # http://validator.w3.org/ does not send ANY "Accept" headers! + $mime||="application/xhtml+xml" if $W->{"user_agent"}=~m{^W3C_Validator/}i; + $mime||=$class->Negotiate_choose([ # Put the fallback variant as the first one. # Rate both variants the same to prefer "text/html" for undecided clients. # At least @@ -813,9 +816,7 @@ my($class)=@_; # text/xml ? ]); $W->{"r"}->content_type("$mime; charset=$client_charset"); - if (1) { # (|| !$msie_major || $msie_major>=4) # TODO:dyn - Wprint ''."\n"; - } + Wprint ''."\n" if $mime=~m{^application/\w+[+]xml$}; Wprint ''."\n"; Wprint ''."\n"; my $title=$W->{"title_prefix"}.join("",map({ ': '.$_; } ($W->{"title"} || ()))); -- 1.8.3.1