Skip to content

Instantly share code, notes, and snippets.

@seungjin
Created January 8, 2011 16:48
Show Gist options
  • Save seungjin/770979 to your computer and use it in GitHub Desktop.
Save seungjin/770979 to your computer and use it in GitHub Desktop.
def reportToInstanceService(arg)
instance_service_url = JSON.parse(arg)['atmosphere']['instance_service_url'] token = JSON.parse(arg)['atmosphere']['token']
userid = JSON.parse(arg)['atmosphere']['userid']
uri = URI.parse(instance_service_url)
data = {'token'=> token, 'userid'=>userid,'vminfo'=>$instance_info_json}
if uri.scheme == "https"
http = Net::HTTP.new(uri.host,uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
path = uri.path
res = http.post(uri.path,data.collect do |key,val| "#{CGI.escape(key.to_s)}=#{CGI.escape(val)}" end.join('&'))
else
res = Net::HTTP.post_form(URI.parse(instance_service_url), data)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment