4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/fsp/web_utils.rb', line 4
def self.fetch(url:, headers: { 'Accept' => '*/*' }, method: :get, verifyssl: false)
warn 'In fetch routine now. '
begin
warn "executing call over the Web to #{url}"
response = RestClient::Request.execute({
method: method,
url: url.to_s,
headers: ,
:verify_ssl => verifyssl
})
warn "starting URL #{url}"
warn "final URL #{response.request.url}"
warn "Response code #{response.code}"
response
rescue RestClient::ExceptionWithResponse => e
warn "EXCEPTION WITH RESPONSE! #{e.response.code} with response #{e.response}\nfailed response headers: #{e.response.}"
if e.response.code == 500 or e.response.code == 404
false
else
e.response
end
rescue RestClient::Exception => e
warn "EXCEPTION WITH NO RESPONSE! #{e}"
false
rescue Exception => e
warn "EXCEPTION UNKNOWN! #{e}"
false
end
end
|