Home | History | Annotate | Download | only in resources
      1 #!/usr/bin/perl -w
      2 
      3 print "Content-type: text/plain\n\n"; 
      4 
      5 if ($ENV{'REQUEST_METHOD'} eq "POST") {
      6     if ($ENV{'CONTENT_LENGTH'}) {
      7         read(STDIN, $postData, $ENV{'CONTENT_LENGTH'}) || die "Could not get post data\n";
      8     } else {
      9         $postData = "";
     10     }
     11 
     12     @list = split(/&/, $ENV{'QUERY_STRING'});
     13     foreach $element (@list) {
     14         ($key, $value) = split(/=/, $element);
     15         $values{$key} = $value;
     16     }
     17 
     18     open FILE, $values{'path'} || die("Could not open file\n");
     19     seek FILE, $values{'start'}, 0;
     20     read FILE, $expectedData, $values{'length'};
     21     close(FILE);
     22 
     23     if ($postData eq $expectedData) {
     24         print "OK";
     25     } else {
     26         print "FAILED";
     27     }
     28 } else {
     29     print "Wrong method: " . $ENV{'REQUEST_METHOD'} . "\n";
     30 } 
     31