This is an automated email from the ASF dual-hosted git repository.
exceptionfactory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push:
new 4ebeb4e NIFI-8181 - Added Disable HTTP/2 property to InvokeHTTP
4ebeb4e is described below
commit 4ebeb4e146390816cb5a0316a3a83e56e0d85f16
Author: Nathan Gough <[email protected]>
AuthorDate: Tue Feb 2 17:23:19 2021 -0500
NIFI-8181 - Added Disable HTTP/2 property to InvokeHTTP
This closes #4804
Signed-off-by: David Handermann <[email protected]>
---
.../nifi/processors/standard/InvokeHTTP.java | 22 ++++++++++++++++++++--
nifi-nar-bundles/nifi-standard-bundle/pom.xml | 4 ++--
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git
a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java
b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java
index aa331a6..07dd549 100644
---
a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java
+++
b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java
@@ -16,8 +16,6 @@
*/
package org.apache.nifi.processors.standard;
-import static org.apache.commons.lang3.StringUtils.trimToEmpty;
-
import com.burgstaller.okhttp.AuthenticationCacheInterceptor;
import com.burgstaller.okhttp.CachingAuthenticatorDecorator;
import com.burgstaller.okhttp.digest.CachingAuthenticator;
@@ -62,6 +60,7 @@ import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.MultipartBody.Builder;
import okhttp3.OkHttpClient;
+import okhttp3.Protocol;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
@@ -107,6 +106,8 @@ import org.apache.nifi.stream.io.StreamUtils;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
+import static org.apache.commons.lang3.StringUtils.trimToEmpty;
+
@SupportsBatching
@Tags({"http", "https", "rest", "client"})
@InputRequirement(Requirement.INPUT_ALLOWED)
@@ -474,6 +475,15 @@ public class InvokeHTTP extends AbstractProcessor {
.allowableValues("true", "false")
.build();
+ public static final PropertyDescriptor DISABLE_HTTP2_PROTOCOL = new
PropertyDescriptor.Builder()
+ .name("disable-http2")
+ .description("Determines whether or not to disable use of the
HTTP/2 protocol version. If disabled, only HTTP/1.1 is supported.")
+ .displayName("Disable HTTP/2")
+ .required(true)
+ .defaultValue("False")
+ .allowableValues("True", "False")
+ .build();
+
private static final ProxySpec[] PROXY_SPECS = {ProxySpec.HTTP_AUTH,
ProxySpec.SOCKS};
public static final PropertyDescriptor PROXY_CONFIGURATION_SERVICE
= ProxyConfiguration.createProxyConfigPropertyDescriptor(true,
PROXY_SPECS);
@@ -488,6 +498,7 @@ public class InvokeHTTP extends AbstractProcessor {
PROP_MAX_IDLE_CONNECTIONS,
PROP_DATE_HEADER,
PROP_FOLLOW_REDIRECTS,
+ DISABLE_HTTP2_PROTOCOL,
PROP_ATTRIBUTES_TO_SEND,
PROP_USERAGENT,
PROP_BASIC_AUTH_USERNAME,
@@ -743,6 +754,13 @@ public class InvokeHTTP extends AbstractProcessor {
okHttpClientBuilder.cache(new Cache(getETagCacheDir(),
maxCacheSizeBytes));
}
+ // Configure whether HTTP/2 protocol should be used or not
+ if (context.getProperty(DISABLE_HTTP2_PROTOCOL).asBoolean()) {
+ okHttpClientBuilder.protocols(Arrays.asList(Protocol.HTTP_1_1));
+ } else {
+ okHttpClientBuilder.protocols(Arrays.asList(Protocol.HTTP_1_1,
Protocol.HTTP_2));
+ }
+
// Set timeouts
okHttpClientBuilder.connectTimeout((context.getProperty(PROP_CONNECT_TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS).intValue()),
TimeUnit.MILLISECONDS);
okHttpClientBuilder.readTimeout(context.getProperty(PROP_READ_TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS).intValue(),
TimeUnit.MILLISECONDS);
diff --git a/nifi-nar-bundles/nifi-standard-bundle/pom.xml
b/nifi-nar-bundles/nifi-standard-bundle/pom.xml
index c29a5f3..7b78887 100644
--- a/nifi-nar-bundles/nifi-standard-bundle/pom.xml
+++ b/nifi-nar-bundles/nifi-standard-bundle/pom.xml
@@ -260,12 +260,12 @@
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
- <version>3.8.1</version>
+ <version>4.9.0</version>
</dependency>
<dependency>
<groupId>com.burgstaller</groupId>
<artifactId>okhttp-digest</artifactId>
- <version>1.18</version>
+ <version>2.1</version>
<type>jar</type>
</dependency>
<dependency>