Skip to content

Commit a3c820c

Browse files
committed
Add support for HTTP method CONNECT in HttpMethod
Introduced a new constant CONNECT with reference to RFC 9110. Updated values array and valueOf method.
1 parent 5489d56 commit a3c820c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

spring-web/src/main/java/org/springframework/http/HttpMethod.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ public final class HttpMethod implements Comparable<HttpMethod>, Serializable {
7171
*/
7272
public static final HttpMethod DELETE = new HttpMethod("DELETE");
7373

74+
/**
75+
* The HTTP method {@code CONNECT}.
76+
* @see <a href="https://www.rfc-editor.org/rfc/rfc9110.html#section-9.3.6">RFC 9110, section 9.3.6</a>
77+
*/
78+
public static final HttpMethod CONNECT = new HttpMethod("CONNECT");
79+
7480
/**
7581
* The HTTP method {@code OPTIONS}.
7682
* @see <a href="https://www.rfc-editor.org/rfc/rfc9110.html#section-9.3.7">RFC 9110, section 9.3.7</a>
@@ -83,7 +89,7 @@ public final class HttpMethod implements Comparable<HttpMethod>, Serializable {
8389
*/
8490
public static final HttpMethod TRACE = new HttpMethod("TRACE");
8591

86-
private static final HttpMethod[] values = new HttpMethod[] { GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE };
92+
private static final HttpMethod[] values = new HttpMethod[] { GET, HEAD, POST, PUT, PATCH, DELETE, CONNECT, OPTIONS, TRACE };
8793

8894

8995
private final String name;
@@ -97,7 +103,7 @@ private HttpMethod(String name) {
97103
* Returns an array containing the standard HTTP methods. Specifically,
98104
* this method returns an array containing {@link #GET}, {@link #HEAD},
99105
* {@link #POST}, {@link #PUT}, {@link #PATCH}, {@link #DELETE},
100-
* {@link #OPTIONS}, and {@link #TRACE}.
106+
* {@link #CONNECT}, {@link #OPTIONS}, and {@link #TRACE}.
101107
*
102108
* <p>Note that the returned value does not include any HTTP methods defined
103109
* in WebDav.
@@ -122,6 +128,7 @@ public static HttpMethod valueOf(String method) {
122128
case "PUT" -> PUT;
123129
case "PATCH" -> PATCH;
124130
case "DELETE" -> DELETE;
131+
case "CONNECT" -> CONNECT;
125132
case "OPTIONS" -> OPTIONS;
126133
case "TRACE" -> TRACE;
127134
default -> new HttpMethod(method);

0 commit comments

Comments
 (0)