mirror of https://github.com/apache/nifi.git
NIFI-8181 - Added Disable HTTP/2 property to InvokeHTTP
This closes #4804 Signed-off-by: David Handermann <exceptionfactory@apache.org>
This commit is contained in:
parent
40d8c41656
commit
4ebeb4e146
|
@ -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);
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue