Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Get and Post at the same time

Reply
Thread Tools

Get and Post at the same time

 
 
Douglas Livingstone
Guest
Posts: n/a
 
      02-01-2005
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, ost, :request

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

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

end


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
mvc same name same post rodchar ASP .Net 0 10-08-2009 08:43 PM
Why "Welcome Message" I post come get posted as the reply to same post ? arnuld C++ 6 09-05-2007 05:24 PM
CGI handler: Retrieving POST and GET at the same time Samuel Python 2 03-10-2007 08:38 PM
HttpWebRequest POST result is not the same as POST via ServerXMLHT =?Utf-8?B?RGF2ZSBCcm93bg==?= ASP .Net 1 11-10-2005 07:49 PM
Post post post. Shel-hed Computer Support 2 11-08-2003 07:41 AM



Advertisments