Skip to content

Commit 55faf6e

Browse files
BryceYangSrstoyanchev
authored andcommitted
Use HttpMethod enums
See gh-26855
1 parent a522ed0 commit 55faf6e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import org.springframework.core.io.ClassPathResource;
5050
import org.springframework.core.io.support.PropertiesLoaderUtils;
5151
import org.springframework.core.log.LogFormatUtils;
52+
import org.springframework.http.HttpMethod;
5253
import org.springframework.http.server.RequestPath;
5354
import org.springframework.http.server.ServletServerHttpRequest;
5455
import org.springframework.lang.Nullable;
@@ -1046,8 +1047,8 @@ protected void doDispatch(HttpServletRequest request, HttpServletResponse respon
10461047

10471048
// Process last-modified header, if supported by the handler.
10481049
String method = request.getMethod();
1049-
boolean isGet = "GET".equals(method);
1050-
if (isGet || "HEAD".equals(method)) {
1050+
boolean isGet = HttpMethod.GET.matches(method);
1051+
if (isGet || HttpMethod.HEAD.matches(method)) {
10511052
long lastModified = ha.getLastModified(request, mappedHandler.getHandler());
10521053
if (new ServletWebRequest(request, response).checkNotModified(lastModified) && isGet) {
10531054
return;

0 commit comments

Comments
 (0)