On 19/11/2024 22:24, r...@apache.org wrote:
This is an automated email from the ASF dual-hosted git repository.

remm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
      new 4810b66087 Add strong ETag support
4810b66087 is described below

commit 4810b660870d6b42bab6b076f57d444cc30b8d8c
Author: remm <r...@apache.org>
AuthorDate: Tue Nov 19 23:24:27 2024 +0100

     Add strong ETag support
Using a useStrongETags init parameter on the default (and WebDAV)
     servlet.
     The ETag generated is a SHA-1 checksum of the file content.

A couple of comments / questions in-line.

<snip/>

diff --git a/java/org/apache/catalina/webresources/AbstractResource.java 
b/java/org/apache/catalina/webresources/AbstractResource.java
index 384c327321..2bd0bdf356 100644
--- a/java/org/apache/catalina/webresources/AbstractResource.java
+++ b/java/org/apache/catalina/webresources/AbstractResource.java

<snip/>

@@ -75,6 +81,52 @@ public abstract class AbstractResource implements 
WebResource {
          return weakETag;
      }
+ @Override
+    public final String getStrongETag() {
+        if (strongETag == null) {
+            synchronized (this) {
+                if (strongETag == null) {
+                    long contentLength = getContentLength();

This doesn't take account of possible conversion on platforms where EBCDIC is the default characterset. You probably want to use getContentLengthInternal() here but that only exists in FileResource.

+                    long lastModified = getLastModified();
+                    if (contentLength > 0 && lastModified > 0) {
+                        try (InputStream is = getInputStream()) {

This will bypass the cache. Is there a way to refactor this to take advantage of any cached content for the resource?

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to