^_args_check: Fixed missing &init startup during My::Web cleanup.
[MyWeb.git] / Web.pm
diff --git a/Web.pm b/Web.pm
index 1a3f9e0..f2c45cf 100644 (file)
--- a/Web.pm
+++ b/Web.pm
@@ -37,6 +37,7 @@ our @EXPORT=qw(
                $W
                &input_hidden_persistents
                &escapeHTML
+               &form_method
                );
 our @ISA=qw(Tie::Handle Exporter);
 
@@ -66,7 +67,6 @@ BEGIN
                $callers{$selfpkg}=1;
                for my $target ($class,__PACKAGE__) {
                        for my $caller (keys(%callers)) {
-                               next if $caller eq $target;
                                next if $packages_used_hash{$caller}{$target}++;
                                cluck "Appending to the '_done' package list: caller=$caller,target=$target"
                                                if $packages_used_hash{$caller}{"_done"};
@@ -121,12 +121,16 @@ require Digest::MD5;
 require Data::Compare;
 use Data::Dumper;
 require Encode;
+use Apache2::RequestUtil;
 use Apache2::Filter;
 use Apache2::Connection;
 require MIME::Base64;
 use Apache2::ServerUtil;
 require MIME::Types;
 require MIME::Parser;
+use Apache2::RequestRec;
+use Apache2::RequestIO;
+use Apache2::Response;
 
 
 #our $W;
@@ -272,12 +276,24 @@ my($class,%args)=@_;
                $W->{"head"}.='<script type="application/javascript" src="'.uri_escaped(path_web('/My/HaveJS.pm')).'"></script>'."\n";
                }
 
-       do { _args_check(%$_) if $_; } for ($W->{"args_check"});
-
+       # Required by &_args_check below.
        $W->{"_init_done"}=1;
+
+       do { _args_check(%$_) if $_; } for $W->{"args_check"};
+
        return $W;
 }
 
+sub form_method($)
+{
+my($method)=@_;
+
+       return q{enctype="application/x-www-form-urlencoded" accept-charset="us-ascii utf-8"} if $method eq "post";
+       return                                             q{accept-charset="us-ascii utf-8"} if $method eq "get";
+       cluck "Undefined method: $method";
+       return ""
+}
+
 sub merge_post_args($)
 {
 my($class)=@_;
@@ -633,6 +649,7 @@ my($msg)=@_;
        if (!$W->{"heading_done"}) {
                $W->{"indexme"}=0;      # For the case no heading was sent yet.
                $W->{"header_only"}=0;  # assurance for &heading
+               $W->{"content_type"}="text/html";       # Force HTML and avoid strictly checked XHTML.
                My::Web->heading();
                }
        Wprint "\n".vskip("3ex")."<hr /><h1 class=\"error\">FATAL ERROR: $msg!</h1>\n"