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

Enhancement Proposal: *Context.cacheControl() #1291

Open
mkarg opened this issue Nov 19, 2024 · 6 comments
Open

Enhancement Proposal: *Context.cacheControl() #1291

mkarg opened this issue Nov 19, 2024 · 6 comments

Comments

@mkarg
Copy link
Contributor

mkarg commented Nov 19, 2024

Recently we deprecated CacheControl.valueOf(String), but the replacement is a rather clumsy code line: RuntimeDelegate.getInstance().createHeaderDelegate(CacheControl.class).fromString(value). This is very annoying e. g. when migrating filters from 2.x to 3.x.

To make the programmer's life easier, I like to propose that we add support for some syntactic sugar:

  • Add new method cacheControl() on Client/Server Request/Response Context returning a modifiable instance of CacheControl initialized by the content of the Cache-Control header.
@jamezp
Copy link
Contributor

jamezp commented Nov 19, 2024

I'd agree that is pretty clumsy. There could be a reason, but why weren't the method calls simply changed to use that long form instead of deprecating the methods?

The CacheControl type itself is rather out of date. The current HTTP RFC for caching is RFC 9111. This is kind of a broader issue in the REST spec in general though having references to long obsolete RFC's.

@mkarg
Copy link
Contributor Author

mkarg commented Nov 20, 2024

I don't know the actual reason why deprecating CacheControl.valueOf(String) months ago, but in fact it is deprecated now, so IMHO we cannot simply remove the deprecation state and change the implementation. 🤔

Nevertheless, I think programmers would be more happy about ctx.cacheControl() than with CacheControl.valueOf(ctx.getHeaderString(HttpHeaders.CACHE_CONTROL)).

Regarding RFC 9111 I think we should separate adding syntactic sugar (this PR) from supporting newer RFCs (separate OR).

@mkarg
Copy link
Contributor Author

mkarg commented Nov 25, 2024

Kindly asking for more opinions. If nobody vetos ctx.cacheControl() upfront, I will provide a PR plus a compliant implementation (PR for Jersey) in the next weeks.

@spericas
Copy link
Contributor

spericas commented Dec 2, 2024

@mkarg Could you link the PR that deprecated the valueOf method? I can't recall how we got there.

@mkarg
Copy link
Contributor Author

mkarg commented Dec 2, 2024

@mkarg Could you link the PR that deprecated the valueOf method? I can't recall how we got there.

https://github.com/jakartaee/rest/pull/608/files#diff-afeba8f9ca4f7cce75662eac8255baeacc627b3f6383ad001ff5bfa1c65a57a1L86

@mkarg
Copy link
Contributor Author

mkarg commented Dec 17, 2024

There had been not upfront vetos, so I assume everybody is fine with adopting this enhancement. If not, please clearly tell me NOW. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants