class Magnesium::Http

Attributes

filepath[RW]
url[RW]

Public Class Methods

get_xml() click to toggle source
# File lib/magnesium/extensions/http.rb, line 13
def self.get_xml
  begin
    uri = URI.parse(@url)
    req = Net::HTTP::Get.new(uri.path)

    req.content_type = 'text/xml'

    http = Net::HTTP.new(uri.host,uri.port)

    request = http.start {|h| h.request(req)}
    #return xml file
    return request.read_body
  rescue
    error
  end
end
post_xml() click to toggle source
# File lib/magnesium/extensions/http.rb, line 30
def self.post_xml
  begin
    file = File.read(@filepath)

    uri = URI.parse(@url)
    req = Net::HTTP::Post.new(uri.path)

    req.body = file
    req.content_type = 'text/xml'

    http = Net::HTTP.new(uri.host,uri.port)

    http.start{|h| h.request(req)}
  rescue
    error
  end
end