349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
|
# File 'lib/rets/client.rb', line 349
def self.check(response)
if response.respond_to?(:status_code) && response.status_code == 412
raise HttpError, "HTTP status: #{response.status_code}, body: #{response.body}"
end
if !response.body.empty?
begin
xml = Nokogiri::XML.parse(response.body, nil, nil, Nokogiri::XML::ParseOptions::STRICT)
rets_element = xml.xpath("/RETS")
if rets_element.empty?
return
end
reply_text = (rets_element.attr("ReplyText") || rets_element.attr("replyText")).value
reply_code = (rets_element.attr("ReplyCode") || rets_element.attr("replyCode")).value.to_i
if reply_code.nonzero?
raise InvalidRequest.new(reply_code, reply_text)
else
return
end
rescue Nokogiri::XML::SyntaxError
end
end
if response.respond_to?(:ok?) && ! response.ok?
if response.status_code == 401
raise AuthorizationFailure.new(response.status_code, response.body)
else
raise HttpError, "HTTP status: #{response.status_code}, body: #{response.body}"
end
end
end
|