garydgregory commented on code in PR #429:
URL: 
https://github.com/apache/commons-fileupload/pull/429#discussion_r2220016612


##########
commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/AbstractFileUpload.java:
##########
@@ -29,6 +29,8 @@
 import 
org.apache.commons.fileupload2.core.FileItemFactory.AbstractFileItemBuilder;
 import org.apache.commons.io.IOUtils;
 
+import static 
org.apache.commons.fileupload2.core.MultipartInput.DEFAULT_PART_HEADER_SIZE_MAX;

Review Comment:
   No static imports please (except JUnit).



##########
commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/AbstractFileUpload.java:
##########
@@ -347,6 +354,17 @@ public FileItemHeaders getParsedHeaders(final String 
headerPart) {
         return headers;
     }
 
+    /**
+     * Obtain the per part size limit for headers.

Review Comment:
   "Obtain" -> "Gets", see the other setter just below.



##########
commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/AbstractSizesTest.java:
##########
@@ -39,6 +39,41 @@
 public abstract class AbstractSizesTest<AFU extends AbstractFileUpload<R, I, 
F>, R, I extends FileItem<I>, F extends FileItemFactory<I>>
         extends AbstractTest<AFU, R, I, F> {
 
+    /**
+     * Checks, whether limiting the PartHeaderSizeMax works.
+     *
+     * @throws IOException Test failure.
+     */
+    @Test
+    void testFilePartHeaderSizeMax() throws IOException {
+        final String request = "-----1234\r\n" +
+            "Content-Disposition: form-data; name=\"file\"; 
filename=\"foo.tab\"\r\n" +
+            "Content-Type: text/whatever\r\n" +
+            "Content-Length: 10\r\n" +
+            "\r\n" +
+            "This is the content of the file\n" +
+            "\r\n" +
+            "-----1234--\r\n";
+
+        final var upload = newFileUpload();
+        upload.setPartHeaderSizeMax(200);
+        final var req = newMockHttpServletRequest(request, null, null);
+        final var fileItems = upload.parseRequest(req);
+        assertEquals(1, fileItems.size());
+        final var item = fileItems.get(0);
+        assertEquals("This is the content of the file\n", new 
String(item.get()));
+
+        var upload2 = newFileUpload();
+        upload2.setPartHeaderSizeMax(10);
+        var req2 = newMockHttpServletRequest(request, null, null);
+        try {
+            upload2.parseRequest(req2);

Review Comment:
   Use assertThrows()



##########
commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/AbstractSizesTest.java:
##########
@@ -39,6 +39,41 @@
 public abstract class AbstractSizesTest<AFU extends AbstractFileUpload<R, I, 
F>, R, I extends FileItem<I>, F extends FileItemFactory<I>>
         extends AbstractTest<AFU, R, I, F> {
 
+    /**
+     * Checks, whether limiting the PartHeaderSizeMax works.

Review Comment:
   No comma needed



-- 
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]

Reply via email to