cziegeler commented on code in PR #75:
URL:
https://github.com/apache/sling-org-apache-sling-engine/pull/75#discussion_r3280965414
##########
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:
Removing commons fileupload from Felix http is imho not easy, not sure if it
is even possible; at least I couldnt find a way without and still passing the
TCK - but that doesnt mean there is none
--
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]