[Catalyst-dev] Separate access to query string and body parameters

Alex Pavlovic alex at taskforce-1.com
Fri Aug 5 12:27:36 CEST 2005


Hi Dan,

Me and Dan go back, way back :). Again good ideas and nice to hear from
you. I just had some comments for you below:

On Friday 05 August 2005 01:55, Dan Kubb wrote:
> Marcus said I should post a message to the dev list about a possible
> patch to Catalyst::Request (and the engines) that would add the ability
> for you to access the query string parameters separately from any
> parameters passed in with a POST request.

Sounds good, php does it too ( $_GET, $_POST, $_REQUEST ). 

> The reason for this is to keep the meaning between the two pieces
> of information separate.  One is part of the URI -- the unique
> identifier of a resource on the web -- and the other is metadata
> for a request operation performed on a resource.

True at the higher conceptual level, although at the lower request level
both "POST" and "GET" request types result in fields that are in 
the form of "key1=value1&key2=value2...."

Here is some examples ( using google and keyword "blah", probably will wrap ):

#GET
http://web-sniffer.net/?url=http%3A%2F%2Fwww.google.ca%2Fsearch%3Fhl%3Den%26ie%3DISO-8859-1%26q%3Dblah%26btnG%3DGoogle%2BSearch%26meta%3D&submit=Submit&http=1.1&rawhtml=yes&gzip=yes&type=GET&ua=Mozilla%2F5.0+%28compatible%3B+Konqueror%2F3.4%3B+FreeBSD%29+KHTML%2F3.4.1+%28like+Gecko%29+Web-Sniffer%2F1.0.21

#POST
http://web-sniffer.net/?url=http%3A%2F%2Fwww.google.ca%2Fsearch%3Fhl%3Den%26ie%3DISO-8859-1%26q%3Dblah%26btnG%3DGoogle%2BSearch%26meta%3D&submit=Submit&http=1.1&rawhtml=yes&gzip=yes&type=POST&ua=Mozilla%2F5.0+%28compatible%3B+Konqueror%2F3.4%3B+FreeBSD%29+KHTML%2F3.4.1+%28like+Gecko%29+Web-Sniffer%2F1.0.21

> Many frameworks don't make it easy enough to do the right thing and
> some even encourage "broken" usage of HTTP.  I'd like to make sure that
> Catalyst doesn't prevent people from doing things according to the
> RFCs should they wish to, while not placing any unnecessary burden on
> developers who don't care either way.
>
> Anyway.. thats my reasoning.  Here's what I want to do:
>
> I'd like to add two methods to C::Request called query and body
> that work like this:

You meant "Catalyst::Request" right ? Why not name methods something
like "get" and "post". I don't think those are used currently. You
could also expand this and add methods
for other request types.

>
>    # query()  -- for the query string
>
>    my @fields = $req->query;
>    my $value  = $req->query($field);
>    my @values = $req->query($field);
>
>    $req->query($field => $value);
>    $req->query($field => @values);
>
>
>    # body()   -- for the body data
>
>    my @fields = $req->body;
>    my $value  = $req->body($field);
>    my @values = $req->body($field);
>
>    $req->body($field => $value);
>    $req->body($field => @values);
>
> The param method will obviously need to continue to work, but it
> could be made into a wrapper around the query and body methods
> if you didn't want to have any duplication of data under the hood.
> Otherwise I could just leave it alone -- although I'd vote for
> wrapping.

Wrapping and combining sources is probably a good idea. Again
this is "Catalyst" and the "DRY" concept.


Thanks.

>
> _______________________________________________
> Catalyst-dev mailing list
> Catalyst-dev at lists.rawmode.org
> http://lists.rawmode.org/mailman/listinfo/catalyst-dev



More information about the Catalyst-dev mailing list