# File lib/rubygems/server.rb, line 506
  def quick(req, res)
    @source_index.refresh!

    res['content-type'] = 'text/plain'
    res['date'] = File.stat(@spec_dir).mtime

    case req.request_uri.path
    when '/quick/index' then
      res.body << @source_index.map { |name,| name }.sort.join("\n")
    when '/quick/index.rz' then
      index = @source_index.map { |name,| name }.sort.join("\n")
      res['content-type'] = 'application/x-deflate'
      res.body << Gem.deflate(index)
    when '/quick/latest_index' then
      index = @source_index.latest_specs.map { |spec| spec.full_name }
      res.body << index.sort.join("\n")
    when '/quick/latest_index.rz' then
      index = @source_index.latest_specs.map { |spec| spec.full_name }
      res['content-type'] = 'application/x-deflate'
      res.body << Gem.deflate(index.sort.join("\n"))
    when %r|^/quick/(Marshal.#{Regexp.escape Gem.marshal_version}/)?(.*?)-([0-9.]+)(-.*?)?\.gemspec\.rz$| then
      dep = Gem::Dependency.new $2, $3
      specs = @source_index.search dep
      marshal_format = $1

      selector = [$2, $3, $4].map { |s| s.inspect }.join ' '

      platform = if $4 then
                   Gem::Platform.new $4.sub(/^-/, '')
                 else
                   Gem::Platform::RUBY
                 end

      specs = specs.select { |s| s.platform == platform }

      if specs.empty? then
        res.status = 404
        res.body = "No gems found matching #{selector}"
      elsif specs.length > 1 then
        res.status = 500
        res.body = "Multiple gems found matching #{selector}"
      elsif marshal_format then
        res['content-type'] = 'application/x-deflate'
        res.body << Gem.deflate(Marshal.dump(specs.first))
      else # deprecated YAML format
        res['content-type'] = 'application/x-deflate'
        res.body << Gem.deflate(specs.first.to_yaml)
      end
    else
      raise WEBrick::HTTPStatus::NotFound, "`#{req.path}' not found."
    end
  end