[
https://issues.apache.org/jira/browse/NIFI-1620?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15205639#comment-15205639
]
ASF GitHub Bot commented on NIFI-1620:
--------------------------------------
Github user taftster commented on a diff in the pull request:
https://github.com/apache/nifi/pull/272#discussion_r56928549
--- Diff:
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java
---
@@ -444,14 +455,27 @@ public void onPropertyModified(final
PropertyDescriptor descriptor, final String
@Override
protected Collection<ValidationResult> customValidate(final
ValidationContext validationContext) {
- final List<ValidationResult> results = new ArrayList<>(1);
+ final List<ValidationResult> results = new
ArrayList<ValidationResult>(3);
+
+ // proxy host and port validation
final boolean proxyHostSet =
validationContext.getProperty(PROP_PROXY_HOST).isSet();
final boolean proxyPortSet =
validationContext.getProperty(PROP_PROXY_PORT).isSet();
-
if ((proxyHostSet && !proxyPortSet) || (!proxyHostSet &&
proxyPortSet)) {
results.add(new ValidationResult.Builder().subject("Proxy Host
and Port").valid(false).explanation("If Proxy Host or Proxy Port is set, both
must be set").build());
}
+ // body and content-type validation
+ final boolean contentTypeSet =
validationContext.getProperty(PROP_CONTENT_TYPE).isSet();
+ final boolean sendBody =
validationContext.getProperty(PROP_SEND_BODY).asBoolean();
+ final String contentType =
validationContext.getProperty(PROP_CONTENT_TYPE).getValue();
+ if(contentTypeSet && contentType.isEmpty() && sendBody) {
+ results.add(new
ValidationResult.Builder().subject("Content-Type and Send body")
+ .valid(false).explanation("If Content-Type is set to
empty, Send body property must be set to false").build());
+ }
+ if(!sendBody && !contentType.isEmpty()) {
+ results.add(new
ValidationResult.Builder().subject("Content-Type and Send
body").valid(false).explanation("If body is not sent, Content-Type must be set
to empty").build());
+ }
+
return results;
--- End diff --
This custom validation rule can be removed if the content-type property is
left alone.
> Allow empty Content-Type in InvokeHTTP processor
> ------------------------------------------------
>
> Key: NIFI-1620
> URL: https://issues.apache.org/jira/browse/NIFI-1620
> Project: Apache NiFi
> Issue Type: Bug
> Components: Extensions
> Affects Versions: 0.5.1
> Reporter: Pierre Villard
> Assignee: Pierre Villard
>
> External API could expect a POST request without a Content-Type property or
> at least with this property empty:
> *Error example:*
> {quote}
> You provided a non-empty HTTP "Content-Type" header ("application/json").
> This API function requires that the header be missing or empty.
> {quote}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)