From: Sean Chittenden Date: 2002-05-10T08:24:31+09:00 Subject: Re: cgi params api > > cgi.rb has undocumented method "CGI#param". > > > > cgi.param["name"] # == cgi.params["name"].join("\0") > > > > > > > > now : cgi["name"] == cgi.params["name"] > > future?: cgi["name"] == cgi.param["name"] > > > > if cgi["name"] == cgi.param["name"] then > > > > cgi["name"].to_a # ["value1", "value2", "value3",...] > > > > how about? > > This looks better than my suggestion. I like that you make the single > param with the join. to_a is also a better name than multiple. Before these cgi param threads get too far down whatever path they're going, let me drop in a few words. *) cgi.rb's behavior of having multiple args per key _is_ correct *) a common line that I use is: username = CGI::escapeHTML(cgi['username'].to_s) if cgi.has_key?('username') *) I'm working on parsing apache requests into an Apache::Table instance for mod_ruby. reqs = r.get_params() # Just GET parameters reqs = r.post_params() # Just POST parameters reqs = r.params() # Both GET and POST parameters reqs will be an instance of Apache::Table. Apache::Table allows for multiple values per key, which is correct for HTTP. If you access reqs['key'], then you'll always get a non-array object. reqs.get_array['key'] will return you an array like cgi.rb does currently. *) As for breaking out some of it's other, more useful features, IMHO such as escapeHTML and escapeURI, I'm hoping those get placed into an Apache::Util module. -sc -- Sean Chittenden