Sha256: 0a65c80eb29977ff5bd1f0cda61659a538c7a11a0b356ebd1783301ba3a84663
Contents?: true
Size: 893 Bytes
Versions: 1
Compression:
Stored size: 893 Bytes
Contents
require 'net/http' require 'hpricot' module Jkl class << self def 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 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 get_xml_from(uri) Hpricot.XML get_from uri end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jakal-0.1.1 | lib/jkl/rest_client.rb |