500: def send_dir_listing(base, dir, response)
501:
502: base.chop! if base[-1] == "/"[-1]
503:
504: if @listing_allowed
505: response.start(200) do |head,out|
506: head['Content-Type'] = "text/html"
507: out << "<html><head><title>Directory Listing</title></head><body>"
508: Dir.entries(dir).each do |child|
509: next if child == "."
510:
511: if child == ".."
512: out << "<a href=\"#{base}/#{child}\">Up to parent..</a><br/>"
513: else
514: out << "<a href=\"#{base}/#{child}\">#{child}</a><br/>"
515: end
516: end
517: out << "</body></html>"
518: end
519: else
520: response.start(403) do |head,out|
521: out.write("Directory listings not allowed")
522: end
523: end
524: end