Professional Web Applications Themes

cgi.rb params initialize_query() - Ruby

I assert that initialize_query is broken. CGI::p should _always_ be called on the QUERY_STRING, no matter if the REQUEST_METHOD is POST or GET. I would also say that instead of params being an Array of Strings, it should contain String like object that have an additional property that indicates the parameter source, i.e. GET, POST, or COOKIE. Cookies should also be in the params so they can be [] found. The only other point on this would be to allow optional order of parsing, and thus the params component array orders. This is a staple of web programming and is ...

  1. #1

    Default cgi.rb params initialize_query()

    I assert that initialize_query is broken. CGI::p should _always_ be
    called on the QUERY_STRING, no matter if the REQUEST_METHOD is POST or
    GET.

    I would also say that instead of params being an Array of Strings, it
    should contain String like object that have an additional property that
    indicates the parameter source, i.e. GET, POST, or COOKIE. Cookies
    should also be in the params so they can be [] found.

    The only other point on this would be to allow optional order of
    parsing, and thus the params component array orders.

    This is a staple of web programming and is something PHP does right and
    JSP does wrong.

    I think this can all be done in the dist cgi.rb without causing anyone
    headaches.

    Can these changes be incorporated into the next 1.8 with my help?

    Dan



    Dan Guest

  2. #2

    Default Re: cgi.rb params initialize_query()

    On Sun, Jan 25, 2004 at 12:30:57AM +0900, Dan Janowski wrote: 

    Biggest problem: one would overwrite the other, unless your string-like
    objects were used as keys and hashed differently depending on origin.

    Better to have separate arrays for get and post... ala modern PHP.

    Ari


    Aredridel Guest

  3. #3

    Default Re: cgi.rb params initialize_query()

    cgi params are always an array of values for a given key. A variety of
    accessors are both possible and practical. Allow me to explain:

    cgi['param'] returns the last value for param among get post and cookie
    (the 1.8 behavior is first instance, I think it should be last
    instance. This allows a form posted value to be easily used to override
    a query string value. Good since forms are typically used to get input
    from the client)

    cgi.params('param') an array of all values

    cgi.cookies('param') returning only cookies (not an array for param)

    cgi.params_get('param') an array of only gets

    cgi.params_post('param') an array of only posts

    params_get('param') is really just: params.collect {|po| po if
    po.is_a? Get }.compact

    get and post vals should be Get < String and Post < String.

    This way a value gotten from cgi['param'] can be detected as post or
    get or cookie.

    On Jan 24, 2004, at 10:55 AM, Aredridel wrote:
     
    >
    > Biggest problem: one would overwrite the other, unless your string-like
    > objects were used as keys and hashed differently depending on origin.
    >
    > Better to have separate arrays for get and post... ala modern PHP.
    >
    > Ari
    >
    >[/ref]



    Dan Guest

Similar Threads

  1. Params in IE
    By Ralf Junge in forum Macromedia Flash Data Integration
    Replies: 0
    Last Post: February 19th, 09:45 AM
  2. Sizing params
    By Tom Jordahl in forum Coldfusion Server Administration
    Replies: 3
    Last Post: February 16th, 03:06 PM
  3. getUrl with querystring params
    By Stuart Palmer in forum Macromedia Flash
    Replies: 0
    Last Post: May 26th, 05:43 AM
  4. params with projector
    By Dycamedia in forum Macromedia Director Lingo
    Replies: 0
    Last Post: September 22nd, 11:38 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139