X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Faviator%2Ffeature%2Ffaraday%2Fadapter%2Fexcon.rb;fp=3rdparty%2Fmodules%2Faviator%2Ffeature%2Ffaraday%2Fadapter%2Fexcon.rb;h=0000000000000000000000000000000000000000;hb=6e1426dc77fb4e5d51f07c187c6f2219431dc31e;hp=db0c7c35269d5110ad53b0d5bb1b3d33fcae6799;hpb=87423ba664cd5f2bb462ebadd08b1a90d0fe1c8d;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/aviator/feature/faraday/adapter/excon.rb b/3rdparty/modules/aviator/feature/faraday/adapter/excon.rb deleted file mode 100644 index db0c7c352..000000000 --- a/3rdparty/modules/aviator/feature/faraday/adapter/excon.rb +++ /dev/null @@ -1,80 +0,0 @@ -module Faraday - class Adapter - class Excon < Faraday::Adapter - dependency 'excon' - - def initialize(app, connection_options = {}) - @connection_options = connection_options - super(app) - end - - def call(env) - super - - opts = {} - if env[:url].scheme == 'https' && ssl = env[:ssl] - opts[:ssl_verify_peer] = !!ssl.fetch(:verify, true) - opts[:ssl_ca_path] = ssl[:ca_path] if ssl[:ca_path] - opts[:ssl_ca_file] = ssl[:ca_file] if ssl[:ca_file] - opts[:client_cert] = ssl[:client_cert] if ssl[:client_cert] - opts[:client_key] = ssl[:client_key] if ssl[:client_key] - opts[:certificate] = ssl[:certificate] if ssl[:certificate] - opts[:private_key] = ssl[:private_key] if ssl[:private_key] - - # https://github.com/geemus/excon/issues/106 - # https://github.com/jruby/jruby-ossl/issues/19 - opts[:nonblock] = false - end - - if ( req = env[:request] ) - if req[:timeout] - opts[:read_timeout] = req[:timeout] - opts[:connect_timeout] = req[:timeout] - opts[:write_timeout] = req[:timeout] - end - - if req[:open_timeout] - opts[:connect_timeout] = req[:open_timeout] - opts[:write_timeout] = req[:open_timeout] - end - - if req[:proxy] - opts[:proxy] = { - :host => req[:proxy][:uri].host, - :port => req[:proxy][:uri].port, - :scheme => req[:proxy][:uri].scheme, - :user => req[:proxy][:user], - :password => req[:proxy][:password] - } - end - end - - conn = ::Excon.new(env[:url].to_s, opts.merge(@connection_options)) - - resp = conn.request \ - :method => env[:method].to_s.upcase, - :headers => env[:request_headers], - :body => read_body(env) - - save_response(env, resp.status.to_i, resp.body, resp.headers) - - @app.call env - rescue ::Excon::Errors::SocketError => err - if err.message =~ /\btimeout\b/ - raise Error::TimeoutError, err - elsif err.message =~ /\bcertificate\b/ - raise Faraday::SSLError, err - else - raise Error::ConnectionFailed, err - end - rescue ::Excon::Errors::Timeout => err - raise Error::TimeoutError, err - end - - # TODO: support streaming requests - def read_body(env) - env[:body].respond_to?(:read) ? env[:body].read : env[:body] - end - end - end -end