A HEAD request answered 304 (Not Modified) carries all the entity headers
Problem
RFC 9110 §15.4.5: a 304 response must carry the validators and caching headers a 200 would have (ETag, Content-Location, Date, Vary, Cache-Control, Expires), and the server SHOULD NOT send other representation metadata. A HEAD request evaluated to 304 is answered like the GET (§9.3.2: a HEAD response has the headers of the GET response).
The server adapters test the method HEAD before the status 304, so a HEAD answered 304 goes through the HEAD branch, which writes all the entity headers (Content-Type, Last-Modified, Content-Length, ...), instead of the 304 branch that writes the restricted set (HeaderUtils.addNotModifiedEntityHeaders).
Measured on 3.0, 2.7 and 2.6 (real server, raw socket, a resource with tag, modification date, expiration date and a text/plain entity; headers of the answer, Server, Date and Connection left out):
3.0 GET If-None-Match -> 304: etag, expires
3.0 HEAD If-None-Match -> 304: content-length, content-type, expires, last-modified, etag
2.7 GET If-None-Match -> 304: etag, expires, content-length
2.7 HEAD If-None-Match -> 304: content-type, expires, last-modified, etag, content-length
2.6 GET If-None-Match -> 304: etag, expires
2.6 HEAD If-None-Match -> 304: last-modified, content-type, etag, content-length, expires
The code: 3.0 NettyServerCall.prepareEntity and 2.7 / 2.6 ServerAdapter.commit start their chain of tests with Method.HEAD.equals(method), before the 304 test.
Proposal
Test the 304 status before the HEAD method in the three versions, so that a HEAD answered 304 carries exactly what the GET answered 304 carries. Other statuses are unchanged.