mcgilman commented on code in PR #9134:
URL: https://github.com/apache/nifi/pull/9134#discussion_r1704124349


##########
nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-viewer/src/main/java/org/apache/nifi/web/ContentViewerController.java:
##########
@@ -263,23 +260,11 @@ public String getRawContentType() {
      */
     private ContentRequestContext getContentRequest(final HttpServletRequest 
request) {
         final String ref = request.getParameter("ref");
-        final String clientId = request.getParameter("clientId");
-
-        final UriBuilder refUriBuilder = UriBuilder.fromUri(ref);
-
-        // base the data ref on the request parameter but ensure the scheme is 
based off the incoming request...
-        // this is necessary for scenario's where the NiFi instance is behind 
a proxy running a different scheme
-        refUriBuilder.scheme(request.getScheme());
+        final URI inputRefUri = UriBuilder.fromUri(ref).build();
+        final URI dataUri = 
RequestUriBuilder.fromHttpServletRequest(request).path(inputRefUri.getPath()).build();

Review Comment:
   These changes do not work when clustered and behind a proxy. The incoming 
`ref` is the user facing URI. The previous behavior converted that URI into an 
"internal" URI so that a node could directly `GET` the content from another 
node in the cluster.
   
   Interestingly, this behavior in this PR exposes an issue in handling the 
response of this `GET` because the response does not contain a 
`content-disposition` header and fails with an NPE.
   
   ```
   3296 [APP] 2024-08-05 13:20:45,807 WARN [NiFi Web Server-191] 
org.apache.nifi.web.ContentViewerController Content retrieval failed
   3297 java.lang.NullPointerException: Cannot invoke "String.indexOf(int)" 
because "headerValue" is null
   3298     at 
org.springframework.http.ContentDisposition.tokenize(ContentDisposition.java:454)
   3299     at 
org.springframework.http.ContentDisposition.parse(ContentDisposition.java:344)
   3300     at 
org.apache.nifi.web.StandardNiFiContentAccess.getContent(StandardNiFiContentAccess.java:120)
   3301     at 
org.apache.nifi.web.ContentViewerController.doGet(ContentViewerController.java:95)
   3302     at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:527)
   3303     at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:614)
   ```



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