Skip to content

Instantly share code, notes, and snippets.

@drbrain
Created September 24, 2015 01:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drbrain/76c9833c7f88f623a70f to your computer and use it in GitHub Desktop.
Save drbrain/76c9833c7f88f623a70f to your computer and use it in GitHub Desktop.
POST example from Net::HTTP documentation
uri = URI('http://www.example.com/todo.cgi')
req = Net::HTTP::Post.new(uri)
req.set_form_data('from' => '2005-01-01', 'to' => '2005-03-31')
res = Net::HTTP.start(uri.hostname, uri.port) do |http|
http.request(req)
end
case res
when Net::HTTPSuccess, Net::HTTPRedirection
# OK
else
res.value
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment