any good library to send POST headers in ruby ?
You can do something like this...
require 'net/http'
postData = Net::HTTP.post_form(URI.parse('http://thewebsite.net'), {'postKey'=>'postValue'})
puts postData.body
The standard library Net::HTTP is pretty straightforward and handles POST
.
From the docs:
response = http.post('/cgi-bin/search.rb', 'query=foo')
# using block
File.open('result.txt', 'w') {|f|
http.post('/cgi-bin/search.rb', 'query=foo') do |str|
f.write str
end
}
For more detailed examples of how to use Net::HTTP, see August Lilleaas's Net::HTTP cheat sheet repository on Github.
Net::HTTP
as mentioned, the curl wrapper Curb, or HTTParty. Depending on what you are trying to do, they may be overkill.
There are plenty of HTTP libraries in Ruby. There's the standard net/http and libcurl bindings. But there are also a lot of high-level libraries to consume web services such as ActiveResource and HTTParty. Depends on what you want to do. Maybe you can update your question with more information?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With