Class: Heartcheck::Cas::HttpClient

Inherits:
Object
  • Object
show all
Defined in:
lib/heartcheck/cas/http_client.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.post(url, params) ⇒ Object



5
6
7
# File 'lib/heartcheck/cas/http_client.rb', line 5

def self.post(url, params)
  self.new.post(url, params)
end

Instance Method Details

#base_client(uri) ⇒ Object



16
17
18
19
20
21
# File 'lib/heartcheck/cas/http_client.rb', line 16

def base_client(uri)
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = uri.scheme.eql?('https')
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  http
end

#post(url, params) ⇒ Object



9
10
11
12
13
14
# File 'lib/heartcheck/cas/http_client.rb', line 9

def post(url, params)
  uri = URI(url)
  request = Net::HTTP::Post.new(uri.request_uri)
  request.set_form_data(params)
  base_client(uri).request(request)
end