From: Tom Robinson Date: 2002-09-04T05:23:02+09:00 Subject: Re: cgi redirect On Tue, 03 Sep 2002 14:50:25 GMT, "Bob Calco" wrote: >In Ruby, you can always add the method you want to CGI dynamically: > >require 'cgi' > >class CGI > def redirect( where ) > print this.header( { 'Status' => '302 Moved', 'location' => >'#{where}' } ) > end >end But that doesn't give the desired result, as I said, using CGI#header in this way also prints out the content-type header - which CGI.pm doesn't. You would want: class CGI def redirect(url) "Status: 302 Moved\nlocation: #{url}\n\n" end end which would then be used as similar to CGI.pm: print cgi.redirect('http://location.com/') You would also have to consider that the above is incompatible with the way the header handling works under mod_ruby (header is sent straight away rather than returned, I think). I agree with you that the way you can 'dip in' to existing classes from anywhere in ruby is great, but I still think CGI#header should be in the standard cgi.rb, as it's very commonly required. -- tom@alkali.spamfree.org remove 'spamfree.' to respond