Github user taftster commented on a diff in the pull request:
https://github.com/apache/nifi/pull/272#discussion_r67284145
--- Diff:
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java
---
@@ -761,24 +771,38 @@ private Request configureRequest(final ProcessContext
context, final ProcessSess
}
private RequestBody getRequestBodyToSend(final ProcessSession session,
final ProcessContext context, final FlowFile requestFlowFile) {
-return new RequestBody() {
-@Override
-public MediaType contentType() {
-String contentType =
context.getProperty(PROP_CONTENT_TYPE).evaluateAttributeExpressions(requestFlowFile).getValue();
-contentType = StringUtils.isBlank(contentType) ?
DEFAULT_CONTENT_TYPE : contentType;
-return MediaType.parse(contentType);
-}
+if(context.getProperty(PROP_SEND_BODY).asBoolean()) {
+return new RequestBody() {
+@Override
+public MediaType contentType() {
+String contentType =
context.getProperty(PROP_CONTENT_TYPE).evaluateAttributeExpressions(requestFlowFile).getValue();
+contentType = StringUtils.isBlank(contentType) ?
DEFAULT_CONTENT_TYPE : contentType;
+return MediaType.parse(contentType);
+}
-@Override
-public void writeTo(BufferedSink sink) throws IOException {
-session.exportTo(requestFlowFile, sink.outputStream());
-}
+@Override
+public void writeTo(BufferedSink sink) throws IOException {
+session.exportTo(requestFlowFile, sink.outputStream());
+}
-@Override
-public long contentLength(){
-return useChunked ? -1 : requestFlowFile.getSize();
-}
-};
+@Override
+public long contentLength(){
+return useChunked ? -1 : requestFlowFile.getSize();
+}
+};
+} else {
+return new RequestBody() {
+@Override
+public void writeTo(BufferedSink sink) throws IOException {
+sink.writeUtf8("");
+}
+
+@Override
+public MediaType contentType() {
+return MediaType.parse("");
+}
+};
--- End diff --
For this 'else' clause, it would probably be better to use a RequstBody
static factory. Something like:
`return RequestBody.create(null, new byte[0]);`
I'm not sure the proper way to specific an empty MediaType, though. I think
reading the MediaType javadoc, my hunch is that MediaType.parse("") should
return null (since empty string is an invalid type).
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---