On 02 Oct 2002 15:23 GMT you wrote:
>
> Hi!
>
> We're developing a perl module for apache/mod_perl, but have encountered a
> really strange problem.
>
> After 'a while' we seem to lose the data sent to the apache-server, at
> least it never reaches our module.
<SNIP>
> Recently we switched from using the standard Apache request-object to
> using the Apache::Request one, for the added functionality, but this has
> not had any effect at all as far as we can tell, and the bug keeps
> happening...
I ran into a problem that the param parts of a request were flushed when read for the
first time... so if you lose them (don't store them) then you cannot access them again.
If you are not already, then try
$apr = HTTP::Request->instance($r); instead...
Here is some code that I use to strip a request down and then store in a hashref for
each request. Almost every handler that I use calls this in the first instance. This
way $r will remain intact and $r_info is a really handy hashref.
sub handler {
my $r_info = r_info($r);
}
sub r_info {
my $r = shift;
my $s = $r->server;
my $c = $r->connection;
my $apr = Apache::Request->instance($r);
#Parse / Collect the parameters.
my %params;
foreach ($apr->param) {
$params{$_} = $apr->param($_);
}
my $r_info_headers = [r_headers($r)]->[1];
my $cookies = fetch CGI::Cookie;
my %hash;
undef %hash;
%hash = (
server_name => $r->get_server_name(),
server_port => $r->get_server_port(),
doc_root => $r->document_root(),
path_info => $r->path_info(),
method => $r->method(),
uri => $r->uri(),
params => \%params,
protocol => $r->protocol(),
server_admin => $s->server_admin(),
server_hostname=>$s->server_hostname(),
remote_ip => $c->remote_ip(),
headers => $r_info_headers,
cookies => $cookies
);
return (\%hash);
}
sub r_headers {
my $r = shift;
my (@list, $header, @headers_list, $value, %headers_hash);
@list = $r->headers_in;
while ($header = shift @list) {
$value = shift @list;
push (@headers_list, $header);
$headers_hash{$header} = $value;
}
return (\@headers_list, \%headers_hash);
}