Skip to content
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

feat: support disable HTTP/2 config #139

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion java/src/main/java/com/aliyun/teaopenapi/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class Client {
public String _key;
public String _cert;
public String _ca;
public Boolean _disableHttp2;
/**
* Init client with Config
* @param config config contains the necessary information to create a client
Expand Down Expand Up @@ -93,6 +94,7 @@ public Client(com.aliyun.teaopenapi.models.Config config) throws Exception {
this._key = config.key;
this._cert = config.cert;
this._ca = config.ca;
this._disableHttp2 = config.disableHttp2;
}

/**
Expand Down Expand Up @@ -944,7 +946,8 @@ public Client(com.aliyun.teaopenapi.models.Config config) throws Exception {
new TeaPair("policy", com.aliyun.teautil.Common.defaultString(runtime.backoffPolicy, "no")),
new TeaPair("period", com.aliyun.teautil.Common.defaultNumber(runtime.backoffPeriod, 1))
)),
new TeaPair("ignoreSSL", runtime.ignoreSSL)
new TeaPair("ignoreSSL", runtime.ignoreSSL),
new TeaPair("disableHttp2", Client.defaultAny(_disableHttp2, false))
);

TeaRequest _lastRequest = null;
Expand Down
14 changes: 14 additions & 0 deletions java/src/main/java/com/aliyun/teaopenapi/models/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ public class Config extends TeaModel {
@NameInMap("ca")
public String ca;

/**
* <p>disable HTTP/2</p>
*/
@NameInMap("disableHttp2")
public Boolean disableHttp2;

public static Config build(java.util.Map<String, ?> map) throws Exception {
Config self = new Config();
return TeaModel.build(map, self);
Expand Down Expand Up @@ -405,4 +411,12 @@ public String getCa() {
return this.ca;
}

public Config setDisableHttp2(Boolean disableHttp2) {
this.disableHttp2 = disableHttp2;
return this;
}
public Boolean getDisableHttp2() {
return this.disableHttp2;
}

}
7 changes: 5 additions & 2 deletions java/src/test/java/com/aliyun/teaopenapi/ClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public void testConfig() throws Exception {
new TeaPair("globalParameters", globalParameters),
new TeaPair("key", "config.key"),
new TeaPair("cert", "config.cert"),
new TeaPair("ca", "config.ca")
new TeaPair("ca", "config.ca"),
new TeaPair("disableHttp2", false)
));
com.aliyun.credentials.models.Config creConfig = com.aliyun.credentials.models.Config.build(TeaConverter.buildMap(
new TeaPair("accessKeyId", "accessKeyId"),
Expand Down Expand Up @@ -104,6 +105,7 @@ public void testConfig() throws Exception {
Assert.assertEquals("config.key", client._key);
Assert.assertEquals("config.cert", client._cert);
Assert.assertEquals("config.ca", client._ca);
Assert.assertEquals(false, client._disableHttp2);
}

public static Config createConfig() throws Exception {
Expand All @@ -126,7 +128,8 @@ public static Config createConfig() throws Exception {
new TeaPair("maxIdleConns", 128),
new TeaPair("signatureVersion", "config.signatureVersion"),
new TeaPair("signatureAlgorithm", "ACS3-HMAC-SHA256"),
new TeaPair("globalParameters", globalParameters)
new TeaPair("globalParameters", globalParameters),
new TeaPair("disableHttp2", true)
));
return config;
}
Expand Down
6 changes: 5 additions & 1 deletion main.tea
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type @globalParameters = GlobalParameters
type @key = string
type @cert = string
type @ca = string
type @disableHttp2 = boolean

model GlobalParameters {
headers?: map[string]string,
Expand Down Expand Up @@ -74,6 +75,7 @@ model Config {
key?: string(description='privite key for client certificate', example='MIIEvQ',default=''),
cert?: string(description='client certificate', example='-----BEGIN CERTIFICATE-----\nxxx-----END CERTIFICATE-----',default=''),
ca?: string(description='server certificate', example='-----BEGIN CERTIFICATE-----\nxxx-----END CERTIFICATE-----',default=''),
disableHttp2?: boolean(description='disable HTTP/2', example='false'),
}

/**
Expand Down Expand Up @@ -126,6 +128,7 @@ init(config: Config) {
@key = config.key;
@cert = config.cert;
@ca = config.ca;
@disableHttp2 = config.disableHttp2;
}

model OpenApiRequest {
Expand Down Expand Up @@ -955,7 +958,8 @@ api execute(params: Params, request: OpenApiRequest, runtime: Util.RuntimeOption
policy = Util.defaultString(runtime.backoffPolicy, 'no'),
period = Util.defaultNumber(runtime.backoffPeriod, 1)
},
ignoreSSL = runtime.ignoreSSL
ignoreSSL = runtime.ignoreSSL,
disableHttp2 = defaultAny(@disableHttp2, false)
}

/**
Expand Down
Loading