1

I want to make a simple post request using ruby. At first I tried it with the gem open-uri. But this answer to a so- question says that it doesn't work. So instead of this I want to use the rest-open-uri gem as recommended in the post. But how does it work? and how does it work using a proxy?

Thanks in advance!

Community
  • 1
  • 1
ada91
  • 828
  • 2
  • 7
  • 19

2 Answers2

2

Couldn't you just use Ruby's stdlib? Here you have some nice examples for ruby 2.0.

Marcin Pietraszek
  • 3,134
  • 1
  • 19
  • 31
2

http://ruby-doc.org/stdlib-2.0/libdoc/net/http/rdoc/Net/HTTP.html#method-i-post

From the docs, a summary:

response = http.post('/cgi-bin/search.rb', 'query=foo')

Use case:

# using block
File.open('result.txt', 'w') {|f|
  http.post('/cgi-bin/search.rb', 'query=foo') do |str|
    f.write str
  end
}
000
  • 26,951
  • 10
  • 71
  • 101