Skip to content

Commit 7112efe

Browse files
committed
Align HttpStatus with RFC9110
This commit updates the `HttpStatus` enum with the latest changes in RFC9110: * deprecate "413 Payload Too Large" in favor of "413 Content Too Large" * deprecate "418 I'm a teapot" as it was meant as a joke and is now marked as unused * Introduce new "421 Misdirected Request" * deprecate "422 Unprocessable Entity" in favor of "422 Unprocessable Content" * deprecate "509 Bandwidth Limit Exceeded" as it's now unassigned * deprecate "510 Not Extended" as it's now marked as "historic" The relevant exceptions, test matchers and more have been updated as a result. Closes gh-32870
1 parent 606b689 commit 7112efe

File tree

19 files changed

+385
-125
lines changed

19 files changed

+385
-125
lines changed

spring-test/src/main/java/org/springframework/test/web/servlet/result/StatusResultMatchers.java

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ public ResultMatcher isSwitchingProtocols() {
141141

142142
/**
143143
* Assert the response status code is {@code HttpStatus.PROCESSING} (102).
144+
* @deprecated since 7.0, removed from <a href="https://datatracker.ietf.org/doc/html/rfc4918#section-21.4">WebDAV specification</a>
144145
*/
146+
@Deprecated(since = "7.0")
145147
public ResultMatcher isProcessing() {
146148
return matcher(HttpStatus.PROCESSING);
147149
}
@@ -364,10 +366,20 @@ public ResultMatcher isPreconditionFailed() {
364366
return matcher(HttpStatus.PRECONDITION_FAILED);
365367
}
366368

369+
/**
370+
* Assert the response status code is {@code HttpStatus.CONTENT_TOO_LARGE} (413).
371+
* @since 7.0
372+
*/
373+
public ResultMatcher isContentTooLarge() {
374+
return matcher(HttpStatus.CONTENT_TOO_LARGE);
375+
}
376+
367377
/**
368378
* Assert the response status code is {@code HttpStatus.PAYLOAD_TOO_LARGE} (413).
369379
* @since 4.1
380+
* @deprecated since 7.0 in favor of {@link #isContentTooLarge()}
370381
*/
382+
@Deprecated(since = "7.0")
371383
public ResultMatcher isPayloadTooLarge() {
372384
return matcher(HttpStatus.PAYLOAD_TOO_LARGE);
373385
}
@@ -403,14 +415,34 @@ public ResultMatcher isExpectationFailed() {
403415

404416
/**
405417
* Assert the response status code is {@code HttpStatus.I_AM_A_TEAPOT} (418).
418+
* @deprecated since 7.0, this was marked as unused in RFC 9110
406419
*/
420+
@Deprecated(since = "7.0")
407421
public ResultMatcher isIAmATeapot() {
408-
return matcher(HttpStatus.valueOf(418));
422+
return matcher(HttpStatus.I_AM_A_TEAPOT);
423+
}
424+
425+
/**
426+
* Assert the response status code is {@code HttpStatus.MISDIRECTED_REQUEST} (421).
427+
* @since 7.0
428+
*/
429+
public ResultMatcher isMisdirectedRequest() {
430+
return matcher(HttpStatus.MISDIRECTED_REQUEST);
431+
}
432+
433+
/**
434+
* Assert the response status code is {@code HttpStatus.UNPROCESSABLE_CONTENT} (422).
435+
* @since 7.0
436+
*/
437+
public ResultMatcher isUnprocessableContent() {
438+
return matcher(HttpStatus.UNPROCESSABLE_CONTENT);
409439
}
410440

411441
/**
412442
* Assert the response status code is {@code HttpStatus.UNPROCESSABLE_ENTITY} (422).
443+
* @deprecated since 7.0 in favor of {@link #isUnprocessableContent()}
413444
*/
445+
@Deprecated(since = "7.0")
414446
public ResultMatcher isUnprocessableEntity() {
415447
return matcher(HttpStatus.UNPROCESSABLE_ENTITY);
416448
}
@@ -538,14 +570,18 @@ public ResultMatcher isLoopDetected() {
538570

539571
/**
540572
* Assert the response status code is {@code HttpStatus.BANDWIDTH_LIMIT_EXCEEDED} (509).
573+
* @deprecated since 7.0, since this is now unassigned
541574
*/
575+
@Deprecated(since = "7.0")
542576
public ResultMatcher isBandwidthLimitExceeded() {
543-
return matcher(HttpStatus.valueOf(509));
577+
return matcher(HttpStatus.BANDWIDTH_LIMIT_EXCEEDED);
544578
}
545579

546580
/**
547581
* Assert the response status code is {@code HttpStatus.NOT_EXTENDED} (510).
582+
* @deprecated since 7.0, this is now marked as "historic" and not endorsed by a standards body.
548583
*/
584+
@Deprecated(since = "7.0")
549585
public ResultMatcher isNotExtended() {
550586
return matcher(HttpStatus.NOT_EXTENDED);
551587
}

spring-test/src/main/kotlin/org/springframework/test/web/servlet/result/StatusResultMatchersDsl.kt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ class StatusResultMatchersDsl internal constructor (private val actions: ResultA
110110
/**
111111
* @see StatusResultMatchers.isProcessing
112112
*/
113+
@Deprecated("Removed from WebDAV specification RFC 4918")
114+
@Suppress("DEPRECATION")
113115
fun isProcessing() {
114116
actions.andExpect(matchers.isProcessing())
115117
}
@@ -325,9 +327,18 @@ class StatusResultMatchersDsl internal constructor (private val actions: ResultA
325327
actions.andExpect(matchers.isPreconditionFailed())
326328
}
327329

330+
/**
331+
* @see StatusResultMatchers.isContentTooLarge
332+
*/
333+
fun isContentTooLarge() {
334+
actions.andExpect(matchers.isContentTooLarge())
335+
}
336+
328337
/**
329338
* @see StatusResultMatchers.isPayloadTooLarge
330339
*/
340+
@Deprecated("Use Content Too Large instead", replaceWith = ReplaceWith("isContentTooLarge()"))
341+
@Suppress("DEPRECATION")
331342
fun isPayloadTooLarge() {
332343
actions.andExpect(matchers.isPayloadTooLarge())
333344
}
@@ -363,13 +374,33 @@ class StatusResultMatchersDsl internal constructor (private val actions: ResultA
363374
/**
364375
* @see StatusResultMatchers.isIAmATeapot
365376
*/
377+
@Deprecated("Marked as unused in RFC 9110")
378+
@Suppress("DEPRECATION")
366379
fun isIAmATeapot() {
367380
actions.andExpect(matchers.isIAmATeapot())
368381
}
369382

383+
/**
384+
* @see StatusResultMatchers.isMisdirectedRequest
385+
* @since 7.0
386+
*/
387+
fun isMisdirectedRequest() {
388+
actions.andExpect(matchers.isMisdirectedRequest())
389+
}
390+
391+
/**
392+
* @see StatusResultMatchers.isUnprocessableContent
393+
* @since 7.0
394+
*/
395+
fun isUnprocessableContent() {
396+
actions.andExpect(matchers.isUnprocessableContent())
397+
}
398+
370399
/**
371400
* @see StatusResultMatchers.isUnprocessableEntity
372401
*/
402+
@Deprecated("Use UnprocessableContent instead.", ReplaceWith("isUnprocessableContent()"))
403+
@Suppress("DEPRECATION")
373404
fun isUnprocessableEntity() {
374405
actions.andExpect(matchers.isUnprocessableEntity())
375406
}
@@ -496,13 +527,17 @@ class StatusResultMatchersDsl internal constructor (private val actions: ResultA
496527
/**
497528
* @see StatusResultMatchers.isBandwidthLimitExceeded
498529
*/
530+
@Deprecated("This is now unassigned")
531+
@Suppress("DEPRECATION")
499532
fun isBandwidthLimitExceeded() {
500533
actions.andExpect(matchers.isBandwidthLimitExceeded())
501534
}
502535

503536
/**
504537
* @see StatusResultMatchers.isNotExtended
505538
*/
539+
@Deprecated("This is marked as 'historic' and is not endorsed by a standards body")
540+
@Suppress("DEPRECATION")
506541
fun isNotExtended() {
507542
actions.andExpect(matchers.isNotExtended())
508543
}

0 commit comments

Comments
 (0)