Class: Nicos::Connector::Xml

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

Direct Known Subclasses

GetThumbInfo, MylistHtml, 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, param) ⇒ Object



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
# File 'lib/classes/connector.rb', line 164

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