You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2024/03/06 07:09:21 UTC
(struts) branch feature/WW-5401-logging created (now f45998102)
This is an automated email from the ASF dual-hosted git repository.
lukaszlenart pushed a change to branch feature/WW-5401-logging
in repository https://gitbox.apache.org/repos/asf/struts.git
at f45998102 WW-5401 Improves logging around wrapping request and detecting multipart request
This branch includes the following new commits:
new f45998102 WW-5401 Improves logging around wrapping request and detecting multipart request
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(struts) 01/01: WW-5401 Improves logging around wrapping request and detecting multipart request
Posted by lu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
lukaszlenart pushed a commit to branch feature/WW-5401-logging
in repository https://gitbox.apache.org/repos/asf/struts.git
commit f459981022677b58e65191c5256a16a1cd1114d3
Author: Lukasz Lenart <lu...@apache.org>
AuthorDate: Wed Mar 6 08:09:09 2024 +0100
WW-5401 Improves logging around wrapping request and detecting multipart request
---
.../main/java/org/apache/struts2/dispatcher/Dispatcher.java | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
index 70b85e1b7..fadbc1bd9 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
@@ -986,10 +986,12 @@ public class Dispatcher {
public HttpServletRequest wrapRequest(HttpServletRequest request) throws IOException {
// don't wrap more than once
if (request instanceof StrutsRequestWrapper) {
+ LOG.debug("Request already wrapped with {}", StrutsRequestWrapper.class.getSimpleName());
return request;
}
if (isMultipartSupportEnabled(request) && isMultipartRequest(request)) {
+ LOG.debug("Wrapping multipart request with: {}", MultiPartRequestWrapper.class.getSimpleName());
request = new MultiPartRequestWrapper(
getMultiPartRequest(),
request,
@@ -998,6 +1000,7 @@ public class Dispatcher {
disableRequestAttributeValueStackLookup
);
} else {
+ LOG.debug("Wrapping request using: {}", StrutsRequestWrapper.class.getSimpleName());
request = new StrutsRequestWrapper(request, disableRequestAttributeValueStackLookup);
}
@@ -1012,6 +1015,7 @@ public class Dispatcher {
* @since 2.5.11
*/
protected boolean isMultipartSupportEnabled(HttpServletRequest request) {
+ LOG.debug("Support for multipart request is enabled: {}", multipartSupportEnabled);
return multipartSupportEnabled;
}
@@ -1026,9 +1030,12 @@ public class Dispatcher {
String httpMethod = request.getMethod();
String contentType = request.getContentType();
- return REQUEST_POST_METHOD.equalsIgnoreCase(httpMethod) &&
- contentType != null &&
- multipartValidationPattern.matcher(contentType.toLowerCase(Locale.ENGLISH)).matches();
+ boolean isPostRequest = REQUEST_POST_METHOD.equalsIgnoreCase(httpMethod);
+ boolean isProperContentType = contentType != null && multipartValidationPattern.matcher(contentType.toLowerCase(Locale.ENGLISH)).matches();
+
+ LOG.debug("Validating if this is proper Multipart request. Request is POST: {} and ContentType matches pattern ({}): {}",
+ isPostRequest, multipartValidationPattern, isProperContentType);
+ return isPostRequest && isProperContentType;
}
/**