Class: Magnesium::Http
- Inherits:
-
Object
- Object
- Magnesium::Http
- Defined in:
- lib/magnesium/extensions/http.rb
Instance Attribute Summary collapse
-
#filepath ⇒ Object
Returns the value of attribute filepath.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Attribute Details
#filepath ⇒ Object
Returns the value of attribute filepath.
11 12 13 |
# File 'lib/magnesium/extensions/http.rb', line 11 def filepath @filepath end |
#url ⇒ Object
Returns the value of attribute url.
10 11 12 |
# File 'lib/magnesium/extensions/http.rb', line 10 def url @url end |
Class Method Details
.get_xml ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# 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 ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# 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 |