From: Jules G. <jul...@us...> - 2002-10-17 23:41:56
|
User: jules_gosnell Date: 02/10/17 16:41:55 Modified: jetty/src/main/org/mortbay/http/handler ResourceHandler.java Log: + Stop/Start filtesr in declaration order. + Some AJP13 optimizations. + Use "standard" names for default,jsp & invoker servlets. + Fixed caching of directories to avoid shared buffers. + Fixed bad log dir detection + Fix Session invalidation bug Revision Changes Path 1.20 +43 -14 contrib/jetty/src/main/org/mortbay/http/handler/ResourceHandler.java Index: ResourceHandler.java =================================================================== RCS file: /cvsroot/jboss/contrib/jetty/src/main/org/mortbay/http/handler/ResourceHandler.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- ResourceHandler.java 15 Sep 2002 13:22:40 -0000 1.19 +++ ResourceHandler.java 17 Oct 2002 23:41:55 -0000 1.20 @@ -1,6 +1,6 @@ // =========================================================================== // Copyright (c) 1996-2002 Mort Bay Consulting Pty. Ltd. All rights reserved. -// $Id: ResourceHandler.java,v 1.19 2002/09/15 13:22:40 jules_gosnell Exp $ +// $Id: ResourceHandler.java,v 1.20 2002/10/17 23:41:55 jules_gosnell Exp $ // --------------------------------------------------------------------------- package org.mortbay.http.handler; @@ -46,7 +46,7 @@ * A simple memory cache is also provided to reduce file I/O. * HTTP/1.1 ranges are supported. * - * @version $Id: ResourceHandler.java,v 1.19 2002/09/15 13:22:40 jules_gosnell Exp $ + * @version $Id: ResourceHandler.java,v 1.20 2002/10/17 23:41:55 jules_gosnell Exp $ * @author Nuno Preguiça * @author Greg Wilkins */ @@ -313,8 +313,26 @@ { if (!request.getMethod().equals(HttpRequest.__HEAD)) { - // check any modified headers. + // If we have meta data for the file + // Try a direct match for most common requests. Avoids + // parsing the date. + HttpContext.ResourceMetaData metaData = + (HttpContext.ResourceMetaData)resource.getAssociate(); + if (metaData!=null) + { + String ifms=request.getField(HttpFields.__IfModifiedSince); + String mdlm=metaData.getLastModified(); + if (ifms!=null && mdlm!=null && ifms.equals(mdlm)) + { + response.setStatus(HttpResponse.__304_Not_Modified); + request.setHandled(true); + return false; + } + } + + long date=0; + // Parse the if[un]modified dates and compare to resource if ((date=request.getDateField(HttpFields.__IfUnmodifiedSince))>0) { @@ -676,20 +694,31 @@ throws IOException { request.setHandled(true); - Code.debug("sendDirectory: "+resource); - String base = URI.addPaths(request.getPath(),"/"); - ByteArrayISO8859Writer dir = getHttpContext() - .getDirectoryListing(resource,base,parent); - if (dir==null) - { - response.sendError(HttpResponse.__403_Forbidden, - "No directory"); - return; + + Code.debug("sendDirectory: "+resource); + byte[] data=null; + if (resource instanceof CachedResource) + data=((CachedResource)resource).getCachedData(); + + if (data==null) + { + String base = URI.addPaths(request.getPath(),"/"); + ByteArrayISO8859Writer dir = getHttpContext() + .getDirectoryListing(resource,base,parent); + if (dir==null) + { + response.sendError(HttpResponse.__403_Forbidden, + "No directory"); + return; + } + data=dir.getByteArray(); + if (resource instanceof CachedResource) + ((CachedResource)resource).setCachedData(data); } response.setContentType("text/html"); - response.setContentLength(dir.length()); + response.setContentLength(data.length); if (request.getMethod().equals(HttpRequest.__HEAD)) { @@ -697,7 +726,7 @@ return; } - dir.writeTo(response.getOutputStream()); + response.getOutputStream().write(data,0,data.length); response.commit(); } |