Add status code 425 ("Too Early") to HttpStatus enum
Closes gh-23384
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -319,6 +319,12 @@ public enum HttpStatus {
|
||||
* @see <a href="https://tools.ietf.org/html/rfc4918#section-11.4">WebDAV</a>
|
||||
*/
|
||||
FAILED_DEPENDENCY(424, "Failed Dependency"),
|
||||
/**
|
||||
* {@code 425 Too Early}.
|
||||
* @since 5.2
|
||||
* @see <a href="https://tools.ietf.org/html/rfc8470">RFC 8470</a>
|
||||
*/
|
||||
TOO_EARLY(425, "Too Early"),
|
||||
/**
|
||||
* {@code 426 Upgrade Required}.
|
||||
* @see <a href="https://tools.ietf.org/html/rfc2817#section-6">Upgrading to TLS Within HTTP/1.1</a>
|
||||
@@ -447,6 +453,7 @@ public enum HttpStatus {
|
||||
* Whether this status code is in the HTTP series
|
||||
* {@link org.springframework.http.HttpStatus.Series#INFORMATIONAL}.
|
||||
* This is a shortcut for checking the value of {@link #series()}.
|
||||
* @since 4.0
|
||||
* @see #series()
|
||||
*/
|
||||
public boolean is1xxInformational() {
|
||||
@@ -457,6 +464,7 @@ public enum HttpStatus {
|
||||
* Whether this status code is in the HTTP series
|
||||
* {@link org.springframework.http.HttpStatus.Series#SUCCESSFUL}.
|
||||
* This is a shortcut for checking the value of {@link #series()}.
|
||||
* @since 4.0
|
||||
* @see #series()
|
||||
*/
|
||||
public boolean is2xxSuccessful() {
|
||||
@@ -467,6 +475,7 @@ public enum HttpStatus {
|
||||
* Whether this status code is in the HTTP series
|
||||
* {@link org.springframework.http.HttpStatus.Series#REDIRECTION}.
|
||||
* This is a shortcut for checking the value of {@link #series()}.
|
||||
* @since 4.0
|
||||
* @see #series()
|
||||
*/
|
||||
public boolean is3xxRedirection() {
|
||||
@@ -477,6 +486,7 @@ public enum HttpStatus {
|
||||
* Whether this status code is in the HTTP series
|
||||
* {@link org.springframework.http.HttpStatus.Series#CLIENT_ERROR}.
|
||||
* This is a shortcut for checking the value of {@link #series()}.
|
||||
* @since 4.0
|
||||
* @see #series()
|
||||
*/
|
||||
public boolean is4xxClientError() {
|
||||
@@ -487,6 +497,7 @@ public enum HttpStatus {
|
||||
* Whether this status code is in the HTTP series
|
||||
* {@link org.springframework.http.HttpStatus.Series#SERVER_ERROR}.
|
||||
* This is a shortcut for checking the value of {@link #series()}.
|
||||
* @since 4.0
|
||||
* @see #series()
|
||||
*/
|
||||
public boolean is5xxServerError() {
|
||||
|
||||
@@ -24,11 +24,14 @@ import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/** @author Arjen Poutsma */
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class HttpStatusTests {
|
||||
|
||||
private Map<Integer, String> statusCodes = new LinkedHashMap<>();
|
||||
|
||||
|
||||
@Before
|
||||
public void createStatusCodes() {
|
||||
statusCodes.put(100, "CONTINUE");
|
||||
@@ -81,6 +84,7 @@ public class HttpStatusTests {
|
||||
statusCodes.put(422, "UNPROCESSABLE_ENTITY");
|
||||
statusCodes.put(423, "LOCKED");
|
||||
statusCodes.put(424, "FAILED_DEPENDENCY");
|
||||
statusCodes.put(425, "TOO_EARLY");
|
||||
statusCodes.put(426, "UPGRADE_REQUIRED");
|
||||
statusCodes.put(428, "PRECONDITION_REQUIRED");
|
||||
statusCodes.put(429, "TOO_MANY_REQUESTS");
|
||||
@@ -101,6 +105,7 @@ public class HttpStatusTests {
|
||||
statusCodes.put(511, "NETWORK_AUTHENTICATION_REQUIRED");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void fromMapToEnum() {
|
||||
for (Map.Entry<Integer, String> entry : statusCodes.entrySet()) {
|
||||
@@ -113,7 +118,6 @@ public class HttpStatusTests {
|
||||
|
||||
@Test
|
||||
public void fromEnumToMap() {
|
||||
|
||||
for (HttpStatus status : HttpStatus.values()) {
|
||||
int value = status.value();
|
||||
if (value == 302 || value == 413 || value == 414) {
|
||||
@@ -123,4 +127,5 @@ public class HttpStatusTests {
|
||||
assertThat(status.name()).as("Invalid name for [" + value + "]").isEqualTo(statusCodes.get(value));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user