[#3907] Obtaining mode information on an IO object — Jos Backus <jos@...>

The attached patch implements IO#mode. This method returns the mode the IO

17 messages 2004/12/06
[#3909] Re: [patch] Obtaining mode information on an IO object — nobu.nokada@... 2004/12/07

Hi,

[#3910] Re: [patch] Obtaining mode information on an IO object — Jos Backus <jos@...> 2004/12/07

On Tue, Dec 07, 2004 at 09:25:13AM +0900, nobu.nokada@softhome.net wrote:

[#3925] Re: [patch] Obtaining mode information on an IO object — James Britt <ruby@...> 2004/12/09

Jos Backus wrote:

[#4009] cgi.rb -- more GET/POST stuff — mde@...26.com

First of all, I think it would be great, as Eustaquio suggests, to

17 messages 2004/12/23
[#4016] Re: [PATCH] cgi.rb -- more GET/POST stuff — Francis Hwang <sera@...> 2004/12/24

GETs and POSTs are defined to be fairly different actions. I'd read

[#4027] Allowing custom number literal suffixes? — Florian Gro<florgro@...>

Moin!

35 messages 2004/12/27
[#4070] Re: Allowing custom number literal suffixes? — nobu.nokada@... 2005/01/02

Hi,

[#4072] Re: Allowing custom number literal suffixes? — Mathieu Bouchard <matju@...> 2005/01/02

[#4079] Re: Allowing custom number literal suffixes? — Florian Gro<florgro@...> 2005/01/03

Mathieu Bouchard wrote:

[#4081] Re: Allowing custom number literal suffixes? — Mathieu Bouchard <matju@...> 2005/01/03

[#4082] Re: Allowing custom number literal suffixes? — Florian Gro<florgro@...> 2005/01/03

Mathieu Bouchard wrote:

[#4084] Re: Allowing custom number literal suffixes? — Brent Roman <brent@...> 2005/01/04

I'm not sure I would advocate making Ruby's grammar even more

[#4086] Re: Allowing custom number literal suffixes? — Mathieu Bouchard <matju@...> 2005/01/04

[#4033] Garbage collection trouble — Christian Neukirchen <chneukirchen@...>

Hello,

13 messages 2004/12/27

[PATCH] cgi.rb -- more GET/POST stuff

From: mde@...26.com
Date: 2004-12-23 05:38:45 UTC
List: ruby-core #4009
First of all, I think it would be great, as Eustaquio suggests, to
be able to distinguish between CGI GET and POST vars.

However, having said that, as a Web programmer who started
work mostly with ASP/PHP and now work with Ruby and Perl,
I have to say that the biggest deficiency in cgi.rb is that
using POST method makes variables disappear completely from
the query string of the processing file (i.e., the "action"
property of the Web form).

It is common practice in Web programming to pass non-changing
values (like a session ID) around on the query string in an
automated fashion, even if posting a form (e.g.,
<form method="POST" action="proc.rbx?sessionid=adsfasdf2112">).

In the Web programming languages that a lot of people start out
on, there is one single place to look for all data coming back
to the processing page (PHP's $_REQUEST and ASP's Request).
This is farily intuitive, and only becomes an issue when
you make the bonehead mistake of using two identically named
variables -- and as long as rules of precence are documented
(i.e., GET before POST), it's not usually a big issue, in
my experience.

I have a feeling there will be more and more Web programmers
like me who will be trying out Ruby, and unless there is some
specific reason to make it an exclusive 'either/or' choice,
it might be nice if cgi.rb acted as intuitively for Web
programmers as the rest of Ruby does.

Again, I think Eustaquio has a good idea -- but for me the
biggest issue is that vanishing query string.

bollowing is a patch I've been using for awhile with cgi.rb
languages 
to keep query string variables from disappearing when I use a
POST. I'd love to know if there's a better or 'more Rubyish'
way to do it.

Thanks.


Matthew

--- cgi.rb      2004-11-01 17:49:15.000000000 -0600
+++ cgi.rb.new  2004-12-22 22:30:00.000000000 -0600
@@ -1102,24 +1102,28 @@
         @multipart = true
         @params = read_multipart(boundary, Integer(env_table['CONTENT_LENGTH']))
       else
-        @multipart = false
-        @params = CGI::parse(
-                    case env_table['REQUEST_METHOD']
-                    when "GET", "HEAD"
-                      if defined?(MOD_RUBY)
-                        Apache::request.args or ""
-                      else
-                        env_table['QUERY_STRING'] or ""
-                      end
-                    when "POST"
-                      stdinput.binmode if defined? stdinput.binmode
-                      stdinput.read(Integer(env_table['CONTENT_LENGTH'])) or ''
-                    else
-                      read_from_cmdline
-                    end
-                  )
+          allparams = ''
+            case env_table['REQUEST_METHOD']
+              when "GET", "HEAD", "POST"
+                if defined?(MOD_RUBY)
+                  allparams += (Apache::request.args or '')
+                else
+                  allparams += (env_table['QUERY_STRING'] or '')
+                end
+                if env_table['REQUEST_METHOD'] == 'POST'
+                  if not allparams.empty?
+                    allparams += '&'
+                  end
+                  stdinput.binmode if defined? stdinput.binmode
+                  allparams += (stdinput.read(Integer(env_table['CONTENT_LENGTH'])) or '')
+                end
+              else
+                allparams = read_from_cmdline
+              end
+          @multipart = false
+          @params = CGI::parse(allparams)
       end
-
+
  
       @cookies = CGI::Cookie::parse((env_table['HTTP_COOKIE'] or env_table['COOKIE']))
     end
     private :initialize_query





In This Thread

Prev Next