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