Class: Nicos::Connector::Xml

Inherits:
Connector show all
Defined in:
lib/classes/connector.rb

Direct Known Subclasses

GetThumbInfo, TagAtom

Instance Attribute Summary

Attributes inherited from Connector

#result, #waitConfig

Instance Method Summary collapse

Methods inherited from Connector

#getStatus, #initialize

Methods included from SetWait

#setWait

Methods inherited from Config

setWait, setWaitDefault

Constructor Details

This class inherits a constructor from Nicos::Connector::Connector

Instance Method Details

#get(host, entity) ⇒ Object



159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/classes/connector.rb', line 159

def get (host, entity)  
  response = nil
  retryCount = 0
  res = {}
        
  begin
    @nowAccess = host + entity
    puts "Request to " + @nowAccess
    Net::HTTP.start(host, 80) { |http|
      response = http.get(entity, HEADER)
    }
    retryCount += 1

  rescue => e
    puts e
  rescue Timeout::Error => e  
    timeOut 
    res[:order] = :retry     

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

  res
end