Skip to content

Instantly share code, notes, and snippets.

@patelc75
Created February 13, 2012 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patelc75/1819335 to your computer and use it in GitHub Desktop.
Save patelc75/1819335 to your computer and use it in GitHub Desktop.
def self.send(dest_url, content)
url = URI.parse(dest_url)
# Code snippet on how to use Net:HTTP: http://snippets.aktagon.com/snippets/305-Example-of-how-to-use-Ruby-s-NET-HTTP
http_endpoint = Net::HTTP.new(url.host, url.port)
if url.scheme == 'https'
http_endpoint.use_ssl = true
http_endpoint.verify_mode = OpenSSL::SSL::VERIFY_NONE
#http_endpoint.verify_mode = OpenSSL::SSL::VERIFY_PEER #verify the certificate -- not working with Avantguard, getting "OpenSSL::SSL::SSLError: certificate verify failed"
end
request = Net::HTTP::Post.new(url.request_uri)
request.body = content
request.set_content_type("text/xml")
res = http_endpoint.start do |http|
http_endpoint.request(request)
end
return res
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment