exceptionfactory commented on code in PR #11303:
URL: https://github.com/apache/nifi/pull/11303#discussion_r3342915377


##########
nifi-extension-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/java/org/apache/nifi/web/controller/StandardContentViewerController.java:
##########
@@ -80,38 +92,47 @@ public void doGet(final HttpServletRequest request, final 
HttpServletResponse re
             return;
         }
 
-        response.setStatus(HttpServletResponse.SC_OK);
-
+        final LimitingInputStream contentStream = 
getContentStream(downloadableContent);
         final boolean formatted = 
Boolean.parseBoolean(request.getParameter("formatted"));
-        if (!formatted) {
-            final InputStream contentStream = downloadableContent.getContent();
+        if (formatted) {
+            final ContentType formattedContentType = 
getFormattedContentType(request, downloadableContent.getType());
+            if (formattedContentType == null) {
+                response.sendError(HttpURLConnection.HTTP_NOT_ACCEPTABLE, 
"Unknown Content Type");
+            } else {
+                final String dataUri = requestContext.getDataUri();
+                writeContentFormatted(dataUri, formattedContentType, 
contentStream, response);
+                response.setStatus(HttpServletResponse.SC_OK);
+            }
+        } else {
             contentStream.transferTo(response.getOutputStream());

Review Comment:
   Good catch, the test behavior masked this important detail. I adjusted the 
approach to get the expected Content Length from the source, and used that to 
get and set the response status prior to handling the stream.



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