void sendDirectory(HttpRequest request,
                       HttpResponse response,
                       Resource resource,
                       boolean parent)
        throws IOException
    {
        if (!_dirAllowed)
        {
            response.sendError(HttpResponse.__403_Forbidden);
            return;
        }
        
        request.setHandled(true);
        
        if(log.isDebugEnabled())log.debug("sendDirectory: "+resource);
        byte[] data=null;
        if (resource instanceof CachedResource)
            data=((CachedResource)resource).getCachedData();
        
        if (data==null)
        {
            String base = URI.addPaths(request.getPath(),"/");
            String dir = resource.getListHTML(URI.encodePath(base),parent);
            if (dir==null)
            {
                response.sendError(HttpResponse.__403_Forbidden,
                                   "No directory");
                return;
            }
            data=dir.getBytes("UTF8");
            if (resource instanceof CachedResource)
                ((CachedResource)resource).setCachedData(data);
        }
        
        response.setContentType("text/html; charset=UTF8");
        response.setContentLength(data.length);
        
        if (request.getMethod().equals(HttpRequest.__HEAD))
        {
            response.commit();
            return;
        }
        
        response.getOutputStream().write(data,0,data.length);
        response.commit();
    }
void sendDirectory ( HttpRequest request , HttpResponse response , Resource resource , boolean parent ) throws IOException { if ( ! _dirAllowed ) { response . sendError ( HttpResponse . __403_Forbidden ) ; return ; } request . setHandled ( true ) ; if ( log . isDebugEnabled ( ) ) log . debug ( "sendDirectory: " + resource ) ; byte [ ] data = null ; if ( resource instanceof CachedResource ) data = ( ( CachedResource ) resource ) . getCachedData ( ) ; if ( data == null ) { String base = URI . addPaths ( request . getPath ( ) , "/" ) ; String dir = resource . getListHTML ( URI . encodePath ( base ) , parent ) ; if ( dir == null ) { response . sendError ( HttpResponse . __403_Forbidden , "No directory" ) ; return ; } data = dir . getBytes ( "UTF8" ) ; if ( resource instanceof CachedResource ) ( ( CachedResource ) resource ) . setCachedData ( data ) ; } response . setContentType ( "text/html; charset=UTF8" ) ; response . setContentLength ( data . length ) ; if ( request . getMethod ( ) . equals ( HttpRequest . __HEAD ) ) { response . commit ( ) ; return ; } response . getOutputStream ( ) . write ( data , 0 , data . length ) ; response . commit ( ) ; }
/* -------------------------------------------------------------------