Use Typhoeus and set agressive timeouts
This commit is contained in:
parent
197089a746
commit
f35aef0eb6
3 changed files with 15 additions and 3 deletions
1
Gemfile
1
Gemfile
|
@ -46,6 +46,7 @@ gem 'openid_connect'
|
||||||
gem 'omniauth-github'
|
gem 'omniauth-github'
|
||||||
|
|
||||||
gem 'rest-client'
|
gem 'rest-client'
|
||||||
|
gem 'typhoeus'
|
||||||
|
|
||||||
gem 'clamav-client', require: 'clamav/client'
|
gem 'clamav-client', require: 'clamav/client'
|
||||||
|
|
||||||
|
|
|
@ -196,6 +196,8 @@ GEM
|
||||||
http_parser.rb (~> 0.6.0)
|
http_parser.rb (~> 0.6.0)
|
||||||
erubi (1.7.0)
|
erubi (1.7.0)
|
||||||
erubis (2.7.0)
|
erubis (2.7.0)
|
||||||
|
ethon (0.11.0)
|
||||||
|
ffi (>= 1.3.0)
|
||||||
eventmachine (1.2.5)
|
eventmachine (1.2.5)
|
||||||
excon (0.60.0)
|
excon (0.60.0)
|
||||||
execjs (2.7.0)
|
execjs (2.7.0)
|
||||||
|
@ -730,6 +732,8 @@ GEM
|
||||||
turbolinks (5.1.0)
|
turbolinks (5.1.0)
|
||||||
turbolinks-source (~> 5.1)
|
turbolinks-source (~> 5.1)
|
||||||
turbolinks-source (5.1.0)
|
turbolinks-source (5.1.0)
|
||||||
|
typhoeus (1.3.0)
|
||||||
|
ethon (>= 0.9.0)
|
||||||
tzinfo (1.2.5)
|
tzinfo (1.2.5)
|
||||||
thread_safe (~> 0.1)
|
thread_safe (~> 0.1)
|
||||||
uglifier (4.1.7)
|
uglifier (4.1.7)
|
||||||
|
@ -854,6 +858,7 @@ DEPENDENCIES
|
||||||
therubyracer
|
therubyracer
|
||||||
timecop
|
timecop
|
||||||
turbolinks
|
turbolinks
|
||||||
|
typhoeus
|
||||||
uglifier (>= 1.3.0)
|
uglifier (>= 1.3.0)
|
||||||
unicode_utils
|
unicode_utils
|
||||||
unicorn
|
unicorn
|
||||||
|
|
|
@ -30,11 +30,17 @@ class ApiEntreprise::API
|
||||||
def self.call(resource_name, siret_or_siren, procedure_id)
|
def self.call(resource_name, siret_or_siren, procedure_id)
|
||||||
url = url(resource_name, siret_or_siren)
|
url = url(resource_name, siret_or_siren)
|
||||||
params = params(siret_or_siren, procedure_id)
|
params = params(siret_or_siren, procedure_id)
|
||||||
verify_ssl_mode = OpenSSL::SSL::VERIFY_NONE
|
|
||||||
|
|
||||||
result = RestClient::Resource.new(url, verify_ssl: verify_ssl_mode).get(params: params)
|
response = Typhoeus.get(url,
|
||||||
|
ssl_verifypeer: false,
|
||||||
|
params: params,
|
||||||
|
timeout: 20)
|
||||||
|
|
||||||
JSON.parse(result, symbolize_names: true)
|
if response.success?
|
||||||
|
JSON.parse(response.body, symbolize_names: true)
|
||||||
|
else
|
||||||
|
raise RestClient::ResourceNotFound
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.url(resource_name, siret_or_siren)
|
def self.url(resource_name, siret_or_siren)
|
||||||
|
|
Loading…
Reference in a new issue