lib/adp/api_connection.rb in adp-connection-0.1.2 vs lib/adp/api_connection.rb in adp-connection-0.1.3
- old
+ new
@@ -7,10 +7,11 @@
require_relative 'access_token'
require_relative "connection_exception"
require_relative "api_connection"
require_relative "client_credential_configuration"
require_relative "authorization_code_configuration"
+require_relative "connection/version"
module Adp
module Connection
class ApiConnection
@@ -123,14 +124,18 @@
log.debug("URL: #{url}")
log.debug("Client ID: #{data["client_id"]}")
log.debug("Client Secret: #{data["client_secret"]}")
log.debug("Grant Type: #{data["grant_type"]}")
+ useragent = "adp-connection-ruby/#{Adp::Connection::VERSION}"
uri = URI.parse( url );
pem = File.read("#{self.connection_configuration.sslCertPath}");
key = File.read(self.connection_configuration.sslKeyPath);
http = Net::HTTP.new(uri.host, uri.port);
+
+ log.debug("User agent: #{useragent}")
+
if (!self.connection_configuration.sslCertPath.nil?)
http.use_ssl = true
http.cert = OpenSSL::X509::Certificate.new( pem );
http.key = OpenSSL::PKey::RSA.new(key, self.connection_configuration.sslKeyPass);
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
@@ -140,9 +145,11 @@
request = Net::HTTP::Post.new(uri.request_uri)
request.set_form_data( data );
else
request = Net::HTTP::Get.new(uri.request_uri)
end
+
+ request.initialize_http_header({"User-Agent" => useragent })
request["Content-Type"] = content_type
# add credentials if available
request["Authorization"] = authorization unless authorization.nil?