def get_cookies(request_uri, opts = {})
      uri = to_uri request_uri
      hosts = Cookie.compute_search_domains uri

      return [] if hosts.nil?

      path = if uri.path == ''
               '/'
             else
               uri.path
      end

      results = []
      hosts.each do |host|
        domain = find_domain host
        domain.each do |apath, cookies|
          next unless path.start_with? apath
          results += cookies.values.select do |cookie|
            cookie.should_send? uri, opts[:script]
          end
        end
      end
      # Sort by path length, longest first
      results.sort do |lhs, rhs|
        rhs.path.length <=> lhs.path.length
      end
    end
def get_cookies(request_uri, opts = {})
      uri = to_uri request_uri
      hosts = Cookie.compute_search_domains uri

      return [] if hosts.nil?

      path = if uri.path == ''
               '/'
             else
               uri.path
      end

      results = []
      hosts.each do |host|
        domain = find_domain host
        domain.each do |apath, cookies|
          next unless path.start_with? apath
          results += cookies.values.select do |cookie|
            cookie.should_send? uri, opts[:script]
          end
        end
      end
      # Sort by path length, longest first
      results.sort do |lhs, rhs|
        rhs.path.length <=> lhs.path.length
      end
    end
Given a request URI, return a sorted list of Cookie objects. Cookies
 will be in order per RFC 2965 - sorted by longest path length, but
 otherwise unordered.

 @param [String, URI] request_uri the address the HTTP request will be
   sent to. This must be a full URI, i.e. must include the protocol,
   if you pass digi.ninja it will fail to find the domain, you must pass
   http://digi.ninja
 @param [Hash] opts options controlling returned cookies
 @option opts [Boolean] :script (false) Cookies marked HTTP-only will be
   ignored if true
 @return [Array<Cookie>] cookies which should be sent in the HTTP request