You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2025/02/28 16:13:25 UTC

[Bug 69602] New: IF-Range Check for Strong-ETags breaks download of large videos

https://bz.apache.org/bugzilla/show_bug.cgi?id=69602

            Bug ID: 69602
           Summary: IF-Range Check for Strong-ETags breaks download of
                    large videos
           Product: Tomcat 9
           Version: 9.0.99
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
          Assignee: dev@tomcat.apache.org
          Reporter: cmm@stl.gmbh
  Target Milestone: -----

Hi guys,

we recognized a severe problem when using tomcat to deliver web based trainings
housing large videos.

How to reproduce:

Microsoft Edge Browser:

* request a large video
* getting a weak ETag, which is default of the DefaultServelet
* cancelling the streaming
* jump to a further location in the video
* Microsoft Edge request the same video but this time with a range request
** if-range: W/"696184473-1709306080000"
** range: bytes=89030656-696184472
* Tomcat 9.0.99 produced a status 400 since the new if-range validation rejects
weak ETags
** cf.
https://github.com/apache/tomcat/commit/99f25115e34ffaa1c7f7bf7003077b12931c5d72

So by default Tomcat 9 rejects ETags that it delivered itself.

Current workaround: adapt Default-Servlet-Config

<init-param>
        <param-name>useStrongETags</param-name>
        <param-value>true</param-value>
</init-param>

I guess this is a bad constellation:
* either activate strong ETags by default
** probable performance impact
* accept weak ETags in if-ranges
** concurs with if-range syntax
*** https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Range

Thank you for helping with this issue.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 69602] IF-Range Check for Strong-ETags breaks download of large videos

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69602

--- Comment #6 from Mark Thomas <ma...@apache.org> ---
Not a veto. See dev@ for further thoughts.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 69602] IF-Range Check for Strong-ETags breaks download of large videos

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69602

--- Comment #2 from Chris <cm...@stl.gmbh> ---
After the code refactoring a String 

W/"696184473-1709306080000"

is falling through the if expression check

if (headerValue.length() < 2 || headerValue.charAt(0) != '"' ||
    headerValue.charAt(headerValue.length() - 1) != '"' ||
    headerValue.indexOf('"', 1) != headerValue.length() - 1) {
    // Not a single, strong entity tag
  response.sendError(HttpServletResponse.SC_BAD_REQUEST);
  return false;
}

Since the String does not start with:
headerValue.charAt(0)
vs.
W/"696184473-1709306080000"

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 69602] IF-Range Check for Strong-ETags breaks download of large videos

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69602

Remy Maucherat <re...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from Remy Maucherat <re...@apache.org> ---
This will be fixed in 11.0.6, 10.1.38 and 9.0.101.

Note: I decided to include this fix in 9.0.101 since this was reported against
9.0.x.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 69602] IF-Range Check for Strong-ETags breaks download of large videos

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69602

--- Comment #4 from Mark Thomas <ma...@apache.org> ---
Note that the client in this case is broken. As per RFC 9110:

"A client MUST NOT generate an If-Range header field containing an entity tag
that is marked as weak."

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 69602] IF-Range Check for Strong-ETags breaks download of large videos

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69602

--- Comment #5 from Remy Maucherat <re...@apache.org> ---
(In reply to Mark Thomas from comment #4)
> Note that the client in this case is broken. As per RFC 9110:
> 
> "A client MUST NOT generate an If-Range header field containing an entity
> tag that is marked as weak."

I missed this, looking mostly at the grammar for the header (which refers to
the usual etag).
Although "broken", the client simply uses the etag sent by the server. To avoid
it, the client would have to do an extra check for W/.

If this is a veto, I will revert the fix and the answer to this BZ will be to
configure Tomcat to use strong etags.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 69602] IF-Range Check for Strong-ETags breaks download of large videos

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69602

--- Comment #7 from Remy Maucherat <re...@apache.org> ---
Ok, so there will not be a 400 anymore (a weak etag is not an invalid etag),
but If-Range will no longer match when a weak etag is sent (the full resource
will be returned). String etags will need to be used.

The change will be in 11.0.6, 10.1.38 and 9.0.102.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 69602] IF-Range Check for Strong-ETags breaks download of large videos

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69602

Remy Maucherat <re...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

--- Comment #1 from Remy Maucherat <re...@apache.org> ---
Ok, I see no indication that weak etags are not allowed there, If-Range is
either an etag (W/"something" or "something") or a date.

As for the cost of enabling string tags, it's not that terrible in most cases.
It will go over the file content only once to hash it, then the result will be
cached.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org