I assert that initialize_query is broken. CGI::parse should always be
called on the QUERY_STRING, no matter if the REQUEST_METHOD is POST or
GET.
I would also say that instead of @params being an Array of Strings, it
should contain String like object that have an additional property that
indicates the parameter source, i.e. GET, POST, or COOKIE. Cookies
should also be in the @params so they can be [] found.
The only other point on this would be to allow optional order of
parsing, and thus the @params component array orders.
This is a staple of web programming and is something PHP does right and
JSP does wrong.
I think this can all be done in the dist cgi.rb without causing anyone
headaches.
Can these changes be incorporated into the next 1.8 with my help?
Dan
Biggest problem: one would overwrite the other, unless your string-like
objects were used as keys and hashed differently depending on origin.
Better to have separate arrays for get and post… ala modern PHP.
Ari
···
On Sun, Jan 25, 2004 at 12:30:57AM +0900, Dan Janowski wrote:
I assert that initialize_query is broken. CGI::parse should always be
called on the QUERY_STRING, no matter if the REQUEST_METHOD is POST or
GET.
cgi params are always an array of values for a given key. A variety of
accessors are both possible and practical. Allow me to explain:
cgi[‘param’] returns the last value for param among get post and cookie
(the 1.8 behavior is first instance, I think it should be last
instance. This allows a form posted value to be easily used to override
a query string value. Good since forms are typically used to get input
from the client)
cgi.params(‘param’) an array of all values
cgi.cookies(‘param’) returning only cookies (not an array for param)
cgi.params_get(‘param’) an array of only gets
cgi.params_post(‘param’) an array of only posts
params_get(‘param’) is really just: @params.collect {|po| po if
po.is_a? Get }.compact
get and post vals should be Get < String and Post < String.
This way a value gotten from cgi[‘param’] can be detected as post or
get or cookie.
···
On Jan 24, 2004, at 10:55 AM, Aredridel wrote:
On Sun, Jan 25, 2004 at 12:30:57AM +0900, Dan Janowski wrote:
I assert that initialize_query is broken. CGI::parse should always
be
called on the QUERY_STRING, no matter if the REQUEST_METHOD is POST or
GET.
Biggest problem: one would overwrite the other, unless your string-like
objects were used as keys and hashed differently depending on origin.
Better to have separate arrays for get and post… ala modern PHP.
Ari