GzipFilter: Weaken ETag when gzipping by tsawada · Pull Request #13818 · playframework/playframework
Pull Request Checklist
- Have you read How to write the perfect pull request?
- Have you read through the contributor guidelines?
- Have you referenced any issues you're fixing using commit message keywords?
- Have you added copyright headers to new files?
- Have you checked that both Scala and Java APIs are updated?
- Have you updated the documentation for both Scala and Java sections?
- Have you added tests for any changed functionality?
Purpose
This PR updates GzipFilter to weaken strong ETags when compressing a Result.
If the Result contains an unquoted ETag, which is malformed according to RFC 9110, Section 8.8.3, GzipFilter removes the ETag header entirely.
I think this behavior is the safest fallback to prevent any downstream caching issue with invalid headers. It seems Cloudflare handles malformed ETags this way, according to their documentation.
https://developers.cloudflare.com/cache/reference/etag-headers/#important-remarks
You must set the value in a strong ETag header using double quotes (for example,
etag: "foobar"). If you use an incorrect format, Cloudflare will remove the ETag header instead of converting it to a weak ETag.
I believe this improves adherence to the HTTP standards.