diff --git a/spring-web/src/main/java/org/springframework/http/server/ServletServerHttpRequest.java b/spring-web/src/main/java/org/springframework/http/server/ServletServerHttpRequest.java index 6993a840be..2712de7eb4 100644 --- a/spring-web/src/main/java/org/springframework/http/server/ServletServerHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/server/ServletServerHttpRequest.java @@ -56,8 +56,6 @@ import org.springframework.util.StringUtils; */ public class ServletServerHttpRequest implements ServerHttpRequest { - protected static final String FORM_CONTENT_TYPE = "application/x-www-form-urlencoded"; - protected static final Charset FORM_CHARSET = StandardCharsets.UTF_8; @@ -230,7 +228,7 @@ public class ServletServerHttpRequest implements ServerHttpRequest { private static boolean isFormPost(HttpServletRequest request) { String contentType = request.getContentType(); - return (contentType != null && contentType.contains(FORM_CONTENT_TYPE) && + return (contentType != null && contentType.contains(MediaType.APPLICATION_FORM_URLENCODED_VALUE) && HttpMethod.POST.matches(request.getMethod())); } diff --git a/spring-web/src/main/java/org/springframework/web/util/ContentCachingRequestWrapper.java b/spring-web/src/main/java/org/springframework/web/util/ContentCachingRequestWrapper.java index 6b2bb021a8..29b93e01a8 100644 --- a/spring-web/src/main/java/org/springframework/web/util/ContentCachingRequestWrapper.java +++ b/spring-web/src/main/java/org/springframework/web/util/ContentCachingRequestWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +33,7 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequestWrapper; import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; import org.springframework.lang.Nullable; /** @@ -54,9 +55,6 @@ import org.springframework.lang.Nullable; */ public class ContentCachingRequestWrapper extends HttpServletRequestWrapper { - private static final String FORM_CONTENT_TYPE = "application/x-www-form-urlencoded"; - - private final ByteArrayOutputStream cachedContent; @Nullable @@ -151,7 +149,7 @@ public class ContentCachingRequestWrapper extends HttpServletRequestWrapper { private boolean isFormPost() { String contentType = getContentType(); - return (contentType != null && contentType.contains(FORM_CONTENT_TYPE) && + return (contentType != null && contentType.contains(MediaType.APPLICATION_FORM_URLENCODED_VALUE) && HttpMethod.POST.matches(getMethod())); } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/adapter/AbstractListenerWebSocketSession.java b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/adapter/AbstractListenerWebSocketSession.java index 98669f781b..551436ca35 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/adapter/AbstractListenerWebSocketSession.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/adapter/AbstractListenerWebSocketSession.java @@ -221,7 +221,13 @@ public abstract class AbstractListenerWebSocketSession extends AbstractWebSoc // Ignore result: can't overflow, ok if not first or no one listens this.handlerCompletionSink.tryEmitError(ex); } - close(CloseStatus.SERVER_ERROR.withReason(ex.getMessage())); + if (logger.isDebugEnabled()) { + logger.debug("WebSocket session completed with error", ex); + } + else if (logger.isInfoEnabled()) { + logger.info("WebSocket session completed with error: " + ex.getMessage()); + } + close(CloseStatus.SERVER_ERROR); } @Override diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java index 34b4aedda6..cdc396639c 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java @@ -49,6 +49,7 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.support.PropertiesLoaderUtils; import org.springframework.core.log.LogFormatUtils; import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; import org.springframework.http.server.RequestPath; import org.springframework.http.server.ServletServerHttpRequest; import org.springframework.lang.Nullable; @@ -986,7 +987,7 @@ public class DispatcherServlet extends FrameworkServlet { } else { // Avoid request body parsing for form data - params = (StringUtils.startsWithIgnoreCase(contentType, "application/x-www-form-urlencoded") || + params = (StringUtils.startsWithIgnoreCase(contentType, MediaType.APPLICATION_FORM_URLENCODED_VALUE) || !request.getParameterMap().isEmpty() ? "masked" : ""); }