def initialize(url, options = {})
@method = options[:method] || :get
@params = options[:params]
@body = options[:body]
@timeout = safe_to_i(options[:timeout])
@connect_timeout = safe_to_i(options[:connect_timeout])
@interface = options[:interface]
@headers = options[:headers] || {}
if options.has_key?(:user_agent)
self.user_agent = options[:user_agent]
end
@cache_timeout = safe_to_i(options[:cache_timeout])
@follow_location = options[:follow_location]
@max_redirects = options[:max_redirects]
@proxy = options[:proxy]
@proxy_type = options[:proxy_type]
@proxy_username = options[:proxy_username]
@proxy_password = options[:proxy_password]
@proxy_auth_method = options[:proxy_auth_method]
@disable_ssl_peer_verification = options[:disable_ssl_peer_verification]
@disable_ssl_host_verification = options[:disable_ssl_host_verification]
@ssl_cert = options[:ssl_cert]
@ssl_cert_type = options[:ssl_cert_type]
@ssl_key = options[:ssl_key]
@ssl_key_type = options[:ssl_key_type]
@ssl_key_password = options[:ssl_key_password]
@ssl_cacert = options[:ssl_cacert]
@ssl_capath = options[:ssl_capath]
@ssl_version = options[:ssl_version]
@verbose = options[:verbose]
@username = options[:username]
@password = options[:password]
@auth_method = options[:auth_method]
if @method == :post
@url = url
else
@url = @params ? "#{url}?#{params_string}" : url
end
@parsed_uri = URI.parse(@url)
@on_complete = nil
@after_complete = nil
@handled_response = nil
end