class Typhoeus::Hydra

def get_easy_object(request)

def get_easy_object(request)
  @running_requests += 1
  easy = @easy_pool.pop || Easy.new
  easy.verbose          = request.verbose
  if request.username || request.password
    auth = { :username => request.username, :password => request.password }
    auth[:method] = Typhoeus::Easy::AUTH_TYPES["CURLAUTH_#{request.auth_method.to_s.upcase}".to_sym] if request.auth_method
    easy.auth = auth
  end
  easy.url          = request.url
  easy.method       = request.method
  easy.params       = request.params  if request.method == :post && !request.params.nil?
  easy.headers      = request.headers if request.headers
  easy.request_body = request.body    if request.body
  easy.timeout      = request.timeout if request.timeout
  easy.connect_timeout = request.connect_timeout if request.connect_timeout
  easy.follow_location = request.follow_location if request.follow_location
  easy.max_redirects = request.max_redirects if request.max_redirects
  easy.proxy = request.proxy if request.proxy
  easy.disable_ssl_peer_verification if request.disable_ssl_peer_verification
  easy.ssl_cert         = request.ssl_cert
  easy.ssl_cert_type    = request.ssl_cert_type
  easy.ssl_key          = request.ssl_key
  easy.ssl_key_type     = request.ssl_key_type
  easy.ssl_key_password = request.ssl_key_password
  easy.ssl_cacert       = request.ssl_cacert
  easy.ssl_capath       = request.ssl_capath
  easy.verbose          = request.verbose
  easy.on_success do |easy|
    queue_next
    handle_request(request, response_from_easy(easy, request))
    release_easy_object(easy)
  end
  easy.on_failure do |easy|
    queue_next
    handle_request(request, response_from_easy(easy, request))
    release_easy_object(easy)
  end
  easy.set_headers
  easy
end