From: mde@...26.com Date: 2004-12-25T16:38:10+09:00 Subject: Re: [PATCH] cgi.rb -- more GET/POST stuff Some more thoughts / clarification on cgi.rb. This might be a bit long ... While the question of when it's appropriate to use GET versus POST is interesting (BTW, I'm not sure I agree with the idea that you should always expect to be able to bookmark or e-mail URIs -- especially in a Web application environment), it's not really relevant to the problem I was describing with cgi.rb. I guess my poor choice of example (the session ID) is to blame for that. The problem is that cgi.rb does not allow you to use any query string variables at all, if you use the POST method. Take, for example, a URI which is pretty normal for any Front Controller / Page Controller setup for a Web app: /processingpage.rbx?module=account If I try to POST to this page, the initialize_query() function does not pick up the variables from the query string, so cgi['module'] is not there. There are, of course, a couple of workarounds -- e.g., submitting hidden form elements or parsing the data myself off cgi.rb's query_string environment variable. But other mainstream Web programming languages like PHP or ASP don't force me to do this -- query string vars show up properly whether I choose to use GET or POST to request a URI. Unless there is some specific reason that POSTs should ignore what's on the query string, it might be nice for Web programmers moving to Ruby if it were as easy as the other languages they have used -- and as intuitive as the rest of Ruby. Regarding Eustaquio's idea of having two separate hashes for GET and POST, I think it makes good sense too -- PHP and ASP have similar setups (PHP's $_GET and $_POST, and ASP's Request.QueryString and Request.Form), so you can distinguish between the two when you want to. But they also have a unified hash (PHP's $_REQUEST and ASP's Request) with everything in it. However, in practice, the only time I've ever actually needed to specify one or the other was with legacy code where the developer had made the confusing decision to use identically named varibles (with two different values), one on the query string and one in the form. I'm thinking this is probably not a great idea, and likely not something you should do all the time, anyway. If anybody has insight into how other Web programming languages handle GET/POST/Cookies, that might be helpful to know. I'm just using PHP and ASP as examples because it's what I know, and they are really widespread as Web languages. Hope I didn't put you folks to sleep. Thanks. Matthew