Sha256: bb727389c83c50b95a0148a96e6e49adff7f12a96c02ad00da0cdeed28e69774
Contents?: true
Size: 1.37 KB
Versions: 1
Compression:
Stored size: 1.37 KB
Contents
require 'faraday' module Twilio module HTTP class Client attr_accessor :adapter def initialize(proxy_addr=nil, proxy_port=nil, proxy_user=nil, proxy_pass=nil, ssl_ca_file=nil) @proxy_addr = proxy_addr @proxy_port = proxy_port @proxy_user = proxy_user @proxy_pass = proxy_pass @ssl_ca_file = ssl_ca_file @adapter = Faraday.default_adapter end def request(host, port, method, url, params={}, data={}, headers={}, auth=nil, timeout=nil) puts host puts url @connection = Faraday.new(url: host + ":" + port.to_s, ssl: {verify: true}) do |f| f.request :url_encoded f.adapter @adapter f.headers = headers f.basic_auth(auth[0], auth[1]) if @proxy_addr f.proxy "#{@proxy_user}:#{@proxy_pass}@#{@proxy_addr}:#{@proxy_port}" end f.options.open_timeout = timeout f.options.timeout = timeout end response = @connection.send(method.downcase.to_sym, url, method == 'GET' ? params : data) @last_response = response if response.body and !response.body.empty? object = response.body elsif response.status == 400 object = { message: 'Bad request', code: 400 }.to_json end TwilioResponse.new(response.status, object) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
twilio-ruby-5.0.0.rc2 | lib/twilio-ruby/http/http_client.rb |