remm 02/03/09 15:22:38 Modified: catalina/src/share/org/apache/catalina/servlets DefaultServlet.java WebdavServlet.java Log: - Add some hooks to allow the directory context implementation to compute strong etags. Revision Changes Path 1.51 +22 -26 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java Index: DefaultServlet.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java,v retrieving revision 1.50 retrieving revision 1.51 diff -u -r1.50 -r1.51 --- DefaultServlet.java 8 Jan 2002 12:14:57 -0000 1.50 +++ DefaultServlet.java 9 Mar 2002 23:22:38 -0000 1.51 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java,v 1.50 2002/01/08 12:14:57 remm Exp $ - * $Revision: 1.50 $ - * $Date: 2002/01/08 12:14:57 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java,v 1.51 2002/03/09 23:22:38 remm Exp $ + * $Revision: 1.51 $ + * $Date: 2002/03/09 23:22:38 $ * * ==================================================================== * @@ -125,7 +125,7 @@ * * @author Craig R. McClanahan * @author Remy Maucherat - * @version $Revision: 1.50 $ $Date: 2002/01/08 12:14:57 $ + * @version $Revision: 1.51 $ $Date: 2002/03/09 23:22:38 $ */ public class DefaultServlet @@ -785,7 +785,7 @@ ResourceInfo resourceInfo) throws IOException { - String eTag = getETag(resourceInfo, true); + String eTag = getETag(resourceInfo); long fileLength = resourceInfo.length; long lastModified = resourceInfo.date; @@ -918,31 +918,21 @@ /** - * Get the ETag value associated with a file. - * - * @param resourceInfo File object - * @param strong True if we want a strong ETag, in which case a checksum - * of the file has to be calculated - */ - protected String getETagValue(ResourceInfo resourceInfo, boolean strong) { - // FIXME : Compute a strong ETag if requested, using an MD5 digest - // of the file contents - return resourceInfo.length + "-" + resourceInfo.date; - } - - - /** * Get the ETag associated with a file. * * @param resourceInfo File object * @param strong True if we want a strong ETag, in which case a checksum * of the file has to be calculated */ - protected String getETag(ResourceInfo resourceInfo, boolean strong) { - if (strong) - return "\"" + getETagValue(resourceInfo, strong) + "\""; - else - return "W/\"" + getETagValue(resourceInfo, strong) + "\""; + protected String getETag(ResourceInfo resourceInfo) { + if (resourceInfo.strongETag != null) { + return resourceInfo.strongETag; + } else if (resourceInfo.weakETag != null) { + return resourceInfo.weakETag; + } else { + return "W/\"" + resourceInfo.length + "-" + + resourceInfo.date + "\""; + } } @@ -1199,7 +1189,7 @@ ranges = parseRange(request, response, resourceInfo); // ETag header - response.setHeader("ETag", getETag(resourceInfo, true)); + response.setHeader("ETag", getETag(resourceInfo)); // Last-Modified header if (debug > 0) @@ -1416,7 +1406,7 @@ String headerValue = request.getHeader("If-Range"); if (headerValue != null) { - String eTag = getETag(resourceInfo, true); + String eTag = getETag(resourceInfo); long lastModified = resourceInfo.date; Date date = null; @@ -2269,6 +2259,8 @@ public long date; public long length; public boolean collection; + public String weakETag; + public String strongETag; public boolean exists; public DirContext resources; protected InputStream is; @@ -2285,6 +2277,8 @@ date = 0; length = -1; collection = true; + weakETag = null; + strongETag = null; exists = false; resources = null; is = null; @@ -2329,6 +2323,8 @@ } else { httpDate = FastHttpDateFormat.getCurrentDate(); } + weakETag = tempAttrs.getETag(); + strongETag = tempAttrs.getETag(true); length = tempAttrs.getContentLength(); } } catch (NamingException e) { 1.27 +11 -7 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/WebdavServlet.java Index: WebdavServlet.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/WebdavServlet.java,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- WebdavServlet.java 3 Jan 2002 08:52:56 -0000 1.26 +++ WebdavServlet.java 9 Mar 2002 23:22:38 -0000 1.27 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/WebdavServlet.java,v 1.26 2002/01/03 08:52:56 remm Exp $ - * $Revision: 1.26 $ - * $Date: 2002/01/03 08:52:56 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/WebdavServlet.java,v 1.27 2002/03/09 23:22:38 remm Exp $ + * $Revision: 1.27 $ + * $Date: 2002/03/09 23:22:38 $ * * ==================================================================== * @@ -126,7 +126,7 @@ * are handled by the DefaultServlet. * * @author Remy Maucherat - * @version $Revision: 1.26 $ $Date: 2002/01/03 08:52:56 $ + * @version $Revision: 1.27 $ $Date: 2002/03/09 23:22:38 $ */ public class WebdavServlet @@ -1388,6 +1388,11 @@ // -------------------------------------------------------- Private Methods + protected String getETagValue(ResourceInfo resourceInfo) { + return resourceInfo.length + "-" + resourceInfo.date; + } + + /** * Generate the namespace declarations. */ @@ -2043,7 +2048,7 @@ (null, "getcontenttype", getServletContext().getMimeType(resourceInfo.path)); generatedXML.writeProperty(null, "getetag", - getETagValue(resourceInfo, true)); + getETagValue(resourceInfo)); generatedXML.writeElement(null, "resourcetype", XMLWriter.NO_CONTENT); } else { @@ -2170,8 +2175,7 @@ propertiesNotFound.addElement(property); } else { generatedXML.writeProperty - (null, "getetag", - getETagValue(resourceInfo, true)); + (null, "getetag", getETagValue(resourceInfo)); } } else if (property.equals("getlastmodified")) { if (resourceInfo.collection) {
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>