Fixed fallback on failed content negotiations.
authorshort <>
Thu, 25 Aug 2005 01:00:05 +0000 (01:00 +0000)
committershort <>
Thu, 25 Aug 2005 01:00:05 +0000 (01:00 +0000)
+Support: $W->{"xml_header_only"};
Cosmetic: Cleanup retrieval: $W->{"language"}

Web.pm

diff --git a/Web.pm b/Web.pm
index f67c47d..3eb176b 100644 (file)
--- a/Web.pm
+++ b/Web.pm
@@ -654,7 +654,7 @@ my($self,$variants)=@_;
                        # Do not: HTTP::Headers->new($W->{"r"}->headers_in());
                        # to prevent empty result or even: Odd number of elements in anonymous hash
                        HTTP::Headers->new(%{$W->{"r"}->headers_in()}));
-       $best||=$variants->[0]{"id"};   # &HTTP::Negotiate::choose failed?
+       $best||=$variants->[0][0];      # $variants->[0]{"id"}; &HTTP::Negotiate::choose failed?
        return $best;
 }
 
@@ -783,7 +783,6 @@ my($class)=@_;
        # FIXME: It is not clean to still append them without overwriting.
        return if $W->{"heading_done"}++;
 
-       my $lang=($W->{"language"}||"en-US");
        # Workaround bug
        #   https://bugzilla.mozilla.org/show_bug.cgi?id=120556
        # of at least
@@ -803,22 +802,23 @@ my($class)=@_;
                                        "content-type"=>"text/html",
                                        "qs"=>0.6,
                                        "charset"=>$client_charset,
-                                       "lang"=>$lang,
+                                       "lang"=>$W->{"language"},
                                        ),
                        negotiate_variant(
                                        "id"=>"application/xhtml+xml",
                                        "content-type"=>"application/xhtml+xml",
                                        "qs"=>0.6,
                                        "charset"=>$client_charset,
-                                       "lang"=>$lang,
+                                       "lang"=>$W->{"language"},
                                        ),
                        # application/xml ?
                        # text/xml ?
                        ]);
        $W->{"r"}->content_type("$mime; charset=$client_charset");
        Wprint '<?xml version="1.0" encoding="'.$client_charset.'"?>'."\n" if $mime=~m{^application/\w+[+]xml$};
+       return if $W->{"xml_header_only"};
        Wprint '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'."\n";
-       Wprint '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="'.$lang.'">'."\n";
+       Wprint '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="'.$W->{"language"}.'">'."\n";
        my $title=$W->{"title_prefix"}.join("",map({ ': '.$_; } ($W->{"title"} || ())));
        $title=~s#<[^>]*>##g;
        Wprint "<head>";