Skip to content

Commit b224fea

Browse files
committed
Exclude CONNECT from allowed HTTP methods
Updated initAllowedHttpMethods in WebContentGenerator and RequestMappingInfoHandlerMapping to explicitly exclude the CONNECT method.
1 parent 18106b3 commit b224fea

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoHandlerMapping.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ private static Set<HttpMethod> initAllowedHttpMethods(Set<String> declaredMethod
517517
Set<HttpMethod> result = CollectionUtils.newLinkedHashSet(declaredMethods.size());
518518
if (declaredMethods.isEmpty()) {
519519
for (HttpMethod method : HttpMethod.values()) {
520-
if (method != HttpMethod.TRACE) {
520+
if (method != HttpMethod.TRACE && method != HttpMethod.CONNECT) {
521521
result.add(method);
522522
}
523523
}

spring-webmvc/src/main/java/org/springframework/web/servlet/support/WebContentGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ private void initAllowHeader() {
146146
if (this.supportedMethods == null) {
147147
allowedMethods = new ArrayList<>(HttpMethod.values().length - 1);
148148
for (HttpMethod method : HttpMethod.values()) {
149-
if (method != HttpMethod.TRACE) {
149+
if (method != HttpMethod.TRACE && method != HttpMethod.CONNECT) {
150150
allowedMethods.add(method.name());
151151
}
152152
}

0 commit comments

Comments
 (0)