Skip to content

Behavior of checkNotModified(String etag, long lastModifiedTimestamp) does not match HTTP recommendations [SPR-14224] #18798

@spring-projects-issues

Description

@spring-projects-issues

Sebastiaan van Erk opened SPR-14224 and commented

According to RFC2616 https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html if a request has the If-None-Match or If-Modified-Since headers are set on a request (that is, either one or the other, but not both), a 304 Not Modified can be returned if the the ETag matches or the resource is has not been modified since the specified date.

According to the same specification, if both headers are set, the behavior of the server is undefined. In other words, a client should never use both, as it does not make sense (the server could return "418 I'm a teapot" if it felt like it).

Thus for the checkNotModified(String etag, long lastModifiedTimestamp) method to be useful, it should:

  • Check the etag if the If-None-Match header is the only header present.
  • Check the last modified timestamp if the If-Modified-Since header is the only header present.
  • Do something sane if both are present (which they shouldn't be). In my opinion, the most sane option is to check the etag, because it's generally stronger than the last modified date.

However, currently the implementation of the method returns false unless both headers are present (a case which should never happen). Thus effectively it always returns false.


Affects: 4.2.5

Issue Links:

Referenced from: commits a50ea80

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions