Class: Chuanglan::Request
- Inherits:
-
Object
- Object
- Chuanglan::Request
- Defined in:
- lib/chuanglan/request.rb
Instance Method Summary collapse
-
#initialize(url, params) ⇒ Request
constructor
A new instance of Request.
- #perform ⇒ Object
Constructor Details
#initialize(url, params) ⇒ Request
Returns a new instance of Request.
6 7 8 9 |
# File 'lib/chuanglan/request.rb', line 6 def initialize(url, params) @uri = URI(url) @params = params end |
Instance Method Details
#perform ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/chuanglan/request.rb', line 11 def perform timeout = Chuanglan.timeout is_https = @uri.scheme == 'https' Net::HTTP.start(@uri.host, @uri.port, open_timeout: timeout, read_timeout: timeout, use_ssl: is_https) do |http| post_data = URI.encode_www_form(@params) http.request_post(@uri.path, post_data) end end |