class RubyARES::HTTP

Public Class Methods

fetch_subject_xml(ic) click to toggle source
# File lib/ruby-ares/http.rb, line 10
def self.fetch_subject_xml(ic)
  # Get a subject info from ARES[http://wwwinfo.mfcr.cz/ares/]
  uri = URI('http://wwwinfo.mfcr.cz/cgi-bin/ares/darv_bas.cgi')
  params = { :ico => ic, :version => '1.0.3' }
  uri.query = URI.encode_www_form(params)

  begin
    res = Net::HTTP.get_response uri
    @xml = res.body if res.is_a? Net::HTTPSuccess
  rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
         Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
    raise ConnectionError, e
  end
end