Sha256: 4c6b7224f22f03f87e5003cdf4906b2ffd4b3de0cf0b028ba0b9c33dbaaa78a7
Contents?: true
Size: 832 Bytes
Versions: 3
Compression:
Stored size: 832 Bytes
Contents
require 'net/http' require 'hpricot' module Jkl def self.post_to(uri, post_args) begin resp, data = Net::HTTP.post_form(uri, post_args) data rescue URI::InvalidURIError => e puts("WARN: Invalid URI: #{e}") rescue SocketError => e puts("WARN: Could not connect: #{e}") rescue Errno::ECONNREFUSED => e puts("WARN: Connection refused: #{e}") end end def self.get_from(uri) begin res = Net::HTTP.get_response(URI.parse(uri)) res.body rescue URI::InvalidURIError => e puts("WARN: Invalid URI: #{e}") rescue SocketError => e puts("WARN: Could not connect: #{e}") rescue Errno::ECONNREFUSED => e puts("WARN: Connection refused: #{e}") end end def self.get_from_as_xml(uri) Hpricot.XML get_from uri end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
jakal-0.0.9 | lib/jkl/rest_client.rb |
jakal-0.0.8 | lib/jkl/rest_client.rb |
jakal-0.0.7 | lib/jkl/rest_client.rb |