Module: Faraday::Adapter::EMHttp::Options
- Included in:
 - Faraday::Adapter::EMHttp, Faraday::Adapter::EMSynchrony
 
- Defined in:
 - lib/puppet/feature/faraday/adapter/em_http.rb
 
Instance Method Summary collapse
- #configure_compression(options, env) ⇒ Object
 - #configure_proxy(options, env) ⇒ Object
 - #configure_socket(options, env) ⇒ Object
 - #configure_ssl(options, env) ⇒ Object
 - #configure_timeout(options, env) ⇒ Object
 - #connection_config(env) ⇒ Object
 - #read_body(env) ⇒ Object
 - #request_config(env) ⇒ Object
 - #request_options(env) ⇒ Object
 
Instance Method Details
#configure_compression(options, env) ⇒ Object
      67 68 69 70 71  | 
    
      # File 'lib/puppet/feature/faraday/adapter/em_http.rb', line 67 def configure_compression(, env) if env[:method] == :get and not [:head].key? 'accept-encoding' [:head]['accept-encoding'] = 'gzip, compressed' end end  | 
  
#configure_proxy(options, env) ⇒ Object
      33 34 35 36 37 38 39 40 41  | 
    
      # File 'lib/puppet/feature/faraday/adapter/em_http.rb', line 33 def configure_proxy(, env) if proxy = (env)[:proxy] [:proxy] = { :host => proxy[:uri].host, :port => proxy[:uri].port, :authorization => [proxy[:user], proxy[:password]] } end end  | 
  
#configure_socket(options, env) ⇒ Object
      43 44 45 46 47 48 49 50  | 
    
      # File 'lib/puppet/feature/faraday/adapter/em_http.rb', line 43 def configure_socket(, env) if bind = (env)[:bind] [:bind] = { :host => bind[:host], :port => bind[:port] } end end  | 
  
#configure_ssl(options, env) ⇒ Object
      52 53 54 55 56 57 58 59  | 
    
      # File 'lib/puppet/feature/faraday/adapter/em_http.rb', line 52 def configure_ssl(, env) if env[:url].scheme == 'https' && env[:ssl] [:ssl] = { :cert_chain_file => env[:ssl][:ca_file], :verify_peer => env[:ssl].fetch(:verify, true) } end end  | 
  
#configure_timeout(options, env) ⇒ Object
      61 62 63 64 65  | 
    
      # File 'lib/puppet/feature/faraday/adapter/em_http.rb', line 61 def configure_timeout(, env) timeout, open_timeout = (env).values_at(:timeout, :open_timeout) [:connect_timeout] = [:inactivity_timeout] = timeout [:connect_timeout] = open_timeout if open_timeout end  | 
  
#connection_config(env) ⇒ Object
      8 9 10 11 12 13 14 15  | 
    
      # File 'lib/puppet/feature/faraday/adapter/em_http.rb', line 8 def connection_config(env) = {} configure_proxy(, env) configure_timeout(, env) configure_socket(, env) configure_ssl(, env) end  | 
  
#read_body(env) ⇒ Object
      28 29 30 31  | 
    
      # File 'lib/puppet/feature/faraday/adapter/em_http.rb', line 28 def read_body(env) body = env[:body] body.respond_to?(:read) ? body.read : body end  | 
  
#request_config(env) ⇒ Object
      17 18 19 20 21 22 23 24 25 26  | 
    
      # File 'lib/puppet/feature/faraday/adapter/em_http.rb', line 17 def request_config(env) = { :body => read_body(env), :head => env[:request_headers], # :keepalive => true, # :file => 'path/to/file', # stream data off disk } configure_compression(, env) end  | 
  
#request_options(env) ⇒ Object
      73 74 75  | 
    
      # File 'lib/puppet/feature/faraday/adapter/em_http.rb', line 73 def (env) env[:request] end  |