Skip to content

Commit

Permalink
fix: multipart 요청 필터링
Browse files Browse the repository at this point in the history
  • Loading branch information
fromitive committed Aug 8, 2024
1 parent 9f9030b commit 3e0a9b8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,20 @@ public class LoggingFilter implements Filter {
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
if (isMultipart(request)) {
chain.doFilter(request, response);
}
HttpServletRequest wrappedRequest
= new CachedHttpServletRequestWrapper((HttpServletRequest) request);
CachedHttpServletResponseWrapper wrappedResponse
= new CachedHttpServletResponseWrapper((HttpServletResponse) response);
chain.doFilter(wrappedRequest, wrappedResponse);
wrappedResponse.copyBodyToResponse();
}

private boolean isMultipart(ServletRequest request) {
String contentType = request.getContentType();
return contentType != null && contentType.toLowerCase().startsWith("multipart/");
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,5 @@ public void afterCompletion(HttpServletRequest request,
requestBody, statusCode, responseBody, latency);
log.warn(logResponse.toString());
}

}
}

0 comments on commit 3e0a9b8

Please sign in to comment.