title: RUBY - SSL, Basic Auth, and POST
body: <p>I'm having quite a hard time with this -- seems like there are a few snippets of code lying around that I can't seem to piece together.  I'm simply trying to POST key/value pairs, but getting <code>Connection refused - connect(2) (Errno::ECONNREFUSED)</code>.  Help!</p>
  
  <pre><code>require 'net/http'
  require 'net/https'
  require 'uri'
  
  @http = Net::HTTP.new('https://my.url.com/path', 443)
  @http.use_ssl = true
  @http.start() { |http|
      req = Net::HTTP.post_form(
          URI.parse('https:///my.url.com/path'),
          {'key1' =&gt; 'value1', 'key2' =&gt; 'value2'}
      )
      req.basic_auth 'username', 'password'
      response = http.request(req)
      puts response.body      
  }
  </code></pre>