# File lib/mongrel/handlers.rb, line 168
168:     def send_dir_listing(base, dir, response)
169:       # take off any trailing / so the links come out right
170:       base = HttpRequest.unescape(base)
171:       base.chop! if base[-1] == "/"[-1]
172: 
173:       if @listing_allowed
174:         response.start(200) do |head,out|
175:           head[Const::CONTENT_TYPE] = "text/html"
176:           out << "<html><head><title>Directory Listing</title></head><body>"
177:           Dir.entries(dir).each do |child|
178:             child = HttpRequest.unescape(child)
179:             next if child == "."
180: 
181:             if child == ".."
182:               out << "<a href=\"#{base}/#{child}\">Up to parent..</a><br/>"
183:             else
184:               out << "<a href=\"#{base}/#{child}/\">#{child}</a><br/>"
185:             end
186:           end
187:           out << "</body></html>"
188:         end
189:       else
190:         response.start(403) do |head,out|
191:           out.write("Directory listings not allowed")
192:         end
193:       end
194:     end