New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NIFI-8181 - Added a property to specify whether to allow HTTP2 protoc… #4804
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @thenatog. Instead of adding a Boolean property, what about following the semantics of OkHttpClient.Builder.protocols()
and allowing the specification of the actual protocol values? OkHttpClient defaults to supporting HTTP 1.1 and HTTP 2, but also supports several other protocols according to current documentation.
To maintain backward compatibility with the default OkHttpClient.Builder configuration, setting the property value to HTTP 1.1 and HTTP 2 should be the default value. Allowing the specification of multiple protocol values using comma separation would support the capability described and also provide additional flexibility for other use cases. Supporting multiple values would require custom validation, but the Protocol
enum from OkHttpClient could be used to validate acceptable string values.
I guess it is possible to allow users to explicitly choose a protocol, but they are not mutually exclusive. If you choose HTTP/2, we will need to include HTTP/1.1 as well, which is basically what the True/False enables. I don't know if users are that interested in figuring out what protocol to choose eg. H2_PRIOR_KNOWLEDGE or QUIC. I can change the default to True. I also forgot to add user docs so I'll do that now. |
That's interesting @exceptionfactory. I didn't realize there were other additional protocols supported by the library. Personally I'm a bit torn on how I think we should best approach it. We can have a single property for specifying which protocols to support, but that has the downside that it's a bad user experience. It requires that the user look up the documentation each time to understand exactly what needs to be typed in, and must then type it in whereas the boolean approach allows them to just select the value (when it's appropriate). We could add an additional property for each protocol that that means we'd be adding several properties to a processor that already has a lot of properties. What it really comes down to, IMO, is a trade-off between power vs. ease of use. The boolean property is easier to use when it applies (which I think is going to be > 99% of the time) but is less powerful because it doesn't support the additional protocols. The other options are not as nice a user experience but are more powerful. Personally, I think we should lean more toward ease of use than power, so I think I prefer the boolean. |
I've set the default to True and realized the documentation for standard processors is compiled from PropertyDescriptor descriptions which I had already added. I think that allowing users to explicitly set protocols may be too library specific. "H2_PRIOR_KNOWLEDGE" for example sounds like it is specifically for use with the okhttp client library for certain use cases, and is not necessarily broadly applicable to HTTP generally. I may be wrong. My approach would be to go with this simpler approach for now, and if we find that users want more specific control then we can move to that. The issue again being that they would be specifying names of protocols that are derived from okhttp which may not exist in a different HTTP client library. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for comments @thenatog and @markap14. It is certainly a tradeoff between customization an ease of use, and it could get complicated when it comes to entering specific string values.
Staying with the Boolean property approach, would it make more sense to change the property to Disable HTTP/2
and set the default value to false
? That way, if the property is set to true
, the processor would explicitly set the HTTP/1.1
protocol, but otherwise would not set the protocols()
property in the OkHttpClient.Builder
. This would allow the default OkHttpClient behavior to be maintained, without necessarily having to specify the default protocols in this processor. I think this approach might also provide more flexibility in the future if the need arises to support some other protocols.
...e/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java
Outdated
Show resolved
Hide resolved
...e/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java
Outdated
Show resolved
Hide resolved
...e/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java
Show resolved
Hide resolved
...e/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java
Outdated
Show resolved
Hide resolved
…ctively the same thing. Fixed docs to show HTTP/2, small codestyle fixes.
@thenatog One additional note in favor of reversing the property to "Disable HTTP/2" instead of "Support HTTP2/": Naming a new property "Support HTTP/2" makes it sound like the processor did not previously support HTTP/2, when it actually did. In the end, these are certainly just semantic differences. Although leaning toward "Disable HTTP/2", if you and @markap14 prefer "Support HTTP/2", that's fine. |
I think I would be in favor of Disable also but don't have a particularly strong opinion. |
Updated to Disable HTTP/2 instead. |
Thanks for adjusting the property naming approach @thenatog. Built and tested. +1 Merging. |
This closes apache#4804 Signed-off-by: David Handermann <exceptionfactory@apache.org>
This closes apache#4804 Signed-off-by: David Handermann <exceptionfactory@apache.org>
…ol for requests.
Thank you for submitting a contribution to Apache NiFi.
Please provide a short description of the PR here:
Description of PR
Enables X functionality; fixes bug NIFI-YYYY.
In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
For all changes:
Is there a JIRA ticket associated with this PR? Is it referenced
in the commit message?
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
main
)?Is your initial contribution a single, squashed commit? Additional commits in response to PR reviewer feedback should be made on this branch and pushed to allow change tracking. Do not
squash
or use--force
when pushing to allow for clean monitoring of changes.For code changes:
mvn -Pcontrib-check clean install
at the rootnifi
folder?LICENSE
file, including the mainLICENSE
file undernifi-assembly
?NOTICE
file, including the mainNOTICE
file found undernifi-assembly
?.displayName
in addition to .name (programmatic access) for each of the new properties?For documentation related changes:
Note:
Please ensure that once the PR is submitted, you check GitHub Actions CI for build issues and submit an update to your PR as soon as possible.