perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Cholet <cho...@logilune.com>
Subject RE: Help about $r->content( )
Date Wed, 01 Mar 2000 11:01:59 GMT
> Quoting cholet@logilune.com:
> :$r->args will read the query string (for GET requests)
> :$r->content will read the data from a POST.
> :
> :This is code a lot of people use:
> :
> :	my %params = $r->method eq 'POST' ? $r->content : $r->args;
> 
> Shouldn't this be abstrated through a "->params" feature that would
> do exactly the above? Low-level method probing like this is precisely
> what OO programming attempts to mask.

It depends. I have code that uses both the query string and the
posted data, so I change it to this:

 my %params = $r->method eq 'POST' ? ($r->content, $r->args) : $r->args;

Also, sometimes you don't want to hash because that will collapse
multiple values for the same key, so then you want to use an array
@params instead of a hash.

Then, there's the fact that $r->content only works for
application/x-www-form-urlencoded data, so calling $r->content
in a systematic way may not be desirable in all cases.

--
Eric


Mime
View raw message