spring-projects / spring-framework

Spring Framework
https://spring.io/projects/spring-framework
Apache License 2.0
56.69k stars 38.14k forks source link

Update HttpStatus to align with RFC9110 where relevant #32870

Open DidierLoiseau opened 5 months ago

DidierLoiseau commented 5 months ago

Affects: 6.1

The HttpStatus javadoc links to HTTP Status Code Registry, which in turn refers to RFC9110 (published in June 2022). However the detailed documentation for HttpStatus’s values still refer to RFC7231, which was obsoleted by the former.

Some statuses have been updated. In particular, statuses 421 & 422 which used to be part of WebDav are now part of this RFC. I didn’t check for all statuses or other usages in the documentation.

simonbasle commented 5 months ago

Other changes that I could spot looking at https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml are:

simonbasle commented 5 months ago

We discussed this as a team and we feel such a refresh would best be done after the 6.2.x timeframe, at a minimum. This would imply a full pass on HttpStatus to deprecate codes, introduce new ones and refresh the links in the javadocs.

DidierLoiseau commented 5 months ago

@simonbasle It’s the first time I hear about Spring 7, wouldn’t it make sense to already deprecate those which should be, so that you can change them in 7? I guess 7 is still far away, isn’t it?

Also wouldn’t it be possible to add the new ones already if they don’t clash with anything, so that users don’t have to wait for 7?

(I agree this is a nice to have for now since raw status codes can be used too, but on the other hand RFC 9110 is already 2 years old)

simonbasle commented 5 months ago

yes, sorry, I should have said "after the 6.2.x timeframe, at a minimum". In the meantime, I'd recommend using the raw codes or HttpStatusCode.valueOf(int) as a way of dealing with both known and unknown codes.

snicoll commented 5 months ago

An issue can't be both an enhancement and a documentation so I've removed the former. @simonbasle can you please rephrase the title to properly describe the enhancement? Thanks!

ivamly commented 1 week ago

Hi @snicoll @simonbasle @bclozel! Can I help with this? Here is my step-by-step plan:

  1. Compare all HTTP status codes in HttpStatus with the current RFC 9110 and identify which ones need updates.
  2. Add the new status codes mentioned in the updated RFC to ensure support is up-to-date.
  3. Mark deprecated statuses accordingly to inform users about the potential future changes.
  4. Update all Javadoc links to reference the current RFC 9110.

Let me know if my assistance would be useful or if there are any specific areas I should focus on! Thanks!