Class: FaradayPersistentExcon::PerformRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/faraday_persistent_excon/perform_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#envObject

Returns the value of attribute env.



3
4
5
# File 'lib/faraday_persistent_excon/perform_request.rb', line 3

def env
  @env
end

Instance Method Details

#call(env) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/faraday_persistent_excon/perform_request.rb', line 5

def call(env)
  @env = env

  resp = nil
  ConnectionPools.with_connection_for(url_without_path.to_s) do |conn|
    resp = conn.request(request_options)
  end

rescue ::Excon::Errors::SocketError => err
  case err.message
  when /\btimeout\b/
    raise Faraday::TimeoutError, err
  when /\bcertificate\b/
    raise Faraday::SSLError, err
  else
    raise Faraday::ConnectionFailed, err
  end
rescue ::Excon::Errors::Timeout => err
  raise Faraday::TimeoutError, err
end