def fetch_named_query_url(url, redirects_left)
      raise 'You need to be authenticated to use named queries' unless @userid
      http = Net::HTTP.new(@api_url.host, @api_url.port)
      http.set_debug_output(Bicho::LoggerIODevice.new)
      http.verify_mode = OpenSSL::SSL::VERIFY_NONE
      http.use_ssl = (@api_url.scheme == 'https')
      # request = Net::HTTP::Get.new(url.request_uri, {'Cookie' => self.cookie})
      request = Net::HTTP::Get.new(url.request_uri)
      request.basic_auth @api_url.user, @api_url.password
      response = http.request(request)
      case response
      when Net::HTTPSuccess
        bugs = []
        begin
          xml = Nokogiri::XML.parse(response.body)
          xml.root.xpath('//xmlns:entry/xmlns:link/@href', xml.root.namespace).each do |attr|
            uri = URI.parse attr.value
            bugs << uri.query.split('=')[1]
          end
          return bugs
        rescue Nokogiri::XML::XPath::SyntaxError
          raise "Named query '#{url.request_uri}' not found"
        end
      when Net::HTTPRedirection
        location = response['location']
        if redirects_left.zero?
          raise "Maximum redirects exceeded (redirected to #{location})"
        end
        new_location_uri = URI.parse(location)
        logger.debug("Moved to #{new_location_uri}")
        fetch_named_query_url(new_location_uri, redirects_left - 1)
      else
        raise "Error when expanding named query '#{url.request_uri}': #{response}"
      end
    end
def fetch_named_query_url(url, redirects_left)
      raise 'You need to be authenticated to use named queries' unless @userid
      http = Net::HTTP.new(@api_url.host, @api_url.port)
      http.set_debug_output(Bicho::LoggerIODevice.new)
      http.verify_mode = OpenSSL::SSL::VERIFY_NONE
      http.use_ssl = (@api_url.scheme == 'https')
      # request = Net::HTTP::Get.new(url.request_uri, {'Cookie' => self.cookie})
      request = Net::HTTP::Get.new(url.request_uri)
      request.basic_auth @api_url.user, @api_url.password
      response = http.request(request)
      case response
      when Net::HTTPSuccess
        bugs = []
        begin
          xml = Nokogiri::XML.parse(response.body)
          xml.root.xpath('//xmlns:entry/xmlns:link/@href', xml.root.namespace).each do |attr|
            uri = URI.parse attr.value
            bugs << uri.query.split('=')[1]
          end
          return bugs
        rescue Nokogiri::XML::XPath::SyntaxError
          raise "Named query '#{url.request_uri}' not found"
        end
      when Net::HTTPRedirection
        location = response['location']
        if redirects_left.zero?
          raise "Maximum redirects exceeded (redirected to #{location})"
        end
        new_location_uri = URI.parse(location)
        logger.debug("Moved to #{new_location_uri}")
        fetch_named_query_url(new_location_uri, redirects_left - 1)
      else
        raise "Error when expanding named query '#{url.request_uri}': #{response}"
      end
    end
Fetches a named query by its full url
 @private
 @returns [Array<String>] list of bugs