Class: Net::HTTP

Inherits:
Object
  • Object
show all
Defined in:
lib/fusebox/core_ext/net_http.rb

Class Method Summary collapse

Class Method Details

.post_form_with_ssl(url, params) ⇒ Object

Posts HTML form data to the URL, but allow for SSL.

The existing 1.8.x implementaiton via post_form does not allow for SSL connections

Parameters:

  • url (URI)
  • POST (Hash)

    data


9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fusebox/core_ext/net_http.rb', line 9

def HTTP.post_form_with_ssl(url, params)
  req = Post.new(url.path)
  req.form_data = params
  req.basic_auth url.user, url.password if url.user
  http = new(url.host, url.port)
  http.use_ssl = (url.scheme == 'https')
  http.verify_mode = OpenSSL::SSL::VERIFY_PEER
  http.ca_file = File.expand_path('../../../../vendor/curl-cacert.pem', __FILE__)
  http.start {|http|
    http.request(req)
  }
end