Get and Post at the same time

Discussion in 'Ruby' started by Douglas Livingstone, Feb 1, 2005.

  1. Here's a script to retrieve Get and Post as the same time. I've had a
    look for one as I needed it, but didn't find anything.

    If someone finds it useful, great. If someone can tell me how it is
    terrible Ruby code and how to make it better, that would be cool too
    :)

    Douglas

    class GetPostRequest

    include Singleton

    attr_reader :raw_get, :raw_post
    attr_reader :get, :post, :request

    # data from QUERY_STRING and $stdin
    def initialize
    @get = @post = Hash.new
    if ENV['QUERY_STRING']
    @raw_get = ENV['QUERY_STRING']
    @get = CGI::parse(@raw_get)
    end
    if ENV['REQUEST_METHOD'] == 'POST'
    @raw_post = $stdin.gets.strip
    @post = CGI::parse(@raw_post)
    end
    @request = @post.merge(@get) # get wins
    end

    # combined Get and Post
    def [](key)
    @request[key]
    end

    end
     
    Douglas Livingstone, Feb 1, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?RGF2ZSBCcm93bg==?=

    HttpWebRequest POST result is not the same as POST via ServerXMLHT

    =?Utf-8?B?RGF2ZSBCcm93bg==?=, Nov 8, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    2,150
    Joerg Jooss
    Nov 10, 2005
  2. flamesrock
    Replies:
    8
    Views:
    502
    Hendrik van Rooyen
    Nov 24, 2006
  3. Samuel
    Replies:
    2
    Views:
    471
    Samuel
    Mar 10, 2007
  4. arnuld
    Replies:
    6
    Views:
    634
    arnuld
    Sep 5, 2007
  5. rodchar

    mvc same name same post

    rodchar, Oct 8, 2009, in forum: ASP .Net
    Replies:
    0
    Views:
    296
    rodchar
    Oct 8, 2009
Loading...

Share This Page