You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by nickcarenza <gi...@git.apache.org> on 2017/01/05 02:43:15 UTC

[GitHub] nifi pull request #1395: NIFI-3280 [WIP] PostHTTP Option to write response t...

GitHub user nickcarenza opened a pull request:

    https://github.com/apache/nifi/pull/1395

    NIFI-3280 [WIP] PostHTTP Option to write response to attribute or flowfile content

     - property to store response body in attribute or replace flowfile content
     - property to set which attribute to store response body in
     - property to store response code in attribute
     - property to set which attribute to store response code in

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/nickcarenza/nifi NIFI-3280

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/nifi/pull/1395.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1395
    
----
commit c5fac63cccf743aa1838e9325e5002d460745531
Author: Nick Carenza <ni...@thecontrolgroup.com>
Date:   2017-01-05T02:39:13Z

    NIFI-3280

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi issue #1395: NIFI-3280 PostHTTP Option to write response to attribute o...

Posted by trixpan <gi...@git.apache.org>.
Github user trixpan commented on the issue:

    https://github.com/apache/nifi/pull/1395
  
    @nickcarenza - welcome. We all have been in that very same boat once. :smiley: 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi issue #1395: NIFI-3280 PostHTTP Option to write response to attribute o...

Posted by nickcarenza <gi...@git.apache.org>.
Github user nickcarenza commented on the issue:

    https://github.com/apache/nifi/pull/1395
  
    ### For all changes:
    - [x] Is there a JIRA ticket associated with this PR? Is it referenced 
         in the commit message?
    
    - [x] Does your PR title start with NIFI-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
    
    - [ ] Has your PR been rebased against the latest commit within the target branch (typically master)?
    
    - [ ] Is your initial contribution a single, squashed commit?
    
    ### For code changes:
    - [ ] Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder?
    - [x] Have you written or updated unit tests to verify your changes?
    - [ ] ~If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?~
    - [ ] ~If applicable, have you updated the LICENSE file, including the main LICENSE file under nifi-assembly?~
    - [ ] ~If applicable, have you updated the NOTICE file, including the main NOTICE file found under nifi-assembly?~
    - [x] If adding new Properties, have you added .displayName in addition to .name (programmatic access) for each of the new properties?
    
    ### For documentation related changes:
    - [ ] ~Have you ensured that format looks appropriate for the output in which it is rendered?~
    
    ### Note:
    Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi issue #1395: NIFI-3280 PostHTTP Option to write response to attribute o...

Posted by alopresto <gi...@git.apache.org>.
Github user alopresto commented on the issue:

    https://github.com/apache/nifi/pull/1395
  
    Some of us more than once. 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi issue #1395: NIFI-3280 PostHTTP Option to write response to attribute o...

Posted by trixpan <gi...@git.apache.org>.
Github user trixpan commented on the issue:

    https://github.com/apache/nifi/pull/1395
  
    @nickcarenza thank you for the contribution. May I ask you to squash the commit as requested by the PR template?
    
    ` Is your initial contribution a single, squashed commit?`
    
    At least you have been honest and left it blank. :-)


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi issue #1395: NIFI-3280 PostHTTP Option to write response to attribute o...

Posted by trixpan <gi...@git.apache.org>.
Github user trixpan commented on the issue:

    https://github.com/apache/nifi/pull/1395
  
    @nickcarenza will try review sometime between today and the weekend.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request #1395: NIFI-3280 PostHTTP Option to write response to attr...

Posted by nickcarenza <gi...@git.apache.org>.
Github user nickcarenza commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1395#discussion_r113246581
  
    --- Diff: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PostHTTP.java ---
    @@ -880,6 +936,29 @@ public long getContentLength() {
             }
         }
     
    +    private FlowFile appendResponseData(final ProcessContext context, final ProcessSession session, final FlowFile original, String responseBody, int statusCode, String mimeType) {
    +        FlowFile appended = original;
    +        switch (context.getProperty(RESPONSE_BODY_DESTINATION).getValue()) {
    +            case DESTINATION_ATTRIBUTE:
    +                if (context.getProperty(RESPONSE_BODY_ATTRIBUTE).isSet()) {
    +                    appended = session.putAttribute(appended, context.getProperty(RESPONSE_BODY_ATTRIBUTE).getValue(), responseBody);
    +                } else {
    +                    getLogger().warn("{} is set to {} but {} is not set", new Object[]{RESPONSE_BODY_DESTINATION.getName(),DESTINATION_ATTRIBUTE,RESPONSE_BODY_ATTRIBUTE.getName()});
    --- End diff --
    
    I agree it should be detected in validation. I didn't realize properties could be validated within the context of other properties.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request #1395: NIFI-3280 PostHTTP Option to write response to attr...

Posted by trixpan <gi...@git.apache.org>.
Github user trixpan commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1395#discussion_r113209753
  
    --- Diff: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PostHTTP.java ---
    @@ -880,6 +936,29 @@ public long getContentLength() {
             }
         }
     
    +    private FlowFile appendResponseData(final ProcessContext context, final ProcessSession session, final FlowFile original, String responseBody, int statusCode, String mimeType) {
    +        FlowFile appended = original;
    +        switch (context.getProperty(RESPONSE_BODY_DESTINATION).getValue()) {
    +            case DESTINATION_ATTRIBUTE:
    +                if (context.getProperty(RESPONSE_BODY_ATTRIBUTE).isSet()) {
    +                    appended = session.putAttribute(appended, context.getProperty(RESPONSE_BODY_ATTRIBUTE).getValue(), responseBody);
    +                } else {
    +                    getLogger().warn("{} is set to {} but {} is not set", new Object[]{RESPONSE_BODY_DESTINATION.getName(),DESTINATION_ATTRIBUTE,RESPONSE_BODY_ATTRIBUTE.getName()});
    --- End diff --
    
    This should not be a warn. It should be an ERROR.
    
    I think it would be a good idea to add a custom validator to identify this very same issue during configuration, instead of ignoring it during execution.
    
    What do you think?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi issue #1395: NIFI-3280 PostHTTP Option to write response to attribute o...

Posted by nickcarenza <gi...@git.apache.org>.
Github user nickcarenza commented on the issue:

    https://github.com/apache/nifi/pull/1395
  
    @trixpan thanks for making me finally learn to rebase


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request #1395: NIFI-3280 [WIP] PostHTTP Option to write response t...

Posted by nickcarenza <gi...@git.apache.org>.
Github user nickcarenza commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1395#discussion_r94995239
  
    --- Diff: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PostHTTP.java ---
    @@ -16,49 +16,45 @@
      */
     package org.apache.nifi.processors.standard;
     
    --- End diff --
    
    - sorted imports
    - added org.apache.http.entity.ContentType
    - added org.apache.nifi.annotation.behavior.WritesAttribute
    - added org.apache.nifi.annotation.behavior.WritesAttributes


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi issue #1395: NIFI-3280 PostHTTP Option to write response to attribute o...

Posted by nickcarenza <gi...@git.apache.org>.
Github user nickcarenza commented on the issue:

    https://github.com/apache/nifi/pull/1395
  
    thanks @trixpan. i dont remember this failing builds. i will try to look at cleaning that up but i don't know that ill get to it this week.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi issue #1395: NIFI-3280 PostHTTP Option to write response to attribute o...

Posted by trixpan <gi...@git.apache.org>.
Github user trixpan commented on the issue:

    https://github.com/apache/nifi/pull/1395
  
    @nickcarenza thanks for the PR, much appreciated.
    
    I was going through it and got myself wondering:
    
    Is there any reason why we are doing this when InvokeHTTP processor cater for the very same need (i.e. POST followed by content to attributes)
    
    From its documentation:
    
    > **Put Response Body In Attribute**
    > 
    > _If set, the response body received back will be put into an attribute of the original FlowFile instead of a separate FlowFile. The attribute key to put to is determined by evaluating value of this property. 
    > Supports Expression Language: true_
    
    Keen to understand the reason as I suspect I am missing something


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---