class CF::UAA::CurlCli

Public Instance Methods

make_request(uri, options) click to toggle source
# File lib/uaa/cli/curl.rb, line 63
def make_request(uri, options)
  http = Net::HTTP.new(uri.host, uri.port)
  if uri.scheme == "https"
    http.use_ssl = true
    if options[:insecure]
      http.verify_mode = OpenSSL::SSL::VERIFY_NONE
    elsif options[:cacert]
      http.ca_file = File.expand_path(options[:cacert])
      http.verify_mode = OpenSSL::SSL::VERIFY_PEER
    end
  end
  request_class = Net::HTTP.const_get("#{options[:request][0]}#{options[:request][1..-1].downcase}")
  req = request_class.new(uri.request_uri)
  req["Authorization"] = "Bearer #{Config.value(:access_token)}"
  Array(options[:header]).each do |h|
    key, value = h.split(":")
    req[key] = value
  end
  http.request(req, options[:data])
end
parse_uri(path) click to toggle source
# File lib/uaa/cli/curl.rb, line 43
def parse_uri(path)
  uri = URI.parse(path)
  unless uri.host
    uri = URI.parse("#{Config.target}#{path}")
  end
  uri
end
print_request(request, uri, data, header, bodyonly) click to toggle source
print_response(response, bodyonly) click to toggle source
say_it(text, bodyonly) click to toggle source
# File lib/uaa/cli/curl.rb, line 101
def say_it(text, bodyonly)
  if !bodyonly
    say text
  end
end