I want to add an ETag to read and write operations. ShallowEtagHeaderFilter does this for the former and as far as I know, I have to deal with the latter. The problem is that ShallowEtagHeaderFilter generates the ETag internally with this method:
protected String generateETagHeaderValue(InputStream inputStream, boolean isWeak) throws IOException {
// length of W/ + " + 0 + 32bits md5 hash + "
StringBuilder builder = new StringBuilder(37);
if (isWeak) {
builder.append("W/");
}
builder.append("\"0");
DigestUtils.appendMd5DigestAsHex(inputStream, builder);
builder.append('"');
return builder.toString();
}
To use this method to generate etags for write operations, I would need to copy and paste it or to make it public by overriding and using the class outside of its intended usecase. It would be much better if this method would be useable by other classes, too.
Comment From: bclozel
As seen in #30517, the ShallowEtagHeaderFilter
is only meant for idempotent HTTP methods. Any other use case should be covered by the ServletWebRequest#checkNotModified
contract.