Use HttpMethod.GET for better readability

See gh-33634
This commit is contained in:
jun 2024-10-02 22:42:07 +09:00 committed by Stéphane Nicoll
parent b54420f8aa
commit a668580f77
1 changed files with 2 additions and 1 deletions

View File

@ -22,6 +22,7 @@ import jakarta.servlet.http.HttpServletRequest;
import org.springframework.context.Lifecycle;
import org.springframework.context.SmartLifecycle;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.lang.Nullable;
import org.springframework.web.context.ServletContextAware;
import org.springframework.web.servlet.HandlerExecutionChain;
@ -126,7 +127,7 @@ public class WebSocketHandlerMapping extends SimpleUrlHandlerMapping implements
handler = (handler instanceof HandlerExecutionChain chain ? chain.getHandler() : handler);
if (this.webSocketUpgradeMatch && handler instanceof WebSocketHttpRequestHandler) {
String header = request.getHeader(HttpHeaders.UPGRADE);
return (request.getMethod().equals("GET") &&
return (HttpMethod.GET.matches(request.getMethod()) &&
header != null && header.equalsIgnoreCase("websocket"));
}
return true;