Deprecate HttpStatus 103 CHECKPOINT in favor of new EARLY_HINTS (#29816)
This commit takes rfc8297 into account and introduces a newer code 103 HttpStatus value which uses `Early Hints` as the more correct reason phrase, deprecating the outdated `CHECKPOINT` enum value for 103. Additionally: - `HttpStatus.valueOf(103)` will return the new enum value - `HttpStatusCode#isSameCodeAs(HttpStatusCode)` is introduced to ease comparison of deprecated enums vs their newer counterparts (or any instance of a more generic `HttpStatusCode`) by comparing the integer `value()` - `HttpStatusTests` covers the new deprecation as well as the three previously deprecated codes, including a check with the above new method to ensure they have comparable integer values Supersedes and Closes gh-27960
This commit is contained in:
@@ -50,11 +50,18 @@ public enum HttpStatus implements HttpStatusCode {
|
||||
* @see <a href="https://tools.ietf.org/html/rfc2518#section-10.1">WebDAV</a>
|
||||
*/
|
||||
PROCESSING(102, Series.INFORMATIONAL, "Processing"),
|
||||
/**
|
||||
* {code 103 Early Hints}.
|
||||
* @see <a href="https://tools.ietf.org/html/rfc8297">An HTTP Status Code for Indicating Hints</a>
|
||||
*/
|
||||
EARLY_HINTS(103, Series.INFORMATIONAL, "Early Hints"),
|
||||
/**
|
||||
* {@code 103 Checkpoint}.
|
||||
* @see <a href="https://code.google.com/p/gears/wiki/ResumableHttpRequestsProposal">A proposal for supporting
|
||||
* resumable POST/PUT HTTP requests in HTTP/1.0</a>
|
||||
* @deprecated in favor of {@link #EARLY_HINTS} which will be returned from {@code HttpStatus.valueOf(103)}
|
||||
*/
|
||||
@Deprecated(since = "6.0")
|
||||
CHECKPOINT(103, Series.INFORMATIONAL, "Checkpoint"),
|
||||
|
||||
// 2xx Success
|
||||
|
||||
@@ -76,6 +76,16 @@ public sealed interface HttpStatusCode extends Serializable permits DefaultHttpS
|
||||
*/
|
||||
boolean isError();
|
||||
|
||||
/**
|
||||
* Whether this {@code HttpStatusCode} shares the same integer {@link #value() value} as the other status code.
|
||||
* <p>Useful for comparisons that take deprecated aliases into account or compare arbitrary implementations
|
||||
* of {@code HttpStatusCode} (e.g. in place of {@link HttpStatus#equals(Object) HttpStatus enum equality}).
|
||||
* @param other the other {@code HttpStatusCode} to compare
|
||||
* @return true if the two {@code HttpStatusCode} share the same integer {@code value()}, false otherwise
|
||||
*/
|
||||
default boolean isSameCodeAs(HttpStatusCode other) {
|
||||
return value() == other.value();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an {@code HttpStatusCode} object for the given integer value.
|
||||
|
||||
Reference in New Issue
Block a user