Skip to content

Commit edc79d8

Browse files
sp00mgcatanese
andauthored
feat(tls): allow disabling protocol upgrade (#1409)
* feat(tls): allow disable protocol upgrade * docs * No need to import RequestConfig --------- Co-authored-by: Beppe Catanese <[email protected]>
1 parent 7e6a06f commit edc79d8

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/main/java/com/adyen/Config.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class Config {
1717
protected String apiKey;
1818
protected int connectionTimeoutMillis;
1919
protected int readTimeoutMillis;
20+
protected Boolean protocolUpgradeEnabled;
2021

2122
//Terminal API Specific
2223
protected String terminalApiCloudEndpoint;
@@ -101,6 +102,18 @@ public void setReadTimeoutMillis(int readTimeoutMillis) {
101102
this.readTimeoutMillis = readTimeoutMillis;
102103
}
103104

105+
public Boolean getProtocolUpgradeEnabled() {
106+
return protocolUpgradeEnabled;
107+
}
108+
109+
/**
110+
* Whether the HTTP requests should automatically attempt to upgrade to a safer/newer version of the protocol.
111+
* See also {@link RequestConfig.Builder#setProtocolUpgradeEnabled(boolean)}.
112+
*/
113+
public void setProtocolUpgradeEnabled(Boolean protocolUpgradeEnabled) {
114+
this.protocolUpgradeEnabled = protocolUpgradeEnabled;
115+
}
116+
104117
public String getLiveEndpointUrlPrefix() {
105118
return this.liveEndpointUrlPrefix;
106119
}

src/main/java/com/adyen/httpclient/AdyenHttpClient.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ private HttpUriRequestBase createRequest(String endpoint, String requestBody, Co
121121
if (config.getConnectionTimeoutMillis() > 0) {
122122
builder.setConnectTimeout(config.getConnectionTimeoutMillis(), TimeUnit.MILLISECONDS);
123123
}
124+
if (config.getProtocolUpgradeEnabled() != null) {
125+
builder.setProtocolUpgradeEnabled(config.getProtocolUpgradeEnabled());
126+
}
124127
if (proxy != null && proxy.address() instanceof InetSocketAddress) {
125128
InetSocketAddress inetSocketAddress = (InetSocketAddress) proxy.address();
126129
builder.setProxy(new HttpHost(inetSocketAddress.getHostName(), inetSocketAddress.getPort()));

0 commit comments

Comments
 (0)