replace deprecated Test::YAML::Meta by equivalent Test::CPAN::Meta::YAML
[perl/plp/.git] / lib / PLP / Fields.pm
index 7f07c4e914225e8f006e86a02db99b7391ee7471..52040e3f3455c082ff63c379a5d4d7235c907b37 100644 (file)
@@ -1,6 +1,9 @@
 package PLP::Fields;
 
 use strict;
+use warnings;
+
+our $VERSION = '1.00';
 
 # Has only one function: doit(), which ties the hashes %get, %post, %fields
 # and %header in PLP::Script. Also generates %cookie immediately.
@@ -9,7 +12,7 @@ sub doit {
        # %get
        
        my $get = \%PLP::Script::get;
-       if (length $ENV{QUERY_STRING}){
+       if (defined $ENV{QUERY_STRING} and length $ENV{QUERY_STRING}){
                for (split /[&;]/, $ENV{QUERY_STRING}) {
                        my @keyval = split /=/, $_, 2;
                        PLP::Functions::DecodeURI(@keyval);
@@ -22,13 +25,10 @@ sub doit {
 
        tie %PLP::Script::post, 'PLP::Tie::Delay', 'PLP::Script::post', sub {
                my %post;
-               my $post;
-               
-               return \%post if $ENV{CONTENT_TYPE} !~
-                       m!^(?:application/x-www-form-urlencoded|$)!;
-               
-               $post = $PLP::read->($ENV{CONTENT_LENGTH}) if $ENV{CONTENT_LENGTH};
+               return \%post unless $ENV{CONTENT_TYPE} and $ENV{CONTENT_LENGTH} and
+                       $ENV{CONTENT_TYPE} =~ m!^(?:application/x-www-form-urlencoded|$)!;
                
+               my $post = $PLP::read->($ENV{CONTENT_LENGTH});
                return \%post unless defined $post and length $post;
                
                for (split /&/, $post) {
@@ -114,6 +114,10 @@ when sending the headers is the one you used first. The following are equal:
     $header{Content_Type}
     $headers{CONTENT_type}
 
+If a value contains newlines, the header is repeated for each line:
+
+       $header{Allow} = "HEAD\nGET";  # equivalent to HEAD,GET
+
 =back
 
 =head1 AUTHOR