-
Notifications
You must be signed in to change notification settings - Fork 285
Expand file tree
/
Copy pathHeaderTest.java
More file actions
50 lines (44 loc) · 1.82 KB
/
HeaderTest.java
File metadata and controls
50 lines (44 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package com.tencentcloudapi.integration.requests;
import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import com.tencentcloudapi.cvm.v20170312.CvmClient;
import com.tencentcloudapi.cvm.v20170312.models.DescribeInstancesRequest;
import org.junit.Test;
import java.util.HashMap;
public class HeaderTest {
@Test
public void TestSetHeader() throws TencentCloudSDKException {
Credential cred = new Credential(
System.getenv("TENCENTCLOUD_SECRET_ID"),
System.getenv("TENCENTCLOUD_SECRET_KEY")
);
String[] signMethods = new String[]{
ClientProfile.SIGN_SHA1,
ClientProfile.SIGN_SHA256,
ClientProfile.SIGN_TC3_256
};
String[] reqMethods = new String[]{
HttpProfile.REQ_POST,
HttpProfile.REQ_GET,
};
for (String signMethod : signMethods) {
for (String reqMethod : reqMethods) {
ClientProfile cpf = new ClientProfile();
cpf.setSignMethod(signMethod);
HttpProfile hpf = new HttpProfile();
hpf.setReqMethod(reqMethod);
hpf.setProtocol("http://");
hpf.setEndpoint("9.134.89.153:81/tc_api");
cpf.setHttpProfile(hpf);
CvmClient client = new CvmClient(cred, "ap-guangzhou", cpf);
DescribeInstancesRequest req = new DescribeInstancesRequest();
req.SetHeader(new HashMap<String, String>() {{
put("Host", "cvm.tencentcloudapi.com");
}});
client.DescribeInstances(req);
}
}
}
}