This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push:
new f9ed0f7400 Add additional HTTP status code constants defined for
Servlet 6.1
f9ed0f7400 is described below
commit f9ed0f74008c47396a70a69b418f8df44cbff860
Author: Mark Thomas <[email protected]>
AuthorDate: Mon Feb 13 17:29:35 2023 +0000
Add additional HTTP status code constants defined for Servlet 6.1
Use the constants where appropriate
---
java/jakarta/servlet/http/HttpServletResponse.java | 25 ++++++++++++++++++++++
.../tomcat/websocket/server/UpgradeUtil.java | 2 +-
.../servlets/TestDefaultServletRedirect.java | 2 +-
webapps/docs/changelog.xml | 5 +++++
4 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/java/jakarta/servlet/http/HttpServletResponse.java
b/java/jakarta/servlet/http/HttpServletResponse.java
index 7b1e84e2fa..d633678eda 100644
--- a/java/jakarta/servlet/http/HttpServletResponse.java
+++ b/java/jakarta/servlet/http/HttpServletResponse.java
@@ -388,6 +388,12 @@ public interface HttpServletResponse extends
ServletResponse {
*/
public static final int SC_TEMPORARY_REDIRECT = 307;
+ /**
+ * Status code (308) indicating that the requested resource resides
permanently under a different URI. The new URI
+ * <em>SHOULD</em> be given by the <code><em>Location</em></code> field in
the response.
+ */
+ public static final int SC_PERMANENT_REDIRECT = 308;
+
/**
* Status code (400) indicating the request sent by the client was
syntactically incorrect.
*/
@@ -488,6 +494,25 @@ public interface HttpServletResponse extends
ServletResponse {
*/
public static final int SC_EXPECTATION_FAILED = 417;
+ /**
+ * Status code (421) indicating that the server is unwilling or unable to
produce an authoritative response for the
+ * target URI.
+ */
+ public static final int SC_MISDIRECTED_REQUEST = 421;
+
+ /**
+ * Status code (422) indicating that the server understands the content
type of the request but is unable to process
+ * the contained instructions.
+ */
+ public static final int SC_UNPROCESSABLE_CONTENT = 422;
+
+ /**
+ * Status code (426) indicating that the server refuses to perform the
request using the current protocol but may be
+ * willing to do so after the client upgrades to a different protocol. The
server must include an appropriate
+ * {@code Upgrade} header in the response.
+ */
+ public static final int SC_UPGRADE_REQUIRED = 426;
+
/**
* Status code (500) indicating an error inside the HTTP server which
prevented it from fulfilling the request.
*/
diff --git a/java/org/apache/tomcat/websocket/server/UpgradeUtil.java
b/java/org/apache/tomcat/websocket/server/UpgradeUtil.java
index b0e6b49328..09fa90021e 100644
--- a/java/org/apache/tomcat/websocket/server/UpgradeUtil.java
+++ b/java/org/apache/tomcat/websocket/server/UpgradeUtil.java
@@ -100,7 +100,7 @@ public class UpgradeUtil {
}
if (!headerContainsToken(req, Constants.WS_VERSION_HEADER_NAME,
Constants.WS_VERSION_HEADER_VALUE)) {
- resp.setStatus(426);
+ resp.setStatus(HttpServletResponse.SC_UPGRADE_REQUIRED);
resp.setHeader(Constants.WS_VERSION_HEADER_NAME,
Constants.WS_VERSION_HEADER_VALUE);
return;
diff --git a/test/org/apache/catalina/servlets/TestDefaultServletRedirect.java
b/test/org/apache/catalina/servlets/TestDefaultServletRedirect.java
index 60e75d9ac8..1a455c9fb2 100644
--- a/test/org/apache/catalina/servlets/TestDefaultServletRedirect.java
+++ b/test/org/apache/catalina/servlets/TestDefaultServletRedirect.java
@@ -54,7 +54,7 @@ public class TestDefaultServletRedirect extends
TomcatBaseTest {
parameterSets.add(new Object[] {
Integer.valueOf(HttpServletResponse.SC_MOVED_PERMANENTLY) });
parameterSets.add(new Object[] {
Integer.valueOf(HttpServletResponse.SC_FOUND) });
parameterSets.add(new Object[] {
Integer.valueOf(HttpServletResponse.SC_TEMPORARY_REDIRECT) });
- parameterSets.add(new Object[] { Integer.valueOf(308) });
+ parameterSets.add(new Object[] {
Integer.valueOf(HttpServletResponse.SC_PERMANENT_REDIRECT) });
return parameterSets;
}
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index e898d09c6f..843885e5b5 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -175,6 +175,11 @@
<code>RemoteIpFilter</code> determines that this request was submitted
via a secure channel. (lihan)
</fix>
+ <add>
+ Add the additional HTTP status code constants to
+ <code>HttpServletResponse</code> defined by the Jakarta Servlet project
+ for the Servlet 6.1 API. (markt)
+ </add>
</changelog>
</subsection>
<subsection name="Coyote">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]