Summary: | ETag comparison does not properly implement RFC 7232, section 2.3.2 | ||
---|---|---|---|
Product: | Tomcat 8 | Reporter: | Michael Osipov <michaelo> |
Component: | Catalina | Assignee: | Tomcat Developers Mailing List <dev> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | P2 | ||
Version: | 8.5.x-trunk | ||
Target Milestone: | ---- | ||
Hardware: | All | ||
OS: | All |
Description
Michael Osipov
2020-03-25 14:01:23 UTC
Hi Michael, I see no difference between your > Tomcat returns a weak etag, so try the weak function: >> $ curl "https://.../test/test.txt" -H 'If-None-Match: W/"6-1585143822000"' -I and > If I try strong logically, the following should give me a 200: >> $ curl "https://.../test/test.txt" -H 'If-None-Match: W/"6-1585143822000"' -I The commands are the same. (In reply to mgrigorov from comment #1) > Hi Michael, > > I see no difference between your > > > Tomcat returns a weak etag, so try the weak function: > >> $ curl "https://.../test/test.txt" -H 'If-None-Match: W/"6-1585143822000"' -I > > and > > > If I try strong logically, the following should give me a 200: > >> $ curl "https://.../test/test.txt" -H 'If-None-Match: W/"6-1585143822000"' -I > > The commands are the same. Please read my comments also the defined comparison functions: strong and weak in the RFC. > Please read my comments also the defined comparison functions: strong and weak in the RFC.
I just wanted to point out that the arguments of the two 'curl` commands are exactly the same. So receiving the same result is what I'd expect from the server, unless the resource is modified or deleted in the meantime.
Maybe you have a typo in the second curl command ?!
If this RFC says that two exactly the same requests should behave differently then I am not sure I want to read it.
(In reply to mgrigorov from comment #3) > > Please read my comments also the defined comparison functions: strong and weak in the RFC. > > I just wanted to point out that the arguments of the two 'curl` commands are > exactly the same. So receiving the same result is what I'd expect from the > server, unless the resource is modified or deleted in the meantime. > Maybe you have a typo in the second curl command ?! > > If this RFC says that two exactly the same requests should behave > differently then I am not sure I want to read it. There is no typo and yes, both commands are the same. I have logically applied to comparsion functions. From a blackbox perspective, in either case Tomcat's implementation is wrong. Since we don't document which comparison we apply I have to guess, try. Read the section and you'll understand. The DefaultServlet defers to the WebResources implementation to generate ETags. The WebResource implementation provided by Tomcat is hard-coded to only provide weak ETags. It would be a fair amount of work for a custom implementation to override that (and none has ever asked us to make that easier). Given the above, I think it makes sense for now for the DefaultServlet to perform the weak comparison. If the resource implementation changes, there could be an argument for the DefaultServlet to do something else. I'll work on a patch (and test cases) for DefaultServlet. Fixed in: - master for 10.0.0-M4 onwards - 9.0.x for 9.0.34 onwards - 8.5.x for 8.5.54 onwards - 7.0.x for 7.0.104 onwards We also should implement weak match for If-None-Match I created PR with the fix https://github.com/apache/tomcat/pull/325 |