Ruby Simple Http Post without NET::HTTP Complexity

I just got brain damage again while trying to use NET::HTTP, its so ridiculous complex, why is there no simple alternative ?
(you can use open-uri for get, but post/delete/update ?)

  def post(url,data)
    require 'activesupport'
    require 'net/http'
    url = URI.parse(url)
    http =, url.port)
    if url.scheme == 'https'
      require 'net/https'
      http.use_ssl = true
    resp, data =, data.to_query)
    raise "POST FAILED:"+resp.inspect unless resp.is_a? Net::HTTPOK or resp.is_a? Net::HTTPFound
    return data

I am willing to make a SimpleHTTP gem if no one comes up with a satisfactory solution 😦


response = page content, throw exception when response code not 200

rest-client seems to be a good solution, although it does not support sending files.

2 thoughts on “Ruby Simple Http Post without NET::HTTP Complexity

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s