Sha256: cf97a5129248ad59a350b1df133ef4d5f5aa0d60597982e6fabfea4294cc063e
Contents?: true
Size: 1021 Bytes
Versions: 3
Compression:
Stored size: 1021 Bytes
Contents
module NFAgent class Client SERVICE_HOST = "collector.service.netfox.com" def self.post(end_point, data_hash) proxy_class = Net::HTTP::Proxy(Config.http_proxy_host, Config.http_proxy_port, Config.http_proxy_user, Config.http_proxy_password) # TODO: Enable SSL proxy_class.start(SERVICE_HOST, 80) do |http| http.read_timeout = 120 # 2 minutes TODO: Make this a config option with 120 as default req = Net::HTTP::Post.new("/#{end_point}") p({"key" => Config.client_key}.merge(data_hash).delete('data')) req.set_form_data({"key" => Config.client_key}.merge(data_hash)) ClientResponse.new do |resp| resp.response, resp.message = http.request(req) Log.info("Client Returned with '#{resp.message}'") end end rescue Exception => e # Trap Exception class here to ensure we catch Timeout ClientResponse.new do |resp| Log.info("Client Error: #{$!}") resp.message = $! end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
nfagent-0.9.30 | lib/nfagent/client.rb |
nfagent-0.9.29 | lib/nfagent/client.rb |
nfagent-0.9.28 | lib/nfagent/client.rb |