class Nicos::Connector::Xml

Public Instance Methods

get(host, entity, param) click to toggle source
# File lib/classes/connector.rb, line 163
def get (host, entity, param)  
  response = nil
  @retryCount = 0
  res = {}
        
  begin
    @nowAccess = host + entity + param
    puts "Request to " + @nowAccess
    Net::HTTP.start(host, 80) { |http|
      response = http.get(entity + param, HEADER)
    }
    @retryCount += 1

  rescue => e
    puts e
  rescue Timeout::Error => e
    timedOut
    res[:order] = :retry
  else
    res = case response
    when Net::HTTPSuccess then
      reviewRes( response.body.force_encoding("UTF-8") )
    # when Net::HTTPRedirection
    #  fetch(response['location'], limit - 1)
    when Net::HTTPForbidden           then forbidden         
    when Net::HTTPNotFound            then notFound
    when Net::HTTPServiceUnavailable  then serviceUnavailable
    else unknownError
    end    
  end until res[:order] != :retry

  res
end