Faraday::Adapter::EMHttp::Options

Public Instance Methods

configure_compression(options, env) click to toggle source
# File lib/faraday/adapter/em_http.rb, line 59
def configure_compression(options, env)
  if env[:method] == :get and not options[:head].key? 'accept-encoding'
    options[:head]['accept-encoding'] = 'gzip, compressed'
  end
end
configure_proxy(options, env) click to toggle source
# File lib/faraday/adapter/em_http.rb, line 44
def configure_proxy(options, env)
  if proxy = request_options(env)[:proxy]
    options[:proxy] = {
      :host => proxy[:uri].host,
      :port => proxy[:uri].port
    }
  end
end
configure_ssl(options, env) click to toggle source
# File lib/faraday/adapter/em_http.rb, line 35
def configure_ssl(options, env)
  if ssl = env[:ssl]
    # :ssl => {
    #   :private_key_file => '/tmp/server.key',
    #   :cert_chain_file => '/tmp/server.crt',
    #   :verify_peer => false
  end
end
configure_timeout(options, env) click to toggle source
# File lib/faraday/adapter/em_http.rb, line 53
def configure_timeout(options, env)
  timeout, open_timeout = request_options(env).values_at(:timeout, :open_timeout)
  options[:connect_timeout] = options[:inactivity_timeout] = timeout
  options[:connect_timeout] = open_timeout if open_timeout
end
connection_config(env) click to toggle source
# File lib/faraday/adapter/em_http.rb, line 8
def connection_config(env)
  options = {}
  configure_ssl(options, env)
  configure_proxy(options, env)
  configure_timeout(options, env)
  options
end
read_body(env) click to toggle source
# File lib/faraday/adapter/em_http.rb, line 30
def read_body(env)
  body = env[:body]
  body.respond_to?(:read) ? body.read : body
end
request_config(env) click to toggle source
# File lib/faraday/adapter/em_http.rb, line 16
def request_config(env)
  options = {
    :body => read_body(env),
    :head => env[:request_headers],
    # :keepalive => true,
    # :file => 'path/to/file', # stream data off disk
  }
  configure_compression(options, env)
  # configure_proxy_auth
  # :proxy => {:authorization => [user, pass]}
  # proxy[:username] && proxy[:password]
  options
end
request_options(env) click to toggle source
# File lib/faraday/adapter/em_http.rb, line 65
def request_options(env)
  env[:request]
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.