Class: PostRemoteLog::Methods::XMLRPC

Inherits:
Object
  • Object
show all
Defined in:
lib/post_remote_log/methods/xmlrpc.rb

Class Method Summary collapse

Class Method Details

.send(config, values) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/post_remote_log/methods/xmlrpc.rb', line 23

def self.send(config, values)
	message = PostRemoteLog.build_xml_message(values)

	port = config[:port] || 9080
	path = config[:path] || "/post-remote-log"

	Net::HTTP.start(config[:host], port) do |http|
		response = http.post(path, message.string, {"Content-Type" => "text/xml"})

		unless (200...300).include?(response.code.to_i)
			$stderr.puts "Could not create remote log record..."

			$stderr.puts "Code: #{response.code}" 
			$stderr.puts "Message: #{response.message}"
			$stderr.puts "Body:\n #{response.body}"
		end
	end
end