soaplog.cgi 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #! /usr/bin/perl
  2. ################################################################################
  3. # HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems(R).
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. #################################################################################
  17. use strict;
  18. use warnings;
  19. use Cwd qw(cwd);
  20. use Config::Simple qw();
  21. my $logfile;
  22. BEGIN
  23. {
  24. my $cfgfile = 'soapserver.ini';
  25. my $cfg = new Config::Simple();
  26. $cfg->read($cfgfile) or die("Could not read config file $cfgfile: $!");
  27. $logfile = $cfg->param('logfile') or die("No logfile in config file $cfgfile");
  28. }
  29. my $time = localtime();
  30. my $method = $ENV{REQUEST_METHOD} || 'NONE';
  31. unless($method eq 'POST')
  32. {
  33. print("Content-type: text/plain\n\n");
  34. print("Expected POST request, received $method\n");
  35. open(OUT, '>>', $logfile) or die("could not write to $logfile: $!");
  36. print(OUT "Bad request at $time: method was $method\n");
  37. close(OUT);
  38. exit(1);
  39. }
  40. open(OUT, '>>', $logfile) or die("could not write to $logfile: $!");
  41. print(OUT "Request at $time\n");
  42. print(OUT "[$_]=[$ENV{$_}]\n") foreach (sort(keys(%ENV)));
  43. print(OUT "[current directory]=[", cwd(), "]\n");
  44. print(OUT) while(<>);
  45. print(OUT "\n.\n\n");
  46. close(OUT);
  47. print("Content-type: text/xml\n\n");
  48. print("<ok/>\n");