Method: HTTP.post

Defined in:
lib/gracenote/HTTP.rb

.post(path, data = '', cookie = '') ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/gracenote/HTTP.rb', line 23

def self.post(path, data='', cookie='')
  uri = URI(path)
  req = Net::HTTP.new(uri.host, uri.port)
  req.use_ssl = (uri.scheme == "https") ? true : false
  headers = {'Cookie' => cookie, "Content-Type" => "application/xml"}

  if data.class.to_s == 'String'
    reqdata = data;
  else
    reqdata = Rack::Utils.build_nested_query(data)
  end

  resp = req.request_post( uri.path, reqdata, headers)     
  return resp
end