# File mod_docs/local.rb, line 69
  def publish(script_name, request, response, logger)
    logger.debug("enter document: #{self.class}")
    script_name2, path = request.subpath(script_name)
    if (path !~ %r"^/") then
      raise 'mismatch script_name.'
    end
    if (path !~ %r"/$") then
      raise 'not a directory path.'
    end
    if (path == '/') then
      local_dir = @root
    else
      local_dir = File.join(@root, http2local(path))
    end

    if (File.directory? local_dir) then
      case (request.method)
      when 'GET', 'HEAD'
        response.status = 200  # OK
        response.set_header('Content-Type', 'text/html')
        response.start_body
        if (request.method != 'HEAD') then
          response << "<html>\n"
          response << "<head><title>" << escapeHTML(request.path) << "</title></head>\n"
          response << "<body>\n"
          response << "<h1>" << escapeHTML(request.path) << "</h1>\n"
          response << '<p><a href="..">parent directory...</a></p>' << "\n"
          response << "<ul>\n"
          name_list = Dir.entries(local_dir)
          name_list.sort!
          for name in name_list
            next if (name =~ /^\./)
            local_path = File.join(local_dir, name)
            http_path = request.path + name
            http_name = name
            if (File.directory? local_path) then
              http_path += '/'
              http_name += '/'
            end
            response << '<li><a href="' << escapeHTML(http_path) << '">'
            response << escapeHTML(http_name)
            response << "</a></li>\n"
          end
          response << "</ul>\n"
          response << "</body>\n"
          response << "</html>\n"
        end
      else
        http_error = HTTPError.new(405) # Method Not Allowed
        http_error.set_header('Allow', 'GET, HEAD')
        raise http_error
      end
    else
      raise HTTPError.new(404) # Not Found
    end

    nil
  end