3 ms·
that's great if all you're trying to do is HTTP GET. standard libs are supposed to make all use cases fairly easy. making an http post isn't too bad: Net::
by catch23 16y ago
that's great if all you're trying to do is HTTP GET. standard libs are supposed to make all use cases fairly easy. making an http post isn't too bad:
Net::HTTP.new(host, port).start do |http|
post = Net::HTTP::Post.new(url)
post.set_form_data('blah' => '123')
http.request(post)
end
- petercooper 16y agoThat's "not too bad" if you're coming from Java. Thankfully most other Ruby libraries have significantly less verbose APIs than this.
- aaronbrethorst 16y agoPersonally, I'm a big fan of open-uri for super-simple requests and HTTParty for anything more complex.
- carbon8 16y agoThere's a much simpler way to do POSTs with Net::HTTP: response = Net::HTTP.post_form(URI.parse("http://example.com"), {:param => "val"})