lib/fastly/client.rb in fastly-1.7.0 vs lib/fastly/client.rb in fastly-1.8.0

- old
+ new

@@ -16,21 +16,22 @@ @user = opts.fetch(:user, nil) @password = opts.fetch(:password, nil) @customer = opts.fetch(:customer, nil) @oldpurge = opts.fetch(:use_old_purge_method, false) - base = opts.fetch(:base_url, DEFAULT_URL) - uri = URI.parse(base) - options = if uri.is_a? URI::HTTPS - { - use_ssl: true, - verify_mode: OpenSSL::SSL::VERIFY_PEER - } - else - {} - end + base = opts.fetch(:base_url, DEFAULT_URL) + uri = URI.parse(base) - @http = Net::HTTP.start(uri.host, uri.port, options) + @http = Net::HTTP.new(uri.host, uri.port, :ENV, nil, nil, nil) + + # handle TLS connections outside of development + @http.verify_mode = OpenSSL::SSL::VERIFY_PEER + @http.use_ssl = uri.scheme.downcase == 'https' + + # debug http interactions if specified + @http.set_debug_output(opts[:debug]) if opts[:debug] + + @http.start return self unless fully_authed? # If full auth creds (user/pass) then log in and set a cookie resp = http.post('/login', make_params(user: user, password: password))