Forum Moderators: phranque

Message Too Old, No Replies

Help with "Script Directive"

         

danielv

9:30 am on Feb 21, 2011 (gmt 0)

10+ Year Member



Hi,

I have some problem with apache configuration and hope to get your help!
For some reason I lost POST data in part of requests (not consistent). As I found it may be caused by some rewrite rules.
Now I try to implement in some way translation of POST to GET requests on apache side (since it can't be done on client).
A I found in apache documentation ([httpd.apache.org ] that I can use Script Directive to apply perl script on request with the specific method.

I entered to the httpd.conf the following code:

# Define the folder as container for CGI handler
<Directory /<full path to local folder> >
Options +ExecCGI
</Directory>
# Define file types for CGI handler
AddHandler cgi-script cgi pl

# Apply specific script on any POST request
Script POST /<folder>/try.pl


Where the script will change the POST method to GET method using this code: [modperlbook.org ]
but for now it only should create the log file and print there request:

#!/bin/perl

use warnings;
use strict;
use Apache2::Const -compile => qw(M_GET);
use Output::Cmd;

my $logfile = "/tmp/try.log";
my $u = Output::Cmd->new('verbose' => 1, 'log' => $logfile);

my $r = shift;

$u->print("request: $r");
1;


I expect to get log file once any POST request is sent to the server, but it does not created...
Can somebody help me to understand how to tune this correctly?

Thank you in advance,

Daniel

jdMorgan

4:37 pm on Mar 8, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Because you have both the AddHandler for all .pl files and the Script directive for try.pl, I suspect that the AddHandler is being invoked first, and therefore the Script directive is never executed.

Jim