From: David Vallner Date: 2006-11-08T20:02:31+09:00 Subject: Re: CGI and POST/PUT URL Variables --------------enigD070094529A7DAACA84EBBCB Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Trevor Elliott wrote: > Hi Everyone, >=20 > I encountered a strange problem when trying to write a cgi script to > handle a PUT/POST scenario for a set of REST-style web services I'm > writing in Ruby. >=20 > If I do a normal post to a url, say: >=20 > /cgi-bin/cgi.rb?a=3D1&b=3D1 >=20 > The params attribute in the CGI class contains {'a'=3D>'1', 'b'=3D>'1'}= =2E > However, when doing a PUT or POST to the same URL, the params hash > contains two elements, one that's empty, and the other that is keyed on= > the payload to the PUT/POST operation. >=20 > Can anyone see my error? >=20 There is no error, Ruby's CGI module ignores the query string when the method isn't GET. AFAIK, this is correct behaviour, you put all query parameters into the body of the request when using POST - no idea about PUT, that method only sees use with REST, which has been of only passing interest to me. [insert rant about HTTP flawedness and bending over business logic backwards to be stateless here] Either redo the client code to use the proper way of passing the query string to the application, or redo the CGI script to manually parse the request string for the query string. The CGI module should have some functionality for that. Also, see http://www.w3.org/Provider/Style/URI for why "/cgi-bin/" and ".rb" are bad, bad things to put in your URL. David Vallner --------------enigD070094529A7DAACA84EBBCB Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (MingW32) iD8DBQFFUblAy6MhrS8astoRAomAAJsHRBVKfE8vkNVe7s5RuvapmvFlgACfZB/G vIc1W5LkNiSn3axROsr2XBA= =m4m/ -----END PGP SIGNATURE----- --------------enigD070094529A7DAACA84EBBCB--