alopresto commented on a change in pull request #4125: NIFI-7153 Adds 
ContentLengthFilter and DoSFilter
URL: https://github.com/apache/nifi/pull/4125#discussion_r390685310
 
 

 ##########
 File path: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-jetty/src/main/java/org/apache/nifi/web/server/JettyServer.java
 ##########
 @@ -607,6 +612,25 @@ private WebAppContext loadWar(final File warFile, final 
String contextPath, fina
         return webappContext;
     }
 
+    private void addContentLengthFilter(String contextPath, String pathSpec, 
WebAppContext webappContext) {
+        final FilterHolder holder = new 
FilterHolder(ContentLengthFilter.class);
+        final Map<String, String> largePaths = 
props.getWebMaxContentSizeLargePaths();
+        int size;
+
+        if (!largePaths.containsValue(contextPath)) {
+            size = DataUnit.parseDataSize(props.getWebMaxContentSize(), 
DataUnit.B).intValue();
+        } else {
+            size = DataUnit.parseDataSize(props.getWebMaxContentSizeLarge(), 
DataUnit.B).intValue();
+        }
+        holder.setInitParameters(new HashMap<String, String>() {{
+            put("maxContentLength", String.valueOf(size));
+        }});
+
+        logger.info("Adding Content Length Filter to context at pathSpec: " + 
contextPath + " with max size: " + size + "b");
+        // NB: the use of pathSpec vs contextPath
 
 Review comment:
   What is the difference between `pathSpec` and `contextPath` here? It appears 
from the calling method that `pathSpec` will always be `ALL_PATHS` -- is it 
necessary to parameterize?
   
   How does the `contextPath` hierarchy work here when multiple values are 
present in `largePaths`?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to