exceptionfactory commented on a change in pull request #5446:
URL: https://github.com/apache/nifi/pull/5446#discussion_r724540893
##########
File path:
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/servlets/ListenHTTPServlet.java
##########
@@ -433,6 +422,63 @@ protected void proceedFlow(final HttpServletRequest
request, final HttpServletRe
}
}
+ protected FlowFile saveRequestDetailsAsAttributes(final HttpServletRequest
request, final ProcessSession session,
+ final String
foundSubject, final String foundIssuer, FlowFile flowFile) {
+ Map<String, String> attributes = new HashMap<>();
+ addMatchingRequestHeaders(request, attributes);
+ flowFile = session.putAllAttributes(flowFile, attributes);
+ flowFile = session.putAttribute(flowFile,
"restlistener.remote.source.host", request.getRemoteHost());
+ flowFile = session.putAttribute(flowFile, "restlistener.request.uri",
request.getRequestURI());
+ flowFile = session.putAttribute(flowFile,
"restlistener.remote.user.dn", foundSubject);
+ flowFile = session.putAttribute(flowFile,
"restlistener.remote.issuer.dn", foundIssuer);
+ return flowFile;
+ }
+
+ private void processRecord(InputStream in, FlowFile flowFile, OutputStream
out) {
+ try (final RecordReader reader =
readerFactory.createRecordReader(flowFile, new BufferedInputStream(in),
logger)) {
+ final RecordSet recordSet = reader.createRecordSet();
+ final PushBackRecordSet pushBackSet = new
PushBackRecordSet(recordSet);
+
+ try (final RecordSetWriter writer =
writerFactory.createWriter(logger, reader.getSchema(), out, flowFile)) {
+ // Reading in records and evaluate script
+ while (pushBackSet.isAnotherRecord()) {
+ final Record record = pushBackSet.next();
+ writer.write(record);
+ }
+ }
+ } catch (IOException | MalformedRecordException |
SchemaNotFoundException e) {
+ logger.error("Could not process record.", e);
+ }
Review comment:
Although this logs an error, it does not communicate failures to the
client sending to ListenHTTP. There are several options for handling this, but
it seems like exceptions in this method should result an in HTTP 400 response
status.
##########
File path:
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestListenHTTP.java
##########
@@ -461,6 +464,36 @@ public void
testMaxThreadPoolSizeSpecifiedInThePropertyIsSetInTheServerInstance(
assertEquals(maxThreadPoolSize, sizedThreadPool.getMaxThreads());
}
+ @Test
+ public void testPOSTRequestsReceivedWithRecordReader() throws Exception {
Review comment:
It would also be helpful to test failure conditions, such as data that
fails to parse with the configured Record Reader.
--
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]