enapps-enorman commented on code in PR #75:
URL:
https://github.com/apache/sling-org-apache-sling-engine/pull/75#discussion_r3276161020
##########
src/main/java/org/apache/sling/engine/impl/parameters/ParameterSupport.java:
##########
@@ -390,55 +346,22 @@ private static final boolean
isWWWFormEncodedContent(HttpServletRequest request)
return false;
}
- private RequestContext getMultiPartContext() {
- return new RequestContext() {
- @Override
- public String getCharacterEncoding() {
- String enc = getServletRequest().getCharacterEncoding();
- return (enc != null) ? enc : Util.ENCODING_DIRECT;
- }
-
- @Override
- public int getContentLength() {
- return getServletRequest().getContentLength();
- }
-
- @Override
- public String getContentType() {
- return getServletRequest().getContentType();
- }
-
- @Override
- public InputStream getInputStream() throws IOException {
- return getServletRequest().getInputStream();
- }
- };
+ /**
+ * Checks if the request is a multipart post
+ *
+ * @param request the request to check
+ * @return true if the request is multipart, false otherwise
+ */
+ private static boolean isMultipartContent(HttpServletRequest request) {
+ final String contentType = request.getContentType();
+ return contentType != null &&
contentType.toLowerCase(Locale.ENGLISH).startsWith(MULTPART);
}
- private void parseMultiPartPost(ParameterMap parameters) {
- // Create a new file upload handler
- ServletFileUpload upload = new ServletFileUpload();
- upload.setSizeMax(ParameterSupport.maxRequestSize);
- upload.setFileSizeMax(ParameterSupport.maxFileSize);
- upload.setFileItemFactory(
- new DiskFileItemFactory(ParameterSupport.fileSizeThreshold,
ParameterSupport.location));
- upload.setFileCountMax(ParameterSupport.maxFileCount);
- final RequestContext rc = this.getMultiPartContext();
-
- // Parse the request
- List<?> /* FileItem */ items = null;
- try {
- items = upload.parseRequest(rc);
- } catch (FileUploadException fue) {
- this.log.error("parseMultiPartPost: Error parsing request", fue);
- }
-
- if (items != null && items.size() > 0) {
- for (Iterator<?> ii = items.iterator(); ii.hasNext(); ) {
- DiskFileItem fileItem = (DiskFileItem) ii.next();
- RequestParameter pp = new MultipartRequestParameter(fileItem);
- parameters.addParameter(pp, false);
- }
+ private void parseMultiPartPost(ParameterMap parameters) throws
IOException, ServletException {
+ final Collection<Part> parts = this.getServletRequest().getParts();
Review Comment:
Ok, I guess I can pass that through again. However, my next step was going
to be attempting to remove the commons-fileupload dependency from the
felix.http stuff as well since they should just delegate to jetty to parse the
multipart stuff too. And I don't believe jetty currently has any mechanism to
limit the max number of file parts.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]