Frage

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!

War es hilfreich?

Lösung

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
}

Andere Tipps

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top