Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Externelize Etag generation from ShallowEtagHeaderFilter #27179

Closed
Shryne opened this issue Jul 15, 2021 · 1 comment
Closed

Externelize Etag generation from ShallowEtagHeaderFilter #27179

Shryne opened this issue Jul 15, 2021 · 1 comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: declined A suggestion or change that we don't feel we should currently apply

Comments

@Shryne
Copy link

Shryne commented Jul 15, 2021

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jul 15, 2021
@rstoyanchev rstoyanchev added the in: web Issues in web modules (web, webmvc, webflux, websocket) label Nov 10, 2021
@bclozel
Copy link
Member

bclozel commented Jul 17, 2023

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.

@bclozel bclozel closed this as not planned Won't fix, can't repro, duplicate, stale Jul 17, 2023
@bclozel bclozel added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

No branches or pull requests

4 participants