lib/spidr/session_cache.rb
def [](url)
      # normalize the url
      url = URI(url)

      # session key
      key = key_for(url)

      unless @sessions[key]
        session = Net::HTTP::Proxy(
          @proxy.host,
          @proxy.port,
          @proxy.user,
          @proxy.password
        ).new(url.host,url.port)

        session.open_timeout       = @open_timeout       if @open_timeout
        session.read_timeout       = @read_timeout       if @read_timeout
        session.continue_timeout   = @continue_timeout   if @continue_timeout
        session.keep_alive_timeout = @keep_alive_timeout if @keep_alive_timeout

        if url.scheme == 'https'
          session.use_ssl     = true
          session.verify_mode = OpenSSL::SSL::VERIFY_NONE
          session.ssl_timeout = @ssl_timeout
          session.start
        end

        @sessions[key] = session
      end

      return @sessions[key]
    end
def [](url)
      # normalize the url
      url = URI(url)

      # session key
      key = key_for(url)

      unless @sessions[key]
        session = Net::HTTP::Proxy(
          @proxy.host,
          @proxy.port,
          @proxy.user,
          @proxy.password
        ).new(url.host,url.port)

        session.open_timeout       = @open_timeout       if @open_timeout
        session.read_timeout       = @read_timeout       if @read_timeout
        session.continue_timeout   = @continue_timeout   if @continue_timeout
        session.keep_alive_timeout = @keep_alive_timeout if @keep_alive_timeout

        if url.scheme == 'https'
          session.use_ssl     = true
          session.verify_mode = OpenSSL::SSL::VERIFY_NONE
          session.ssl_timeout = @ssl_timeout
          session.start
        end

        @sessions[key] = session
      end

      return @sessions[key]
    end
Provides an active HTTP session for a given URL.

 @param [URI::HTTP, String] url
   The URL which will be requested later.

 @return [Net::HTTP]
   The active HTTP session object.