httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jody Biggs <j...@codegrok.com>
Subject Apache::Request patch request (fwd)
Date Tue, 06 Mar 2001 18:56:12 GMT
I was having trouble setting a param to hold multiple values, and then
retrieving them using Apache Request, as
such:

sub handler
{
  my $r = Apache::Request->new (shift);
  $r->param ( 'foo' => [qw(a few element long list)] );
  my @foolist = $r->param ( 'foo' );
  # would get scalar (@foolist) == 1
  # with that one element being an array ref
  #
  # actually, i'm not sure if it was an actual array ref,
  # or just a string containing "ARRAY(0x.......)", but whatever
  
  #...
}



anyhow, I think the problem was just that Request.pm holds:

sub param {
    #...
    if (defined $value) {
        $tab->set($name, $value);
    }
    #...
}

however, $tab, which if I'm correct in assuming is an Apache::Table
object, only accepts string values to set, which means you get your array
ref converted to a string when it gets set.

I changed the set to add, which will accept strings or arrayrefs for the
value, and everything worked as I expected.  However, there may be an
issue if the param was already set, and you wished to overwrite the
value(s) associated with it.  Hence, it would make sense to call unset
first.

so:

sub param {
    #...
    if (defined $value) {
        $tab->unset($name);
        $tab->add($name, $value);
    }
    #...
}


anyhow, I hope that all made sense, and that I'm not missing some obvious
point in all of this.  If it does make sense, I'd certainly like to see
the fix incorporated in the next version of libapreq (or however it
makes sense to release it).

thanks -
Jody Biggs
VP Product Engineering
CodeGrok Inc.



Mime
View raw message