X-Git-Url: http://git.jankratochvil.net/?a=blobdiff_plain;f=Web.pm;h=dbb9c44a06add15277326c27777d1f19b7ad4bf4;hb=4e6161858714cf6b06278b32e36df915ef81c6fc;hp=ad685e6ce502dd89638312b54326ca9d7d6d8325;hpb=a20ecc379dc3b96fc5646b3915022a9ffa399d9b;p=MyWeb.git diff --git a/Web.pm b/Web.pm index ad685e6..dbb9c44 100644 --- a/Web.pm +++ b/Web.pm @@ -145,8 +145,8 @@ my($class,%args)=@_; # $W={} can get somehow created very easily. cluck "W not empty:\n".Dumper($W) if keys(%$W); - $W=bless My::Hash->new({}),$class; - $W=My::Hash->new($W,"My::Hash::Sub","My::Hash::Push"); + $W=My::Hash->new({},"My::Hash::Sub","My::Hash::Push"); + bless $W,$class; %$W=( "__PACKAGE__"=>scalar(caller()), %WebConfig, @@ -260,7 +260,10 @@ my($class,%args)=@_; }; if (!defined $W->{"have_style"}) { - $W->{"have_style"}=(!$W->{"browser"}->netscape() || ($W->{"browser"}->major() && $W->{"browser"}->major()>4) ? 1 : 0); + $W->{"have_style"}=sub { + # Lazy-evaluation, we may not need the "User-Agent" header at all. + return our $r||=(!$W->{"browser"}->netscape() || ($W->{"browser"}->major() && $W->{"browser"}->major()>4) ? 1 : 0); + }; } $W->{"have_js"}=($W->{"args"}{"have_js"} ? 1 : 0); @@ -513,10 +516,22 @@ my($msg)=@_; exit; } +sub footer_packages_used_comments() +{ + my $packages_used=$packages_used_array{$W->{"__PACKAGE__"}}; + for my $package (@$packages_used) { + my $cvs_id=(eval('$'.$package."::CVS_ID") +# || $package # debug + ); + Wprint ''."\n" if $cvs_id; + } +} + sub footer() { cluck 'Explicit &footer call is deprecated, !_exit_dne' if !$W->{"_exit_done"}; exit if $W->{"footer_done"}++; # deadlock prevention: + &{$_}() for reverse @{$W->{"footer_sub_push"}}; if ($W->{"header_only"}) { $packages_used_hash{$W->{"__PACKAGE__"}}{"_done"}=1; exit; @@ -568,12 +583,7 @@ sub footer() Wprint "

\n"; } - for my $package (@$packages_used) { - my $cvs_id=(eval('$'.$package."::CVS_ID") -# || $package # debug - ); - Wprint ''."\n" if $cvs_id; - } + packages_used_comments(); do { Wprint $_ if $_; } for $W->{"footing"}; @@ -696,6 +706,7 @@ my($self,$url,$status)=@_; $W->{"r"}->headers_out()->{"Location"}=$url; $W->{"header_only"}=1; $W->{"content_type"}=0; + $W->{"charset"}=0; My::Web->heading(); exit; die "NOTREACHED"; @@ -1093,7 +1104,8 @@ my($class)=@_; header("Cache-Control"=>"public"); # HTTP/1.1 # Use $W->{"charset"}=0 to disable charset. - $W->{"charset"}="us-ascii" if !defined $W->{"charset"} && !defined($W->{"content_type"}) || $W->{"content_type"}; + $W->{"charset"}="us-ascii" + if !defined $W->{"charset"} && (!defined($W->{"content_type"}) || $W->{"content_type"}); # Workaround bug # https://bugzilla.mozilla.org/show_bug.cgi?id=120556 @@ -1144,7 +1156,9 @@ my($class)=@_; # FIXME: It is not clean to still append them without overwriting. return if $W->{"heading_done"}; Wprint '{"charset"}.'"?>'."\n" - if (!$W->{"header_only"} || $W->{"header_only"} eq "xml") && $W->{"content_type"}=~m{^application/\w+[+]xml$}; + if (!$W->{"header_only"} || $W->{"header_only"} eq "xml") && (0 + || $W->{"content_type"}=~m{^application/\w+[+]xml$} + || $W->{"content_type"} eq "text/vnd.wap.wml"); return if $W->{"header_only"}; # Split 'heading_done' for the proper handling of: /project/Rel.pm $W->{"heading_done"}++;